public static function PHPExcel_Calculation_Engineering::IMPOWER in Loft Data Grids 7.2
Same name and namespace in other branches
- 6.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/Engineering.php \PHPExcel_Calculation_Engineering::IMPOWER()
* IMPOWER * * Returns a complex number in x + yi or x + yj text format raised to a power. * * Excel Function: * IMPOWER(complexNumber,realNumber) * *
Parameters
string $complexNumber The complex number you want to raise to a power.: * @param float $realNumber The power to which you want to raise the complex number. * @return string
File
- vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Calculation/ Engineering.php, line 2005
Class
- PHPExcel_Calculation_Engineering
- PHPExcel_Calculation_Engineering
Code
public static function IMPOWER($complexNumber, $realNumber) {
$complexNumber = PHPExcel_Calculation_Functions::flattenSingleValue($complexNumber);
$realNumber = PHPExcel_Calculation_Functions::flattenSingleValue($realNumber);
if (!is_numeric($realNumber)) {
return PHPExcel_Calculation_Functions::VALUE();
}
$parsedComplex = self::_parseComplex($complexNumber);
$r = sqrt($parsedComplex['real'] * $parsedComplex['real'] + $parsedComplex['imaginary'] * $parsedComplex['imaginary']);
$rPower = pow($r, $realNumber);
$theta = self::IMARGUMENT($complexNumber) * $realNumber;
if ($theta == 0) {
return 1;
}
elseif ($parsedComplex['imaginary'] == 0.0) {
return self::COMPLEX($rPower * cos($theta), $rPower * sin($theta), $parsedComplex['suffix']);
}
else {
return self::COMPLEX($rPower * cos($theta), $rPower * sin($theta), $parsedComplex['suffix']);
}
}