MathParser\Extensions\Complex Class Reference

Implementation of complex number arithmetic with the standard transcendental functions. More...

Public Member Functions

 __construct ($real, $imag)
 Constructor. More...
 
 r ()
 Real part. More...
 
 i ()
 Imaginary part. More...
 
 abs ()
 Modulus (absolute value) More...
 
 arg ()
 Argument (principal value) More...
 
 is_nan ()
 test if the complex number is NAN More...
 
 __toString ()
 string representation of a complex number More...
 
 signed ()
 

Static Public Member Functions

static parse ($value)
 convert data to a complex number, if possible More...
 
static create ($real, $imag)
 create a complex number from its real and imaginary parts More...
 
static add ($z, $w)
 add two complex numbers More...
 
static sub ($z, $w)
 subtract two complex numbers More...
 
static mul ($z, $w)
 multiply two complex numbers More...
 
static div ($z, $w)
 divide two complex numbers More...
 
static pow ($z, $w)
 powers of two complex numbers More...
 
static sin ($z)
 complex sine function More...
 
static cos ($z)
 complex cosine function More...
 
static tan ($z)
 complex tangent function More...
 
static cot ($z)
 complex cotangent function More...
 
static arcsin ($z)
 complex inverse sine function More...
 
static arccos ($z)
 complex inverse cosine function More...
 
static arctan ($z)
 complex inverse tangent function More...
 
static arccot ($z)
 complex inverse cotangent function More...
 
static exp ($z)
 complex exponential function More...
 
static log ($z)
 complex logarithm function More...
 
static sinh ($z)
 complex hyperbolic sine function More...
 
static cosh ($z)
 complex hyperbolic cosine function More...
 
static tanh ($z)
 complex hyperbolic tangent function More...
 
static arsinh ($z)
 complex inverse hyperbolic sine function More...
 
static arcosh ($z)
 complex inverse hyperbolic cosine function More...
 
static artanh ($z)
 complex inverse hyperbolic tangent function More...
 
static sqrt ($z)
 complex square root function More...
 

Static Private Member Functions

static isSignedReal ($value)
 check whether a string represents a signed real number More...
 
static parseReal ($value)
 convert string to floating point number, if possible More...
 
static toFloat ($x)
 convert data to a floating point number, if possible More...
 
static powi ($z, $n)
 integer power of a complex number More...
 

Private Attributes

 $x
 float $x real part
 
 $y
 float $y real part
 

Detailed Description

Implementation of complex number arithmetic with the standard transcendental functions.

Example:

$z = new Complex(3, 4); // creates the complex number 3+4i
$w = new Complex(-1, 1); // creates the complex number -1+i
$product = Complex::mul($z, $w) // computes the product (3+4i)(-1+i)

Constructor & Destructor Documentation

MathParser\Extensions\Complex::__construct (   $real,
  $imag 
)

Constructor.

Construct a complex number with given real and imaginary part

Parameters
float$realreal part
float$imagimaginary part

Member Function Documentation

MathParser\Extensions\Complex::__toString ( )

string representation of a complex number

Parameters
mixed$z(Complex, or parsable to Complex)
Return values
string
MathParser\Extensions\Complex::abs ( )

Modulus (absolute value)

Return the modulus of the complex number z=x+iy, i.e. sqrt(x^2 + y^2)

Return values
floatmodulus
static MathParser\Extensions\Complex::add (   $z,
  $w 
)
static

add two complex numbers

Complex::add($z, $w) computes and returns $z+$w

Parameters
mixed$z(Complex, or parsable to Complex)
mixed$w(Complex, or parsable to Complex)
Return values
Complex
static MathParser\Extensions\Complex::arccos (   $z)
static

complex inverse cosine function

Complex::arccos($z) computes and returns the principal branch of arccos($z)

Parameters
mixed$z(Complex, or parsable to Complex)
Return values
Complex
static MathParser\Extensions\Complex::arccot (   $z)
static

complex inverse cotangent function

Complex::arccot($z) computes and returns the principal branch of arccot($z)

Parameters
mixed$z(Complex, or parsable to Complex)
Return values
Complex
static MathParser\Extensions\Complex::arcosh (   $z)
static

complex inverse hyperbolic cosine function

Complex::arcosh($z) computes and returns the principal branch of arcosh($z)

Parameters
mixed$z(Complex, or parsable to Complex)
Return values
Complex
static MathParser\Extensions\Complex::arcsin (   $z)
static

complex inverse sine function

Complex::arcsin($z) computes and returns the principal branch of arcsin($z)

Parameters
mixed$z(Complex, or parsable to Complex)
Return values
Complex
static MathParser\Extensions\Complex::arctan (   $z)
static

complex inverse tangent function

Complex::arctan($z) computes and returns the principal branch of arctan($z)

Parameters
mixed$z(Complex, or parsable to Complex)
Return values
Complex
MathParser\Extensions\Complex::arg ( )

Argument (principal value)

Returns the prinicpal argument of the complex number, i.e. a number t with -pi < t <= pi, such that z = rexp(i*t) for some positive real r

Return values
floatargument
static MathParser\Extensions\Complex::arsinh (   $z)
static

complex inverse hyperbolic sine function

Complex::arsinh($z) computes and returns the principal branch of arsinh($z)

Parameters
mixed$z(Complex, or parsable to Complex)
Return values
Complex
static MathParser\Extensions\Complex::artanh (   $z)
static

complex inverse hyperbolic tangent function

Complex::artanh($z) computes and returns the principal branch of artanh($z)

Parameters
mixed$z(Complex, or parsable to Complex)
Return values
Complex
static MathParser\Extensions\Complex::cos (   $z)
static

complex cosine function

Complex::cos($z) computes and returns cos($z)

Parameters
mixed$z(Complex, or parsable to Complex)
Return values
Complex
static MathParser\Extensions\Complex::cosh (   $z)
static

complex hyperbolic cosine function

Complex::cosh($z) computes and returns cosh($z)

Parameters
mixed$z(Complex, or parsable to Complex)
Return values
Complex
static MathParser\Extensions\Complex::cot (   $z)
static

complex cotangent function

Complex::cot($z) computes and returns cot($z)

Parameters
mixed$z(Complex, or parsable to Complex)
Return values
Complex
static MathParser\Extensions\Complex::create (   $real,
  $imag 
)
static

create a complex number from its real and imaginary parts

Parameters
mixed$real(float, int, Rational)
mixed$imag(float, int, Rational)
Exceptions
SyntaxErrorExceptionif the string cannot be parsed
Return values
float
static MathParser\Extensions\Complex::div (   $z,
  $w 
)
static

divide two complex numbers

Complex::div($z, $w) computes and returns $z/$w

Parameters
mixed$z(Complex, or parsable to Complex)
mixed$w(Complex, or parsable to Complex)
Return values
Complex
static MathParser\Extensions\Complex::exp (   $z)
static

complex exponential function

Complex::exp($z) computes and returns exp($z)

Parameters
mixed$z(Complex, or parsable to Complex)
Return values
Complex
MathParser\Extensions\Complex::i ( )

Imaginary part.

Return values
floatimaginary part
MathParser\Extensions\Complex::is_nan ( )

test if the complex number is NAN

Return values
bool
static MathParser\Extensions\Complex::isSignedReal (   $value)
staticprivate

check whether a string represents a signed real number

Parameters
string$value
Return values
booltrue if $value is a signed real number
static MathParser\Extensions\Complex::log (   $z)
static

complex logarithm function

Complex::log($z) computes and returns the principal branch of log($z)

Parameters
mixed$z(Complex, or parsable to Complex)
Return values
Complex
static MathParser\Extensions\Complex::mul (   $z,
  $w 
)
static

multiply two complex numbers

Complex::mul($z, $w) computes and returns $z*$w

Parameters
mixed$z(Complex, or parsable to Complex)
mixed$w(Complex, or parsable to Complex)
Return values
Complex
static MathParser\Extensions\Complex::parse (   $value)
static

convert data to a complex number, if possible

Parameters
mixed$value(Complex, Rational, int, float and strings accepted)
Exceptions
SyntaxErrorExceptionif the string cannot be parsed
Return values
Complex
static MathParser\Extensions\Complex::parseReal (   $value)
staticprivate

convert string to floating point number, if possible

decimal commas accepted

Parameters
string$value
Exceptions
SyntaxErrorExceptionif the string cannot be parsed
Return values
float
static MathParser\Extensions\Complex::pow (   $z,
  $w 
)
static

powers of two complex numbers

Complex::pow($z, $w) computes and returns the principal value of $z^$w

Parameters
mixed$z(Complex, or parsable to Complex)
mixed$w(Complex, or parsable to Complex)
Return values
Complex
static MathParser\Extensions\Complex::powi (   $z,
  $n 
)
staticprivate

integer power of a complex number

Complex::powi($z, $n) computes and returns $z^$n where $n is an integer

Parameters
mixed$z(Complex, or parsable to Complex)
int$n
Return values
Complex
MathParser\Extensions\Complex::r ( )

Real part.

Return values
floatreal part
static MathParser\Extensions\Complex::sin (   $z)
static

complex sine function

Complex::sin($z) computes and returns sin($z)

Parameters
mixed$z(Complex, or parsable to Complex)
Return values
Complex
static MathParser\Extensions\Complex::sinh (   $z)
static

complex hyperbolic sine function

Complex::sinh($z) computes and returns sinh($z)

Parameters
mixed$z(Complex, or parsable to Complex)
Return values
Complex
static MathParser\Extensions\Complex::sqrt (   $z)
static

complex square root function

Complex::sqrt($z) computes and returns the principal branch of sqrt($z)

Parameters
mixed$z(Complex, or parsable to Complex)
Return values
Complex
static MathParser\Extensions\Complex::sub (   $z,
  $w 
)
static

subtract two complex numbers

Complex::sub($z, $w) computes and returns $z-$w

Parameters
mixed$z(Complex, or parsable to Complex)
mixed$w(Complex, or parsable to Complex)
Return values
Complex
static MathParser\Extensions\Complex::tan (   $z)
static

complex tangent function

Complex::tan($z) computes and returns tan($z)

Parameters
mixed$z(Complex, or parsable to Complex)
Return values
Complex
static MathParser\Extensions\Complex::tanh (   $z)
static

complex hyperbolic tangent function

Complex::tanh($z) computes and returns tanh($z)

Parameters
mixed$z(Complex, or parsable to Complex)
Return values
Complex
static MathParser\Extensions\Complex::toFloat (   $x)
staticprivate

convert data to a floating point number, if possible

Parameters
mixed$value(float, int, Rational)
Exceptions
SyntaxErrorExceptionif the string cannot be parsed
Return values
float

The documentation for this class was generated from the following file: