Element manipulation

Basic element manipulation and I/O

Return the real/imaginary part of an element

C++ API

T RealPart(const T &alpha)
T ImagPart(const T &alpha)

C API

Note

Since C does not support generic programming, it is best to directly manipulate the structure for complex data.

Set the real/imaginary part of an element

Note

If an element is non-complex, an error is thrown if an attempt is made to set its imaginary component.

C++ API

void SetRealPart(T &alpha, Base<T> &beta)
void SetImagPart(T &alpha, Base<T> &beta)

C API

Note

Since C does not support generic programming, it is best to directly manipulate the structure for complex data.

Update the real/imaginary part of an element

Note

If an element is non-complex, an error is thrown if an attempt is made to update its imaginary component.

C++ API

void UpdateRealPart(T &alpha, Base<T> &beta)
void UpdateImagPart(T &alpha, Base<T> &beta)

C API

Note

Since C does not support generic programming, it is best to directly manipulate the structure for complex data.

Conjugate an element

C++ API

F Conj(const F &alpha)

C API

Note

Since C does not support generic programming, it is best to directly manipulate the structure for complex data.

Return the complex argument

C++ API

Base<F> Arg(const F &alpha)

C API

ElError ElArg_s(float alpha, float* result)
ElError ElArg_d(double alpha, double* result)
ElError ElArg_c(complex_float alpha, float* result)
ElError ElArg_z(complex_double alpha, double* result)

Construct a complex number from its polar coordinates

C++ API

Complex<Real> Polar(const R &r, const R &theta = 0)

C API

ElError ElComplexFromPolar_c(float r, float theta, complex_float* result)
ElError ElComplexFromPolar_z(double r, double theta, complex_double* result)

Magnitude and sign

C++ API

Base<F> Abs(const F &alpha)

Use the naive algorithm for computing the absolute value (note that unnecessary overflow may occur for complex values, please see SafeAbs())

Real SafeAbs(const Complex<Real> &alpha)

Carefully avoid overflow via slapy2 or dlapy2

Real FastAbs(const Complex<Real> &alpha)

Return the sum of the absolute values of the real and imaginary components

Real Sgn(const Real &alpha, bool symmetric = true)

If \(\alpha \neq 0\), \(\alpha/|\alpha|\) is returned. If symmetric is true, \(\text{sgn}(0)=0\), otherwise, \(\text{sgn}(0)=1\).

C API

ElError ElAbs_i(ElInt alpha, ElInt* result)
ElError ElAbs_s(float alpha, float* result)
ElError ElAbs_d(double alpha, double* result)
ElError ElAbs_c(complex_float alpha, float* result)
ElError ElAbs_z(complex_double alpha, double* result)
ElError ElSafeAbs_c(complex_float alpha, float* result)
ElError ElSafeAbs_z(complex_double alpha, double* result)
ElError ElFastAbs_c(complex_float alpha, float* result)
ElError ElFastAbs_z(complex_double alpha, double* result)
ElError ElSgn_i(ElInt alpha, bool symmetric, ElInt* result)
ElError ElSgn_s(float alpha, bool symmetric, float* result)
ElError ElSgn_d(double alpha, bool symmetric, double* result)

Exponentiation

C++ API

F Exp(const F &alpha)

Returns the exponential of a scalar

F Pow(const F &alpha, const T &beta)

Returns \(\alpha^\beta\) for scalar \(\alpha\) and scalar or integer \(\beta\)

F Log(const F &alpha)

Returns the natural logarithm of a scalar

F Sqrt(const F &alpha)

Returns the square-root of a scalar

C API

ElError ElExp_s(float alpha, float* result)
ElError ElExp_d(double alpha, double* result)
ElError ElExp_c(complex_float alpha, complex_float* result)
ElError ElExp_z(complex_double alpha, complex_double* result)
ElError ElPow_s(float alpha, float beta, float* result)
ElError ElPow_d(double alpha, double beta, double* result)
ElError ElPow_c(complex_float alpha, complex_float beta, complex_float* result)
ElError ElPow_z(complex_double alpha, complex_double beta, complex_double* result)
ElError ElLog_s(float alpha, float* result)
ElError ElLog_d(double alpha, double* result)
ElError ElLog_c(complex_float alpha, complex_float* result)
ElError ElLog_z(complex_double alpha, complex_double* result)
ElError ElSqrt_s(float alpha, float* result)
ElError ElSqrt_d(double alpha, double* result)
ElError ElSqrt_c(complex_float alpha, complex_float* result)
ElError ElSqrt_z(complex_double alpha, complex_double* result)

Trigonometric functions

C++ API

F Cos(const F &alpha)
F Sin(const F &alpha)
F Tan(const F &alpha)

Trigonometric functions

Acos(const F &alpha)
Asin(const F &alpha)
Atan(const F &alpha)

Inverse trigonometric functions

Real Atan2(const Real &y, const Real &x)

Return the inverse tangent of \(x+iy\)

C API

ElError ElCos_s(float alpha, float* result)
ElError ElCos_d(double alpha, double* result)
ElError ElCos_c(complex_float alpha, complex_float* result)
ElError ElCos_z(complex_double alpha, complex_double* result)
ElError ElSin_s(float alpha, float* result)
ElError ElSin_d(double alpha, double* result)
ElError ElSin_c(complex_float alpha, complex_float* result)
ElError ElSin_z(complex_double alpha, complex_double* result)
ElError ElTan_s(float alpha, float* result)
ElError ElTan_d(double alpha, double* result)
ElError ElTan_c(complex_float alpha, complex_float* result)
ElError ElTan_z(complex_double alpha, complex_double* result)

Trigonometric functions

ElError ElAcos_s(float alpha, float* result)
ElError ElAcos_d(double alpha, double* result)
ElError ElAcos_c(complex_float alpha, complex_float* result)
ElError ElAcos_z(complex_double alpha, complex_double* result)
ElError ElAsin_s(float alpha, float* result)
ElError ElAsin_d(double alpha, double* result)
ElError ElAsin_c(complex_float alpha, complex_float* result)
ElError ElAsin_z(complex_double alpha, complex_double* result)
ElError ElAtan_s(float alpha, float* result)
ElError ElAtan_d(double alpha, double* result)
ElError ElAtan_c(complex_float alpha, complex_float* result)
ElError ElAtan_z(complex_double alpha, complex_double* result)

Inverse trigonometric functions

ElError ElAtan2_s(float y, float x, float* result)
ElError ElAtan2_d(double y, double x, double* result)

Return the inverse tangent of the point \(x + i y\)

Hyperbolic functions

C++ API

F Cosh(const F &alpha)
F Sinh(const F &alpha)
F Tanh(const F &alpha)

Hyperbolic functions

Acosh(const F &alpha)
Asinh(const F &alpha)
Atanh(const F &alpha)

Inverse hyperbolic functions

C API

ElError ElCosh_s(float alpha, float* result)
ElError ElCosh_d(double alpha, double* result)
ElError ElCosh_c(complex_float alpha, complex_float* result)
ElError ElCosh_z(complex_double alpha, complex_double* result)
ElError ElSinh_s(float alpha, float* result)
ElError ElSinh_d(double alpha, double* result)
ElError ElSinh_c(complex_float alpha, complex_float* result)
ElError ElSinh_z(complex_double alpha, complex_double* result)
ElError ElTanh_s(float alpha, float* result)
ElError ElTanh_d(double alpha, double* result)
ElError ElTanh_c(complex_float alpha, complex_float* result)
ElError ElTanh_z(complex_double alpha, complex_double* result)

Hyperbolic functions

ElError ElAcosh_s(float alpha, float* result)
ElError ElAcosh_d(double alpha, double* result)
ElError ElAcosh_c(complex_float alpha, complex_float* result)
ElError ElAcosh_z(complex_double alpha, complex_double* result)
ElError ElAsinh_s(float alpha, float* result)
ElError ElAsinh_d(double alpha, double* result)
ElError ElAsinh_c(complex_float alpha, complex_float* result)
ElError ElAsinh_z(complex_double alpha, complex_double* result)
ElError ElAtanh_s(float alpha, float* result)
ElError ElAtanh_d(double alpha, double* result)
ElError ElAtanh_c(complex_float alpha, complex_float* result)
ElError ElAtanh_z(complex_double alpha, complex_double* result)

Inverse hyperbolic functions