12 if (is_numeric($complexNumber))
13 return array( $complexNumber, 0, NULL );
16 if (strpos($complexNumber,
'+-') !== FALSE)
17 $complexNumber = str_replace(
'+-',
'-',$complexNumber);
18 if (strpos($complexNumber,
'++') !== FALSE)
19 $complexNumber = str_replace(
'++',
'+',$complexNumber);
20 if (strpos($complexNumber,
'--') !== FALSE)
21 $complexNumber = str_replace(
'--',
'-',$complexNumber);
24 $validComplex = preg_match(
'/^([\-\+]?(\d+\.?\d*|\d*\.?\d+)([Ee][\-\+]?[0-2]?\d{1,3})?)([\-\+]?(\d+\.?\d*|\d*\.?\d+)([Ee][\-\+]?[0-2]?\d{1,3})?)?(([\-\+]?)([ij]?))$/ui',$complexNumber,$complexParts);
28 $validComplex = preg_match(
'/^([\-\+]?)([ij])$/ui',$complexNumber,$complexParts);
30 throw new Exception(
'COMPLEX: Invalid complex number');
34 if ($complexParts[1] ===
'-') {
35 $imaginary = 0 - $imaginary;
37 return array(0, $imaginary, $complexParts[2]);
41 if (($complexParts[4] ===
'') && ($complexParts[9] !==
'')) {
42 if ($complexParts[7] !== $complexParts[9]) {
44 if ($complexParts[8] ===
'-') {
45 $complexParts[4] = -1;
49 $complexParts[4] = $complexParts[1];
55 return array( $complexParts[1],
57 !empty($complexParts[9]) ? $complexParts[9] :
'i' 77 $this->suffix = strtolower(
$suffix);
97 if ($this->imaginaryPart != 0.0) {
98 if (abs($this->imaginaryPart) != 1.0) {
101 $str .= (($this->imaginaryPart < 0.0) ?
'-' :
''). $this->suffix;
104 if ($this->realPart != 0.0) {
105 if (($str) && ($this->imaginaryPart > 0.0))
107 $str = $this->realPart . $str;
Create styles array
The data for the language used.
static _parseComplex($complexNumber)
__construct($realPart, $imaginaryPart=null, $suffix='i')