本文整理匯總了C++中GSL_SET_COMPLEX函數的典型用法代碼示例。如果您正苦於以下問題:C++ GSL_SET_COMPLEX函數的具體用法?C++ GSL_SET_COMPLEX怎麽用?C++ GSL_SET_COMPLEX使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了GSL_SET_COMPLEX函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: gsl_complex_sub
gsl_complex
gsl_complex_sub (gsl_complex a, gsl_complex b)
{ /* z=a-b */
double ar = GSL_REAL (a), ai = GSL_IMAG (a);
double br = GSL_REAL (b), bi = GSL_IMAG (b);
gsl_complex z;
GSL_SET_COMPLEX (&z, ar - br, ai - bi);
return z;
}
示例2: gsl_complex_add
gsl_complex
gsl_complex_add (gsl_complex a, gsl_complex b)
{ /* z=a+b */
double ar = GSL_REAL (a), ai = GSL_IMAG (a);
double br = GSL_REAL (b), bi = GSL_IMAG (b);
gsl_complex z;
GSL_SET_COMPLEX (&z, ar + br, ai + bi);
return z;
}
示例3: v1
/** Subtraction operator (vector) */
vector<complex> vector<complex>::operator-(const vector<complex>& v) const
{
vector<complex> v1(_vector);
gsl_complex z1;
GSL_SET_COMPLEX(&z1, -1., 0.);
if (gsl_blas_zaxpy(z1, v.as_gsl_type_ptr(), v1.as_gsl_type_ptr())) {
std::cout << "\n Error in vector<complex> -" << std::endl;
exit(EXIT_FAILURE);
}
return v1;
}
示例4: gsl_complex_min_real
/* ------------------------------------------------------ */
gsl_complex gsl_complex_min_real (gsl_complex a, gsl_complex b)
{
gsl_complex z;
double min;
/* just consider real parts */
min = GSL_REAL(a) < GSL_REAL(b) ? GSL_REAL(a) : GSL_REAL(b);
GSL_SET_COMPLEX (&z, min, 0);
return z;
}
示例5: gsl_complex_cos
gsl_complex
gsl_complex_cos (gsl_complex a)
{ /* z = cos(a) */
double R = GSL_REAL (a), I = GSL_IMAG (a);
gsl_complex z;
if (I == 0.0)
{
/* avoid returing negative zero (-0.0) for the imaginary part */
GSL_SET_COMPLEX (&z, cos (R), 0.0);
}
else
{
GSL_SET_COMPLEX (&z, cos (R) * cosh (I), sin (R) * sinh (-I));
}
return z;
}
示例6: gsl_complex_pow_real
gsl_complex
gsl_complex_pow_real (gsl_complex a, double b)
{ /* z=a^b */
gsl_complex z;
if (GSL_REAL (a) == 0 && GSL_IMAG (a) == 0)
{
GSL_SET_COMPLEX (&z, 0, 0);
}
else
{
double logr = gsl_complex_logabs (a);
double theta = gsl_complex_arg (a);
double rho = exp (logr * b);
double beta = theta * b;
GSL_SET_COMPLEX (&z, rho * cos (beta), rho * sin (beta));
}
return z;
}
示例7: gsl_complex_max_real
/* ------------------------------------------------------ */
gsl_complex gsl_complex_max_real (gsl_complex a, gsl_complex b)
{
gsl_complex z;
double max;
/* just consider real parts */
max = GSL_REAL(a) > GSL_REAL(b) ? GSL_REAL(a) : GSL_REAL(b);
GSL_SET_COMPLEX (&z, max, 0);
return z;
}
示例8: GSL_SET_COMPLEX
complex_spinor complex_spinor::operator+(const complex_spinor & complex_spinor_param)const{
gsl_complex aux_UP;
gsl_complex aux_DOWN;
GSL_SET_COMPLEX(&aux_UP, 0, 0);
GSL_SET_COMPLEX(&aux_DOWN, 0, 0);
int i;
int nSitios = this->_numSites;
complex_spinor complex_spinor_res(nSitios);
for(i=0; i<nSitios ; i++){
aux_UP = gsl_complex_add(complex_spinor_param.complex_spinor_get(i, UP) , this->complex_spinor_get(i, UP));
aux_DOWN = gsl_complex_add(complex_spinor_param.complex_spinor_get(i, DOWN) , this->complex_spinor_get(i,DOWN));
complex_spinor_res.complex_spinor_set(i, UP, aux_UP);
complex_spinor_res.complex_spinor_set(i, DOWN, aux_DOWN);
}
return complex_spinor_res;
}
示例9: gsl_complex_pow
gsl_complex gsl_complex_pow(gsl_complex a, gsl_complex b)
{ /* z=a^b */
gsl_complex z;
if (GSL_REAL(a) == 0 && GSL_IMAG(a) == 0.0) {
GSL_SET_COMPLEX(&z, 0.0, 0.0);
} else {
double logr = gsl_complex_logabs(a);
double theta = gsl_complex_arg(a);
double br = GSL_REAL(b), bi = GSL_IMAG(b);
double rho = exp(logr * br - bi * theta);
double beta = theta * br + bi * logr;
GSL_SET_COMPLEX(&z, rho * cos(beta), rho * sin(beta));
}
return z;
}
示例10: gsl_complex_sqrt
gsl_complex
gsl_complex_sqrt (gsl_complex a)
{ /* z=sqrt(a) */
gsl_complex z;
if (GSL_REAL (a) == 0.0 && GSL_IMAG (a) == 0.0)
{
GSL_SET_COMPLEX (&z, 0, 0);
}
else
{
double x = fabs (GSL_REAL (a));
double y = fabs (GSL_IMAG (a));
double w;
if (x >= y)
{
double t = y / x;
w = sqrt (x) * sqrt (0.5 * (1.0 + sqrt (1.0 + t * t)));
}
else
{
double t = x / y;
w = sqrt (y) * sqrt (0.5 * (t + sqrt (1.0 + t * t)));
}
if (GSL_REAL (a) >= 0.0)
{
double ai = GSL_IMAG (a);
GSL_SET_COMPLEX (&z, w, ai / (2.0 * w));
}
else
{
double ai = GSL_IMAG (a);
double vi = (ai >= 0) ? w : -w;
GSL_SET_COMPLEX (&z, ai / (2.0 * vi), vi);
}
}
return z;
}
示例11: do_ccmul
static int
do_ccmul(lua_State *L, mMatComplex *a, double b_re, double b_im)
{
mMatComplex *r = qlua_newMatComplex(L, a->l_size, a->r_size);
gsl_complex z;
gsl_matrix_complex_memcpy(r->m, a->m);
GSL_SET_COMPLEX(&z, b_re, b_im);
gsl_matrix_complex_scale(r->m, z);
return 1;
}
示例12: gsl_complex_polar
void
complex::assign(const double& real=0., const double& imag=0.,
bool polar=false)
{
if (polar)
_complex = gsl_complex_polar(real,imag);
else
{
GSL_SET_COMPLEX(&_complex, real, imag);
// *_complex = gsl_complex_rect(real,imag);
}
}
示例13: cm_mul_cm
static int
cm_mul_cm(lua_State *L)
{
mMatComplex *a = qlua_checkMatComplex(L, 1);
mMatComplex *b = qlua_checkMatComplex(L, 2);
int al = a->l_size;
int ar = a->r_size;
int bl = b->l_size;
int br = b->r_size;
mMatComplex *r = qlua_newMatComplex(L, al, br);
gsl_complex z1, z0;
if (ar != bl)
return luaL_error(L, "matrix sizes mismatch in m * m");
GSL_SET_COMPLEX(&z1, 1.0, 0.0);
GSL_SET_COMPLEX(&z0, 0.0, 0.0);
gsl_blas_zgemm(CblasNoTrans, CblasNoTrans, z1, a->m, b->m, z0, r->m);
return 1;
}
示例14: AllFacetHarmonics
void CModel::AllFacetHarmonics(int bw, double r, gsl_complex *coeff){
for(int i=0; i<bw*bw; i++) GSL_SET_COMPLEX(&coeff[i], 0.0, 0.0);
gsl_complex *temp = new gsl_complex[bw*bw];
for(int i=0; i<f_no; i++){
FacetHarmonics(i, bw, r, temp);
for(int j=0; j<bw*bw; j++) coeff[j] = gsl_complex_add(coeff[j],temp[j]);
}
delete [] temp;
}
示例15: gsl_complex_arccos
gsl_complex gsl_complex_arccos(gsl_complex a)
{ /* z = arccos(a) */
double R = GSL_REAL(a), I = GSL_IMAG(a);
gsl_complex z;
if (I == 0) {
z = gsl_complex_arccos_real(R);
} else {
double x = fabs(R), y = fabs(I);
double r = hypot(x + 1, y), s = hypot(x - 1, y);
double A = 0.5 * (r + s);
double B = x / A;
double y2 = y * y;
double real, imag;
const double A_crossover = 1.5, B_crossover = 0.6417;
if (B <= B_crossover) {
real = acos(B);
} else {
if (x <= 1) {
double D =
0.5 * (A + x) * (y2 / (r + x + 1) + (s + (1 - x)));
real = atan(sqrt(D) / x);
} else {
double Apx = A + x;
double D = 0.5 * (Apx / (r + x + 1) + Apx / (s + (x - 1)));
real = atan((y * sqrt(D)) / x);
}
}
if (A <= A_crossover) {
double Am1;
if (x < 1) {
Am1 = 0.5 * (y2 / (r + (x + 1)) + y2 / (s + (1 - x)));
} else {
Am1 = 0.5 * (y2 / (r + (x + 1)) + (s + (x - 1)));
}
imag = log1p(Am1 + sqrt(Am1 * (A + 1)));
} else {
imag = log(A + sqrt(A * A - 1));
}
GSL_SET_COMPLEX(&z, (R >= 0) ? real : M_PI - real,
(I >= 0) ? -imag : imag);
}
return z;
}