Differences Between: [Versions 400 and 401] [Versions 400 and 402] [Versions 400 and 403]
1 <?php 2 3 namespace PhpOffice\PhpSpreadsheet\Calculation\Engineering; 4 5 use Complex\Complex as ComplexObject; 6 use Complex\Exception as ComplexException; 7 use PhpOffice\PhpSpreadsheet\Calculation\Functions; 8 9 class ComplexOperations 10 { 11 /** 12 * IMDIV. 13 * 14 * Returns the quotient of two complex numbers in x + yi or x + yj text format. 15 * 16 * Excel Function: 17 * IMDIV(complexDividend,complexDivisor) 18 * 19 * @param string $complexDividend the complex numerator or dividend 20 * @param string $complexDivisor the complex denominator or divisor 21 * 22 * @return string 23 */ 24 public static function IMDIV($complexDividend, $complexDivisor) 25 { 26 $complexDividend = Functions::flattenSingleValue($complexDividend); 27 $complexDivisor = Functions::flattenSingleValue($complexDivisor); 28 29 try { 30 return (string) (new ComplexObject($complexDividend))->divideby(new ComplexObject($complexDivisor)); 31 } catch (ComplexException $e) { 32 return Functions::NAN(); 33 } 34 } 35 36 /** 37 * IMSUB. 38 * 39 * Returns the difference of two complex numbers in x + yi or x + yj text format. 40 * 41 * Excel Function: 42 * IMSUB(complexNumber1,complexNumber2) 43 * 44 * @param string $complexNumber1 the complex number from which to subtract complexNumber2 45 * @param string $complexNumber2 the complex number to subtract from complexNumber1 46 * 47 * @return string 48 */ 49 public static function IMSUB($complexNumber1, $complexNumber2) 50 { 51 $complexNumber1 = Functions::flattenSingleValue($complexNumber1); 52 $complexNumber2 = Functions::flattenSingleValue($complexNumber2); 53 54 try { 55 return (string) (new ComplexObject($complexNumber1))->subtract(new ComplexObject($complexNumber2)); 56 } catch (ComplexException $e) { 57 return Functions::NAN(); 58 } 59 } 60 61 /** 62 * IMSUM. 63 * 64 * Returns the sum of two or more complex numbers in x + yi or x + yj text format. 65 * 66 * Excel Function: 67 * IMSUM(complexNumber[,complexNumber[,...]]) 68 * 69 * @param string ...$complexNumbers Series of complex numbers to add 70 * 71 * @return string 72 */ 73 public static function IMSUM(...$complexNumbers) 74 { 75 // Return value 76 $returnValue = new ComplexObject(0.0); 77 $aArgs = Functions::flattenArray($complexNumbers); 78 79 try { 80 // Loop through the arguments 81 foreach ($aArgs as $complex) { 82 $returnValue = $returnValue->add(new ComplexObject($complex)); 83 } 84 } catch (ComplexException $e) { 85 return Functions::NAN(); 86 } 87 88 return (string) $returnValue; 89 } 90 91 /** 92 * IMPRODUCT. 93 * 94 * Returns the product of two or more complex numbers in x + yi or x + yj text format. 95 * 96 * Excel Function: 97 * IMPRODUCT(complexNumber[,complexNumber[,...]]) 98 * 99 * @param string ...$complexNumbers Series of complex numbers to multiply 100 * 101 * @return string 102 */ 103 public static function IMPRODUCT(...$complexNumbers) 104 { 105 // Return value 106 $returnValue = new ComplexObject(1.0); 107 $aArgs = Functions::flattenArray($complexNumbers); 108 109 try { 110 // Loop through the arguments 111 foreach ($aArgs as $complex) { 112 $returnValue = $returnValue->multiply(new ComplexObject($complex)); 113 } 114 } catch (ComplexException $e) { 115 return Functions::NAN(); 116 } 117 118 return (string) $returnValue; 119 } 120 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body