ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
log2.php
Go to the documentation of this file.
1<?php
2
10namespace Complex;
11
20if (!function_exists(__NAMESPACE__ . '\\log2')) {
21 function log2($complex): Complex
22 {
23 $complex = Complex::validateComplexArgument($complex);
24
25 if (($complex->getReal() == 0.0) && ($complex->getImaginary() == 0.0)) {
26 throw new \InvalidArgumentException();
27 } elseif (($complex->getReal() > 0.0) && ($complex->getImaginary() == 0.0)) {
28 return new Complex(\log($complex->getReal(), 2), 0.0, $complex->getSuffix());
29 }
30
31 return ln($complex)
32 ->multiply(\log(Complex::EULER, 2));
33 }
34}
An exception for terminatinating execution or to throw for unit testing.