Moodle PHP Documentation 5.1
Moodle 5.1dev (Build: 20250620) (7d9030acd6e)
Complex Class Reference

Complex Number object. More...

Public Member Functions

 __construct ($realPart=0.0, $imaginaryPart=null, $suffix='i')
 
 __call ($functionName, $arguments)
 Returns the result of the function call or operation.
 
 __toString ()
 
 format ()
 
 getImaginary ()
 Gets the imaginary part of this complex number.
 
 getReal ()
 Gets the real part of this complex number.
 
 getSuffix ()
 Gets the suffix of this complex number.
 
 invertImaginary ()
 
 invertReal ()
 
 isComplex ()
 Returns true if this is a complex value, false if a real value.
 
 isReal ()
 Returns true if this is a real value, false if a complex value.
 
 reverse ()
 Returns the reverse of this complex number.
 

Static Public Member Functions

static validateComplexArgument ($complex)
 Validates whether the argument is a valid complex number, converting scalar or array values if possible.
 

Public Attributes

const EULER = 2.7182818284590452353602874713526624977572
 @constant Euler's Number.
 
const NUMBER_SPLIT_REGEXP
 @constant Regexp to split an input string into real and imaginary components and suffix
 

Protected Attributes

float $imaginaryPart = 0.0
 $imaginaryPart The value of of this complex number on the imaginary plane.
 
float $realPart = 0.0
 $realPart The value of of this complex number on the real plane.
 
string $suffix
 $suffix The suffix for this complex number (i or j).
 

Static Protected Attributes

static $functions
 
static $operations
 

Detailed Description

Complex Number object.

@method float abs() @method Complex acos() @method Complex acosh() @method Complex acot() @method Complex acoth() @method Complex acsc() @method Complex acsch() @method float argument() @method Complex asec() @method Complex asech() @method Complex asin() @method Complex asinh() @method Complex atan() @method Complex atanh() @method Complex conjugate() @method Complex cos() @method Complex cosh() @method Complex cot() @method Complex coth() @method Complex csc() @method Complex csch() @method Complex exp() @method Complex inverse() @method Complex ln() @method Complex log2() @method Complex log10() @method Complex negative() @method Complex pow(int|float $power) @method float rho() @method Complex sec() @method Complex sech() @method Complex sin() @method Complex sinh() @method Complex sqrt() @method Complex tan() @method Complex tanh() @method float theta() @method Complex add(...$complexValues) @method Complex subtract(...$complexValues) @method Complex multiply(...$complexValues) @method Complex divideby(...$complexValues) @method Complex divideinto(...$complexValues)

Member Function Documentation

◆ __call()

Complex::__call ( $functionName,
$arguments )

Returns the result of the function call or operation.

Return values
Complex|float
Exceptions
Exception|InvalidArgumentException

◆ getImaginary()

Complex::getImaginary ( )

Gets the imaginary part of this complex number.

Return values
Float

◆ getReal()

Complex::getReal ( )

Gets the real part of this complex number.

Return values
Float

◆ getSuffix()

Complex::getSuffix ( )

Gets the suffix of this complex number.

Return values
String

◆ isComplex()

Complex::isComplex ( )

Returns true if this is a complex value, false if a real value.

Return values
Bool

◆ isReal()

Complex::isReal ( )

Returns true if this is a real value, false if a complex value.

Return values
Bool

◆ reverse()

Complex::reverse ( )

Returns the reverse of this complex number.

Return values
Complex

◆ validateComplexArgument()

static Complex::validateComplexArgument ( $complex)
static

Validates whether the argument is a valid complex number, converting scalar or array values if possible.

Parameters
mixed$complexThe value to validate
Return values
Complex
Exceptions
ExceptionIf the argument isn't a Complex number or cannot be converted to one

Member Data Documentation

◆ $operations

Complex::$operations
staticprotected
Initial value:
= [
'add',
'subtract',
'multiply',
'divideby',
'divideinto',
]

◆ NUMBER_SPLIT_REGEXP

const Complex::NUMBER_SPLIT_REGEXP
Initial value:
=
'` ^
( # Real part
[-+]?(\d+\.?\d*|d*::.?::d+) # Real value (integer or float)
([Ee][-+]?[0-2]?\d{1,3})? # Optional real exponent for scientific format
)
( # Imaginary part
[-+]?(\d+\.?\d*|d*::.?::d+) # Imaginary value (integer or float)
([Ee][-+]?[0-2]?\d{1,3})? # Optional imaginary exponent for scientific format
)?
( # Imaginary part is optional
([-+]?) # Imaginary (implicit 1 or -1) only
([ij]?) # Imaginary i or j - depending on whether mathematical or engineering
)
$`uix'

@constant Regexp to split an input string into real and imaginary components and suffix


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