See Release Notes
Long Term Support Release
Differences Between: [Versions 400 and 401]
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\ArrayEnabled; 8 use PhpOffice\PhpSpreadsheet\Calculation\Functions; 9 use PhpOffice\PhpSpreadsheet\Calculation\Information\ExcelError; 10 11 class ComplexOperations 12 { 13 use ArrayEnabled; 14 15 /** 16 * IMDIV. 17 * 18 * Returns the quotient of two complex numbers in x + yi or x + yj text format. 19 * 20 * Excel Function: 21 * IMDIV(complexDividend,complexDivisor) 22 * 23 * @param array|string $complexDividend the complex numerator or dividend 24 * Or can be an array of values 25 * @param array|string $complexDivisor the complex denominator or divisor 26 * Or can be an array of values 27 * 28 * @return array|string 29 * If an array of numbers is passed as an argument, then the returned result will also be an array 30 * with the same dimensions 31 */ 32 public static function IMDIV($complexDividend, $complexDivisor) 33 { 34 if (is_array($complexDividend) || is_array($complexDivisor)) { 35 return self::evaluateArrayArguments([self::class, __FUNCTION__], $complexDividend, $complexDivisor); 36 } 37 38 try { 39 return (string) (new ComplexObject($complexDividend))->divideby(new ComplexObject($complexDivisor)); 40 } catch (ComplexException $e) { 41 return ExcelError::NAN(); 42 } 43 } 44 45 /** 46 * IMSUB. 47 * 48 * Returns the difference of two complex numbers in x + yi or x + yj text format. 49 * 50 * Excel Function: 51 * IMSUB(complexNumber1,complexNumber2) 52 * 53 * @param array|string $complexNumber1 the complex number from which to subtract complexNumber2 54 * Or can be an array of values 55 * @param array|string $complexNumber2 the complex number to subtract from complexNumber1 56 * Or can be an array of values 57 * 58 * @return array|string 59 * If an array of numbers is passed as an argument, then the returned result will also be an array 60 * with the same dimensions 61 */ 62 public static function IMSUB($complexNumber1, $complexNumber2) 63 { 64 if (is_array($complexNumber1) || is_array($complexNumber2)) { 65 return self::evaluateArrayArguments([self::class, __FUNCTION__], $complexNumber1, $complexNumber2); 66 } 67 68 try { 69 return (string) (new ComplexObject($complexNumber1))->subtract(new ComplexObject($complexNumber2)); 70 } catch (ComplexException $e) { 71 return ExcelError::NAN(); 72 } 73 } 74 75 /** 76 * IMSUM. 77 * 78 * Returns the sum of two or more complex numbers in x + yi or x + yj text format. 79 * 80 * Excel Function: 81 * IMSUM(complexNumber[,complexNumber[,...]]) 82 * 83 * @param string ...$complexNumbers Series of complex numbers to add 84 * 85 * @return string 86 */ 87 public static function IMSUM(...$complexNumbers) 88 { 89 // Return value 90 $returnValue = new ComplexObject(0.0); 91 $aArgs = Functions::flattenArray($complexNumbers); 92 93 try { 94 // Loop through the arguments 95 foreach ($aArgs as $complex) { 96 $returnValue = $returnValue->add(new ComplexObject($complex)); 97 } 98 } catch (ComplexException $e) { 99 return ExcelError::NAN(); 100 } 101 102 return (string) $returnValue; 103 } 104 105 /** 106 * IMPRODUCT. 107 * 108 * Returns the product of two or more complex numbers in x + yi or x + yj text format. 109 * 110 * Excel Function: 111 * IMPRODUCT(complexNumber[,complexNumber[,...]]) 112 * 113 * @param string ...$complexNumbers Series of complex numbers to multiply 114 * 115 * @return string 116 */ 117 public static function IMPRODUCT(...$complexNumbers) 118 { 119 // Return value 120 $returnValue = new ComplexObject(1.0); 121 $aArgs = Functions::flattenArray($complexNumbers); 122 123 try { 124 // Loop through the arguments 125 foreach ($aArgs as $complex) { 126 $returnValue = $returnValue->multiply(new ComplexObject($complex)); 127 } 128 } catch (ComplexException $e) { 129 return ExcelError::NAN(); 130 } 131 132 return (string) $returnValue; 133 } 134 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body