PluginProbe
wpDataTables – WordPress Data Table, Dynamic Tables & Table Charts Plugin / 6.5.1.7
wpDataTables – WordPress Data Table, Dynamic Tables & Table Charts Plugin v6.5.1.7
6.5.1.7 6.5.1.6 6.5.1.5 6.5.1.4 6.5.1.3 6.5.1.2 6.5.1.1 6.5.0.9 6.5.0.8 6.5.0.7 6.5.0.6 trunk 3.4.2.40 3.4.2.41 3.4.2.42 3.4.2.43 3.4.2.44 3.4.2.45 3.4.2.46 3.4.2.47 3.4.2.48 3.4.2.49 3.4.2.50 6.3.2 6.3.3.1 All 47 releases
wpdatatables / lib / phpoffice / phpspreadsheet / src / PhpSpreadsheet / Calculation / Engineering / ComplexOperations.php

ComplexOperations.php in wpDataTables – WordPress Data Table, Dynamic Tables & Table Charts Plugin 6.5.1.7, at lib/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Engineering/ComplexOperations.php

135 lines 4.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 }
135