Dynamic Complex Library 1.0.0
Reference-counted arbitrary precision complex number library (MIT OR Unlicense)
Loading...
Searching...
No Matches
Functions
Double Complex Functions

Functions for floating-point complex numbers. More...

Functions

dc_complex_double dc_double_from_doubles (double real, double imag)
 Create a floating-point complex number from real and imaginary parts.
 
dc_complex_double dc_double_from_polar (double magnitude, double angle)
 Create a floating-point complex number from polar coordinates.
 
dc_complex_double dc_double_zero (void)
 Get the floating-point complex zero (0.0 + 0.0i)
 
dc_complex_double dc_double_one (void)
 Get the floating-point complex one (1.0 + 0.0i)
 
dc_complex_double dc_double_i (void)
 Get the floating-point complex i (0.0 + 1.0i)
 
dc_complex_double dc_double_neg_one (void)
 Get the floating-point complex -1 (-1.0 + 0.0i)
 
dc_complex_double dc_double_neg_i (void)
 Get the floating-point complex -i (0.0 + -1.0i)
 
dc_complex_double dc_double_retain (dc_complex_double c)
 Increment reference count and return the same object.
 
void dc_double_release (dc_complex_double *c)
 Decrement reference count and possibly free memory.
 
dc_complex_double dc_double_copy (dc_complex_double c)
 Create a new copy with reference count 1.
 
dc_complex_double dc_double_add (dc_complex_double a, dc_complex_double b)
 Add two floating-point complex numbers.
 
dc_complex_double dc_double_sub (dc_complex_double a, dc_complex_double b)
 Subtract two floating-point complex numbers.
 
dc_complex_double dc_double_mul (dc_complex_double a, dc_complex_double b)
 Multiply two floating-point complex numbers.
 
dc_complex_double dc_double_div (dc_complex_double a, dc_complex_double b)
 Divide two floating-point complex numbers.
 
dc_complex_double dc_double_negate (dc_complex_double c)
 Negate a floating-point complex number.
 
dc_complex_double dc_double_conj (dc_complex_double c)
 Complex conjugate of a floating-point complex number.
 
dc_complex_double dc_double_exp (dc_complex_double c)
 Complex exponential function.
 
dc_complex_double dc_double_log (dc_complex_double c)
 Complex natural logarithm.
 
dc_complex_double dc_double_pow (dc_complex_double a, dc_complex_double b)
 Complex power function.
 
dc_complex_double dc_double_sqrt (dc_complex_double c)
 Complex square root.
 
dc_complex_double dc_double_sin (dc_complex_double c)
 Complex sine function.
 
dc_complex_double dc_double_cos (dc_complex_double c)
 Complex cosine function.
 
dc_complex_double dc_double_tan (dc_complex_double c)
 Complex tangent function.
 
dc_complex_double dc_double_sinh (dc_complex_double c)
 Complex hyperbolic sine function.
 
dc_complex_double dc_double_cosh (dc_complex_double c)
 Complex hyperbolic cosine function.
 
dc_complex_double dc_double_tanh (dc_complex_double c)
 Complex hyperbolic tangent function.
 
double dc_double_real (dc_complex_double c)
 Get the real part of a floating-point complex number.
 
double dc_double_imag (dc_complex_double c)
 Get the imaginary part of a floating-point complex number.
 
double dc_double_abs (dc_complex_double c)
 Get the absolute value (magnitude) of a complex number.
 
double dc_double_arg (dc_complex_double c)
 Get the argument (phase angle) of a complex number.
 
bool dc_double_eq (dc_complex_double a, dc_complex_double b)
 Test if two floating-point complex numbers are equal.
 
bool dc_double_is_zero (dc_complex_double c)
 Test if a floating-point complex number is zero.
 
bool dc_double_is_real (dc_complex_double c)
 Test if a floating-point complex number is real (imaginary part is zero)
 
bool dc_double_is_imag (dc_complex_double c)
 Test if a floating-point complex number is purely imaginary (real part is zero)
 
bool dc_double_is_nan (dc_complex_double c)
 Test if a floating-point complex number contains NaN.
 
bool dc_double_is_inf (dc_complex_double c)
 Test if a floating-point complex number contains infinity.
 
char * dc_double_to_string (dc_complex_double c)
 Convert floating-point complex number to mathematical string representation.
 

Detailed Description

Functions for floating-point complex numbers.

Function Documentation

◆ dc_double_abs()

double dc_double_abs ( dc_complex_double  c)
extern

Get the absolute value (magnitude) of a complex number.

Parameters
cThe complex number (must not be NULL)
Returns
The magnitude as a double
Note
Uses C99 complex.h cabs() function
Returns sqrt(real² + imag²)

◆ dc_double_add()

dc_complex_double dc_double_add ( dc_complex_double  a,
dc_complex_double  b 
)
extern

Add two floating-point complex numbers.

Parameters
aFirst operand (must not be NULL)
bSecond operand (must not be NULL)
Returns
New complex number a + b
Note
Result has reference count of 1
Uses IEEE 754 floating-point arithmetic

◆ dc_double_arg()

double dc_double_arg ( dc_complex_double  c)
extern

Get the argument (phase angle) of a complex number.

Parameters
cThe complex number (must not be NULL)
Returns
The angle in radians (-π to π)
Note
Uses C99 complex.h carg() function
Returns atan2(imag, real)

◆ dc_double_conj()

dc_complex_double dc_double_conj ( dc_complex_double  c)
extern

Complex conjugate of a floating-point complex number.

Parameters
cThe operand (must not be NULL)
Returns
New complex number with imaginary part negated
Note
Result has reference count of 1
For a+bi, returns a-bi
Uses C99 complex.h conj() function

◆ dc_double_copy()

dc_complex_double dc_double_copy ( dc_complex_double  c)
extern

Create a new copy with reference count 1.

Parameters
cThe complex number to copy (must not be NULL)
Returns
New complex number with same value
Note
Result has reference count of 1

◆ dc_double_cos()

dc_complex_double dc_double_cos ( dc_complex_double  c)
extern

Complex cosine function.

Parameters
cThe operand (must not be NULL)
Returns
New complex number cos(c)
Note
Result has reference count of 1
Uses C99 complex.h ccos() function

◆ dc_double_cosh()

dc_complex_double dc_double_cosh ( dc_complex_double  c)
extern

Complex hyperbolic cosine function.

Parameters
cThe operand (must not be NULL)
Returns
New complex number cosh(c)
Note
Result has reference count of 1
Uses C99 complex.h ccosh() function

◆ dc_double_div()

dc_complex_double dc_double_div ( dc_complex_double  a,
dc_complex_double  b 
)
extern

Divide two floating-point complex numbers.

Parameters
aDividend (must not be NULL)
bDivisor (must not be NULL and not zero)
Returns
New complex number a / b
Note
Result has reference count of 1
Uses C99 complex.h division

◆ dc_double_eq()

bool dc_double_eq ( dc_complex_double  a,
dc_complex_double  b 
)
extern

Test if two floating-point complex numbers are equal.

Parameters
aFirst operand (must not be NULL)
bSecond operand (must not be NULL)
Returns
true if a == b (exact equality), false otherwise
Note
Uses exact floating-point comparison
Consider using epsilon comparison for numerical stability

◆ dc_double_exp()

dc_complex_double dc_double_exp ( dc_complex_double  c)
extern

Complex exponential function.

Parameters
cThe operand (must not be NULL)
Returns
New complex number e^c
Note
Result has reference count of 1
Uses C99 complex.h cexp() function

◆ dc_double_from_doubles()

dc_complex_double dc_double_from_doubles ( double  real,
double  imag 
)
extern

Create a floating-point complex number from real and imaginary parts.

Parameters
realThe real part
imagThe imaginary part
Returns
New floating-point complex number (must be released)
Note
Result has reference count of 1

◆ dc_double_from_polar()

dc_complex_double dc_double_from_polar ( double  magnitude,
double  angle 
)
extern

Create a floating-point complex number from polar coordinates.

Parameters
magnitudeThe magnitude (radius)
angleThe angle in radians
Returns
New floating-point complex number (must be released)
Note
Result has reference count of 1
Uses formula: magnitude * e^(i*angle)

◆ dc_double_i()

dc_complex_double dc_double_i ( void  )
extern

Get the floating-point complex i (0.0 + 1.0i)

Returns
Singleton imaginary unit
Note
This is a singleton with high reference count

◆ dc_double_imag()

double dc_double_imag ( dc_complex_double  c)
extern

Get the imaginary part of a floating-point complex number.

Parameters
cThe complex number (must not be NULL)
Returns
The imaginary part as a double
Note
Uses C99 complex.h cimag() function

◆ dc_double_is_imag()

bool dc_double_is_imag ( dc_complex_double  c)
extern

Test if a floating-point complex number is purely imaginary (real part is zero)

Parameters
cThe complex number (must not be NULL)
Returns
true if real part is 0.0, false otherwise

◆ dc_double_is_inf()

bool dc_double_is_inf ( dc_complex_double  c)
extern

Test if a floating-point complex number contains infinity.

Parameters
cThe complex number (must not be NULL)
Returns
true if either component is infinite, false otherwise
Note
Uses isinf() for both real and imaginary parts

◆ dc_double_is_nan()

bool dc_double_is_nan ( dc_complex_double  c)
extern

Test if a floating-point complex number contains NaN.

Parameters
cThe complex number (must not be NULL)
Returns
true if either component is NaN, false otherwise
Note
Uses isnan() for both real and imaginary parts

◆ dc_double_is_real()

bool dc_double_is_real ( dc_complex_double  c)
extern

Test if a floating-point complex number is real (imaginary part is zero)

Parameters
cThe complex number (must not be NULL)
Returns
true if imaginary part is 0.0, false otherwise

◆ dc_double_is_zero()

bool dc_double_is_zero ( dc_complex_double  c)
extern

Test if a floating-point complex number is zero.

Parameters
cThe complex number (must not be NULL)
Returns
true if c == 0.0+0.0i, false otherwise

◆ dc_double_log()

dc_complex_double dc_double_log ( dc_complex_double  c)
extern

Complex natural logarithm.

Parameters
cThe operand (must not be NULL and not zero)
Returns
New complex number log(c)
Note
Result has reference count of 1
Uses C99 complex.h clog() function
Principal branch of logarithm

◆ dc_double_mul()

dc_complex_double dc_double_mul ( dc_complex_double  a,
dc_complex_double  b 
)
extern

Multiply two floating-point complex numbers.

Parameters
aFirst operand (must not be NULL)
bSecond operand (must not be NULL)
Returns
New complex number a * b
Note
Result has reference count of 1
Uses C99 complex.h multiplication

◆ dc_double_neg_i()

dc_complex_double dc_double_neg_i ( void  )
extern

Get the floating-point complex -i (0.0 + -1.0i)

Returns
Singleton negative imaginary unit
Note
This is a singleton with high reference count

◆ dc_double_neg_one()

dc_complex_double dc_double_neg_one ( void  )
extern

Get the floating-point complex -1 (-1.0 + 0.0i)

Returns
Singleton negative one complex number
Note
This is a singleton with high reference count

◆ dc_double_negate()

dc_complex_double dc_double_negate ( dc_complex_double  c)
extern

Negate a floating-point complex number.

Parameters
cThe operand (must not be NULL)
Returns
New complex number -c
Note
Result has reference count of 1

◆ dc_double_one()

dc_complex_double dc_double_one ( void  )
extern

Get the floating-point complex one (1.0 + 0.0i)

Returns
Singleton one complex number
Note
This is a singleton with high reference count

◆ dc_double_pow()

dc_complex_double dc_double_pow ( dc_complex_double  a,
dc_complex_double  b 
)
extern

Complex power function.

Parameters
aBase (must not be NULL)
bExponent (must not be NULL)
Returns
New complex number a^b
Note
Result has reference count of 1
Uses C99 complex.h cpow() function
Principal branch for multi-valued functions

◆ dc_double_real()

double dc_double_real ( dc_complex_double  c)
extern

Get the real part of a floating-point complex number.

Parameters
cThe complex number (must not be NULL)
Returns
The real part as a double
Note
Uses C99 complex.h creal() function

◆ dc_double_release()

void dc_double_release ( dc_complex_double c)
extern

Decrement reference count and possibly free memory.

Parameters
cPointer to complex number pointer (gracefully handles NULL)
Note
Sets *c to NULL after release
Only frees memory when reference count reaches 0
Singletons are never freed

◆ dc_double_retain()

dc_complex_double dc_double_retain ( dc_complex_double  c)
extern

Increment reference count and return the same object.

Parameters
cThe complex number to retain (must not be NULL)
Returns
The same object passed in
Note
Increases reference count by 1

◆ dc_double_sin()

dc_complex_double dc_double_sin ( dc_complex_double  c)
extern

Complex sine function.

Parameters
cThe operand (must not be NULL)
Returns
New complex number sin(c)
Note
Result has reference count of 1
Uses C99 complex.h csin() function

◆ dc_double_sinh()

dc_complex_double dc_double_sinh ( dc_complex_double  c)
extern

Complex hyperbolic sine function.

Parameters
cThe operand (must not be NULL)
Returns
New complex number sinh(c)
Note
Result has reference count of 1
Uses C99 complex.h csinh() function

◆ dc_double_sqrt()

dc_complex_double dc_double_sqrt ( dc_complex_double  c)
extern

Complex square root.

Parameters
cThe operand (must not be NULL)
Returns
New complex number sqrt(c)
Note
Result has reference count of 1
Uses C99 complex.h csqrt() function
Principal branch with Re(sqrt(c)) >= 0

◆ dc_double_sub()

dc_complex_double dc_double_sub ( dc_complex_double  a,
dc_complex_double  b 
)
extern

Subtract two floating-point complex numbers.

Parameters
aFirst operand (must not be NULL)
bSecond operand (must not be NULL)
Returns
New complex number a - b
Note
Result has reference count of 1
Uses IEEE 754 floating-point arithmetic

◆ dc_double_tan()

dc_complex_double dc_double_tan ( dc_complex_double  c)
extern

Complex tangent function.

Parameters
cThe operand (must not be NULL)
Returns
New complex number tan(c)
Note
Result has reference count of 1
Uses C99 complex.h ctan() function

◆ dc_double_tanh()

dc_complex_double dc_double_tanh ( dc_complex_double  c)
extern

Complex hyperbolic tangent function.

Parameters
cThe operand (must not be NULL)
Returns
New complex number tanh(c)
Note
Result has reference count of 1
Uses C99 complex.h ctanh() function

◆ dc_double_to_string()

char * dc_double_to_string ( dc_complex_double  c)
extern

Convert floating-point complex number to mathematical string representation.

Parameters
cThe complex number (must not be NULL)
Returns
Newly allocated string (must be freed with free())
Note
Format examples: "3.14+2.71i", "1.5-2.3i", "2.71i", "-i", "3.14", "0"
Uses mathematical notation with 'i' for imaginary unit
Uses g format for compact representation

◆ dc_double_zero()

dc_complex_double dc_double_zero ( void  )
extern

Get the floating-point complex zero (0.0 + 0.0i)

Returns
Singleton zero complex number
Note
This is a singleton with high reference count