/** * Returns the exponentiation of a complex numbers to a real power: z = c1^(real) * * @param Math_Complex $c1 * @param float $real * @return Math_Complex A valid Math_Complex number on success * @throws InvalidArgumentException */ public static function powReal(Math_Complex $c1, $real) { if (!Math_ComplexOp::isComplex($c1)) { throw new InvalidArgumentException('First arguments must be Math_Complex object'); } elseif (!is_numeric($real)) { throw new InvalidArgumentException("An real number is needed as second parameter"); } else { $ar = $c1->getReal(); $ai = $c1->getIm(); if ($ar == 0 && $ai == 0) { $r = $i = 0.0; } else { $logr = log($c1->abs()); $theta = $c1->arg(); $rho = exp($logr * $real); $beta = $theta * $real; $r = $rho * cos($beta); $i = $rho * sin($beta); } return new Math_Complex($r, $i); } }
function testIsComplex() { /*{{{*/ $this->assertEquals(true, Math_ComplexOp::isComplex($this->cnum1)); }