amath  1.8.5
Simple command line calculator
csgn.c File Reference
#include "prim.h"
Include dependency graph for csgn.c:

Go to the source code of this file.

Functions

double csgn (complex z)
 Complex signum. More...
 

Function Documentation

◆ csgn()

double csgn ( complex  z)

Complex signum.

More info is available at Wikipedia:
https://wikipedia.org/wiki/Sign_function#Complex_signum

Definition at line 38 of file csgn.c.

References cimag(), and creal().

Referenced by ComplexNumber::Signum().

39 {
40  double a = creal(z);
41 
42  if (a > 0.0)
43  {
44  return 1.0;
45  }
46  else if (a < 0.0)
47  {
48  return -1.0;
49  }
50  else
51  {
52  double b = cimag(z);
53  return b > 0.0 ? 1.0 : b < 0.0 ? -1.0 : 0.0;
54  }
55 }
double cimag(complex z)
Imaginary part of complex number.
Definition: prim.c:46
double creal(complex z)
Real part of complex number.
Definition: prim.c:38
Here is the call graph for this function:
Here is the caller graph for this function: