ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
PHPExcel_Calculation_MathTrig Class Reference
+ Collaboration diagram for PHPExcel_Calculation_MathTrig:

Static Public Member Functions

static ATAN2 ($xCoordinate=NULL, $yCoordinate=NULL)
 
static CEILING ($number, $significance=NULL)
 
static COMBIN ($numObjs, $numInSet)
 
static EVEN ($number)
 
static FACT ($factVal)
 
static FACTDOUBLE ($factVal)
 
static FLOOR ($number, $significance=NULL)
 
static GCD ()
 
static INT ($number)
 
static LCM ()
 
static LOG_BASE ($number=NULL, $base=10)
 
static MDETERM ($matrixValues)
 
static MINVERSE ($matrixValues)
 
static MMULT ($matrixData1, $matrixData2)
 MMULT. More...
 
static MOD ($a=1, $b=1)
 MOD. More...
 
static MROUND ($number, $multiple)
 MROUND. More...
 
static MULTINOMIAL ()
 MULTINOMIAL. More...
 
static ODD ($number)
 ODD. More...
 
static POWER ($x=0, $y=2)
 POWER. More...
 
static PRODUCT ()
 
static QUOTIENT ()
 
static RAND ($min=0, $max=0)
 RAND. More...
 
static ROMAN ($aValue, $style=0)
 
static ROUNDUP ($number, $digits)
 ROUNDUP. More...
 
static ROUNDDOWN ($number, $digits)
 ROUNDDOWN. More...
 
static SERIESSUM ()
 SERIESSUM. More...
 
static SIGN ($number)
 SIGN. More...
 
static SQRTPI ($number)
 SQRTPI. More...
 
static SUBTOTAL ()
 SUBTOTAL. More...
 
static SUM ()
 
static SUMIF ($aArgs, $condition, $sumArgs=array())
 
static SUMPRODUCT ()
 
static SUMSQ ()
 
static SUMX2MY2 ($matrixData1, $matrixData2)
 SUMX2MY2. More...
 
static SUMX2PY2 ($matrixData1, $matrixData2)
 SUMX2PY2. More...
 
static SUMXMY2 ($matrixData1, $matrixData2)
 SUMXMY2. More...
 
static TRUNC ($value=0, $digits=0)
 TRUNC. More...
 

Static Private Member Functions

static _factors ($value)
 
static _romanCut ($num, $n)
 

Detailed Description

Definition at line 46 of file MathTrig.php.

Member Function Documentation

◆ _factors()

static PHPExcel_Calculation_MathTrig::_factors (   $value)
staticprivate

Definition at line 51 of file MathTrig.php.

51 {
52 $startVal = floor(sqrt($value));
53
54 $factorArray = array();
55 for ($i = $startVal; $i > 1; --$i) {
56 if (($value % $i) == 0) {
57 $factorArray = array_merge($factorArray,self::_factors($value / $i));
58 $factorArray = array_merge($factorArray,self::_factors($i));
59 if ($i <= sqrt($value)) {
60 break;
61 }
62 }
63 }
64 if (!empty($factorArray)) {
65 rsort($factorArray);
66 return $factorArray;
67 } else {
68 return array((integer) $value);
69 }
70 } // function _factors()

Referenced by GCD(), and LCM().

+ Here is the caller graph for this function:

◆ _romanCut()

static PHPExcel_Calculation_MathTrig::_romanCut (   $num,
  $n 
)
staticprivate

Definition at line 73 of file MathTrig.php.

73 {
74 return ($num - ($num % $n ) ) / $n;
75 } // function _romanCut()
$n
Definition: RandomTest.php:80

References $n.

Referenced by ROMAN().

+ Here is the caller graph for this function:

◆ ATAN2()

static PHPExcel_Calculation_MathTrig::ATAN2 (   $xCoordinate = NULL,
  $yCoordinate = NULL 
)
static

Definition at line 100 of file MathTrig.php.

100 {
101 $xCoordinate = PHPExcel_Calculation_Functions::flattenSingleValue($xCoordinate);
102 $yCoordinate = PHPExcel_Calculation_Functions::flattenSingleValue($yCoordinate);
103
104 $xCoordinate = ($xCoordinate !== NULL) ? $xCoordinate : 0.0;
105 $yCoordinate = ($yCoordinate !== NULL) ? $yCoordinate : 0.0;
106
107 if (((is_numeric($xCoordinate)) || (is_bool($xCoordinate))) &&
108 ((is_numeric($yCoordinate))) || (is_bool($yCoordinate))) {
109 $xCoordinate = (float) $xCoordinate;
110 $yCoordinate = (float) $yCoordinate;
111
112 if (($xCoordinate == 0) && ($yCoordinate == 0)) {
114 }
115
116 return atan2($yCoordinate, $xCoordinate);
117 }
119 } // function ATAN2()
static flattenSingleValue($value='')
Convert an array to a single scalar value by extracting the first element.
Definition: Functions.php:662

References PHPExcel_Calculation_Functions\DIV0(), PHPExcel_Calculation_Functions\flattenSingleValue(), and PHPExcel_Calculation_Functions\VALUE().

+ Here is the call graph for this function:

◆ CEILING()

static PHPExcel_Calculation_MathTrig::CEILING (   $number,
  $significance = NULL 
)
static

Definition at line 139 of file MathTrig.php.

139 {
141 $significance = PHPExcel_Calculation_Functions::flattenSingleValue($significance);
142
143 if ((is_null($significance)) &&
145 $significance = $number/abs($number);
146 }
147
148 if ((is_numeric($number)) && (is_numeric($significance))) {
149 if (($number == 0.0 ) || ($significance == 0.0)) {
150 return 0.0;
151 } elseif (self::SIGN($number) == self::SIGN($significance)) {
152 return ceil($number / $significance) * $significance;
153 } else {
155 }
156 }
158 } // function CEILING()

References PHPExcel_Calculation_Functions\COMPATIBILITY_GNUMERIC, PHPExcel_Calculation_Functions\flattenSingleValue(), PHPExcel_Calculation_Functions\getCompatibilityMode(), PHPExcel_Calculation_Functions\NaN(), and PHPExcel_Calculation_Functions\VALUE().

Referenced by EVEN(), and ODD().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ COMBIN()

static PHPExcel_Calculation_MathTrig::COMBIN (   $numObjs,
  $numInSet 
)
static

Definition at line 176 of file MathTrig.php.

176 {
179
180 if ((is_numeric($numObjs)) && (is_numeric($numInSet))) {
181 if ($numObjs < $numInSet) {
183 } elseif ($numInSet < 0) {
185 }
186 return round(self::FACT($numObjs) / self::FACT($numObjs - $numInSet)) / self::FACT($numInSet);
187 }
189 } // function COMBIN()

References FACT(), PHPExcel_Calculation_Functions\flattenSingleValue(), PHPExcel_Calculation_Functions\NaN(), and PHPExcel_Calculation_Functions\VALUE().

Referenced by PHPExcel_Calculation_Statistical\BINOMDIST(), PHPExcel_Calculation_Statistical\HYPGEOMDIST(), and PHPExcel_Calculation_Statistical\NEGBINOMDIST().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ EVEN()

static PHPExcel_Calculation_MathTrig::EVEN (   $number)
static

Definition at line 209 of file MathTrig.php.

209 {
211
212 if (is_null($number)) {
213 return 0;
214 } elseif (is_bool($number)) {
215 $number = (int) $number;
216 }
217
218 if (is_numeric($number)) {
219 $significance = 2 * self::SIGN($number);
220 return (int) self::CEILING($number,$significance);
221 }
223 } // function EVEN()
static CEILING($number, $significance=NULL)
Definition: MathTrig.php:139
static SIGN($number)
SIGN.
Definition: MathTrig.php:1021

References CEILING(), PHPExcel_Calculation_Functions\flattenSingleValue(), SIGN(), and PHPExcel_Calculation_Functions\VALUE().

+ Here is the call graph for this function:

◆ FACT()

static PHPExcel_Calculation_MathTrig::FACT (   $factVal)
static

Definition at line 240 of file MathTrig.php.

240 {
242
243 if (is_numeric($factVal)) {
244 if ($factVal < 0) {
246 }
247 $factLoop = floor($factVal);
249 if ($factVal > $factLoop) {
251 }
252 }
253
254 $factorial = 1;
255 while ($factLoop > 1) {
256 $factorial *= $factLoop--;
257 }
258 return $factorial ;
259 }
261 } // function FACT()

References PHPExcel_Calculation_Functions\COMPATIBILITY_GNUMERIC, PHPExcel_Calculation_Functions\flattenSingleValue(), PHPExcel_Calculation_Functions\getCompatibilityMode(), PHPExcel_Calculation_Functions\NaN(), and PHPExcel_Calculation_Functions\VALUE().

Referenced by PHPExcel_Calculation_Engineering\BESSELI(), PHPExcel_Calculation_Engineering\BESSELJ(), COMBIN(), MULTINOMIAL(), PHPExcel_Calculation_Statistical\PERMUT(), and PHPExcel_Calculation_Statistical\POISSON().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FACTDOUBLE()

static PHPExcel_Calculation_MathTrig::FACTDOUBLE (   $factVal)
static

Definition at line 277 of file MathTrig.php.

277 {
279
280 if (is_numeric($factLoop)) {
281 $factLoop = floor($factLoop);
282 if ($factVal < 0) {
284 }
285 $factorial = 1;
286 while ($factLoop > 1) {
287 $factorial *= $factLoop--;
288 --$factLoop;
289 }
290 return $factorial ;
291 }
293 } // function FACTDOUBLE()

References PHPExcel_Calculation_Functions\flattenSingleValue(), PHPExcel_Calculation_Functions\NaN(), and PHPExcel_Calculation_Functions\VALUE().

+ Here is the call graph for this function:

◆ FLOOR()

static PHPExcel_Calculation_MathTrig::FLOOR (   $number,
  $significance = NULL 
)
static

Definition at line 310 of file MathTrig.php.

310 {
312 $significance = PHPExcel_Calculation_Functions::flattenSingleValue($significance);
313
315 $significance = $number/abs($number);
316 }
317
318 if ((is_numeric($number)) && (is_numeric($significance))) {
319 if ($significance == 0.0) {
321 } elseif ($number == 0.0) {
322 return 0.0;
323 } elseif (self::SIGN($number) == self::SIGN($significance)) {
324 return floor($number / $significance) * $significance;
325 } else {
327 }
328 } else
329
331 } // function FLOOR()

References PHPExcel_Calculation_Functions\COMPATIBILITY_GNUMERIC, PHPExcel_Calculation_Functions\DIV0(), PHPExcel_Calculation_Functions\flattenSingleValue(), PHPExcel_Calculation_Functions\getCompatibilityMode(), PHPExcel_Calculation_Functions\NaN(), and PHPExcel_Calculation_Functions\VALUE().

+ Here is the call graph for this function:

◆ GCD()

static PHPExcel_Calculation_MathTrig::GCD ( )
static

Definition at line 349 of file MathTrig.php.

349 {
350 $returnValue = 1;
351 $allValuesFactors = array();
352 // Loop through arguments
353 foreach(PHPExcel_Calculation_Functions::flattenArray(func_get_args()) as $value) {
354 if (!is_numeric($value)) {
356 } elseif ($value == 0) {
357 continue;
358 } elseif($value < 0) {
360 }
361 $myFactors = self::_factors($value);
362 $myCountedFactors = array_count_values($myFactors);
363 $allValuesFactors[] = $myCountedFactors;
364 }
365 $allValuesCount = count($allValuesFactors);
366 if ($allValuesCount == 0) {
367 return 0;
368 }
369
370 $mergedArray = $allValuesFactors[0];
371 for ($i=1;$i < $allValuesCount; ++$i) {
372 $mergedArray = array_intersect_key($mergedArray,$allValuesFactors[$i]);
373 }
374 $mergedArrayValues = count($mergedArray);
375 if ($mergedArrayValues == 0) {
376 return $returnValue;
377 } elseif ($mergedArrayValues > 1) {
378 foreach($mergedArray as $mergedKey => $mergedValue) {
379 foreach($allValuesFactors as $highestPowerTest) {
380 foreach($highestPowerTest as $testKey => $testValue) {
381 if (($testKey == $mergedKey) && ($testValue < $mergedValue)) {
382 $mergedArray[$mergedKey] = $testValue;
383 $mergedValue = $testValue;
384 }
385 }
386 }
387 }
388
389 $returnValue = 1;
390 foreach($mergedArray as $key => $value) {
391 $returnValue *= pow($key,$value);
392 }
393 return $returnValue;
394 } else {
395 $keys = array_keys($mergedArray);
396 $key = $keys[0];
397 $value = $mergedArray[$key];
398 foreach($allValuesFactors as $testValue) {
399 foreach($testValue as $mergedKey => $mergedValue) {
400 if (($mergedKey == $key) && ($mergedValue < $value)) {
401 $value = $mergedValue;
402 }
403 }
404 }
405 return pow($key,$value);
406 }
407 } // function GCD()
static flattenArray($array)
Convert a multi-dimensional array to a simple 1-dimensional array.
Definition: Functions.php:598

References _factors(), PHPExcel_Calculation_Functions\flattenArray(), PHPExcel_Calculation_Functions\NaN(), and PHPExcel_Calculation_Functions\VALUE().

Referenced by PHPExcel_Style_NumberFormat\_formatAsFraction().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ INT()

static PHPExcel_Calculation_MathTrig::INT (   $number)
static

Definition at line 423 of file MathTrig.php.

423 {
425
426 if (is_null($number)) {
427 return 0;
428 } elseif (is_bool($number)) {
429 return (int) $number;
430 }
431 if (is_numeric($number)) {
432 return (int) floor($number);
433 }
435 } // function INT()

References PHPExcel_Calculation_Functions\flattenSingleValue(), and PHPExcel_Calculation_Functions\VALUE().

+ Here is the call graph for this function:

◆ LCM()

static PHPExcel_Calculation_MathTrig::LCM ( )
static

Definition at line 454 of file MathTrig.php.

454 {
455 $returnValue = 1;
456 $allPoweredFactors = array();
457 // Loop through arguments
458 foreach(PHPExcel_Calculation_Functions::flattenArray(func_get_args()) as $value) {
459 if (!is_numeric($value)) {
461 }
462 if ($value == 0) {
463 return 0;
464 } elseif ($value < 0) {
466 }
467 $myFactors = self::_factors(floor($value));
468 $myCountedFactors = array_count_values($myFactors);
469 $myPoweredFactors = array();
470 foreach($myCountedFactors as $myCountedFactor => $myCountedPower) {
471 $myPoweredFactors[$myCountedFactor] = pow($myCountedFactor,$myCountedPower);
472 }
473 foreach($myPoweredFactors as $myPoweredValue => $myPoweredFactor) {
474 if (array_key_exists($myPoweredValue,$allPoweredFactors)) {
475 if ($allPoweredFactors[$myPoweredValue] < $myPoweredFactor) {
476 $allPoweredFactors[$myPoweredValue] = $myPoweredFactor;
477 }
478 } else {
479 $allPoweredFactors[$myPoweredValue] = $myPoweredFactor;
480 }
481 }
482 }
483 foreach($allPoweredFactors as $allPoweredFactor) {
484 $returnValue *= (integer) $allPoweredFactor;
485 }
486 return $returnValue;
487 } // function LCM()

References _factors(), PHPExcel_Calculation_Functions\flattenArray(), PHPExcel_Calculation_Functions\NaN(), and PHPExcel_Calculation_Functions\VALUE().

+ Here is the call graph for this function:

◆ LOG_BASE()

static PHPExcel_Calculation_MathTrig::LOG_BASE (   $number = NULL,
  $base = 10 
)
static

Definition at line 504 of file MathTrig.php.

504 {
506 $base = (is_null($base)) ? 10 : (float) PHPExcel_Calculation_Functions::flattenSingleValue($base);
507
508 if ((!is_numeric($base)) || (!is_numeric($number)))
510 if (($base <= 0) || ($number <= 0))
512 return log($number, $base);
513 } // function LOG_BASE()

References PHPExcel_Calculation_Functions\flattenSingleValue(), PHPExcel_Calculation_Functions\NaN(), and PHPExcel_Calculation_Functions\VALUE().

+ Here is the call graph for this function:

◆ MDETERM()

static PHPExcel_Calculation_MathTrig::MDETERM (   $matrixValues)
static

Definition at line 529 of file MathTrig.php.

529 {
530 $matrixData = array();
531 if (!is_array($matrixValues)) { $matrixValues = array(array($matrixValues)); }
532
533 $row = $maxColumn = 0;
534 foreach($matrixValues as $matrixRow) {
535 if (!is_array($matrixRow)) { $matrixRow = array($matrixRow); }
536 $column = 0;
537 foreach($matrixRow as $matrixCell) {
538 if ((is_string($matrixCell)) || ($matrixCell === null)) {
540 }
541 $matrixData[$column][$row] = $matrixCell;
542 ++$column;
543 }
544 if ($column > $maxColumn) { $maxColumn = $column; }
545 ++$row;
546 }
547 if ($row != $maxColumn) { return PHPExcel_Calculation_Functions::VALUE(); }
548
549 try {
550 $matrix = new PHPExcel_Shared_JAMA_Matrix($matrixData);
551 return $matrix->det();
552 } catch (PHPExcel_Exception $ex) {
554 }
555 } // function MDETERM()
$column
Definition: 39dropdown.php:62
PHPExcel root directory.
Definition: Matrix.php:27

References $column, $row, and PHPExcel_Calculation_Functions\VALUE().

+ Here is the call graph for this function:

◆ MINVERSE()

static PHPExcel_Calculation_MathTrig::MINVERSE (   $matrixValues)
static

Definition at line 571 of file MathTrig.php.

571 {
572 $matrixData = array();
573 if (!is_array($matrixValues)) { $matrixValues = array(array($matrixValues)); }
574
575 $row = $maxColumn = 0;
576 foreach($matrixValues as $matrixRow) {
577 if (!is_array($matrixRow)) { $matrixRow = array($matrixRow); }
578 $column = 0;
579 foreach($matrixRow as $matrixCell) {
580 if ((is_string($matrixCell)) || ($matrixCell === null)) {
582 }
583 $matrixData[$column][$row] = $matrixCell;
584 ++$column;
585 }
586 if ($column > $maxColumn) { $maxColumn = $column; }
587 ++$row;
588 }
589 if ($row != $maxColumn) { return PHPExcel_Calculation_Functions::VALUE(); }
590
591 try {
592 $matrix = new PHPExcel_Shared_JAMA_Matrix($matrixData);
593 return $matrix->inverse()->getArray();
594 } catch (PHPExcel_Exception $ex) {
596 }
597 } // function MINVERSE()

References $column, $row, and PHPExcel_Calculation_Functions\VALUE().

+ Here is the call graph for this function:

◆ MMULT()

static PHPExcel_Calculation_MathTrig::MMULT (   $matrixData1,
  $matrixData2 
)
static

MMULT.

Parameters
array$matrixData1A matrix of values
array$matrixData2A matrix of values
Returns
array

Definition at line 607 of file MathTrig.php.

607 {
608 $matrixAData = $matrixBData = array();
609 if (!is_array($matrixData1)) { $matrixData1 = array(array($matrixData1)); }
610 if (!is_array($matrixData2)) { $matrixData2 = array(array($matrixData2)); }
611
612 try {
613 $rowA = 0;
614 foreach($matrixData1 as $matrixRow) {
615 if (!is_array($matrixRow)) { $matrixRow = array($matrixRow); }
616 $columnA = 0;
617 foreach($matrixRow as $matrixCell) {
618 if ((!is_numeric($matrixCell)) || ($matrixCell === null)) {
620 }
621 $matrixAData[$rowA][$columnA] = $matrixCell;
622 ++$columnA;
623 }
624 ++$rowA;
625 }
626 $matrixA = new PHPExcel_Shared_JAMA_Matrix($matrixAData);
627 $rowB = 0;
628 foreach($matrixData2 as $matrixRow) {
629 if (!is_array($matrixRow)) { $matrixRow = array($matrixRow); }
630 $columnB = 0;
631 foreach($matrixRow as $matrixCell) {
632 if ((!is_numeric($matrixCell)) || ($matrixCell === null)) {
634 }
635 $matrixBData[$rowB][$columnB] = $matrixCell;
636 ++$columnB;
637 }
638 ++$rowB;
639 }
640 $matrixB = new PHPExcel_Shared_JAMA_Matrix($matrixBData);
641
642 if ($columnA != $rowB) {
644 }
645
646 return $matrixA->times($matrixB)->getArray();
647 } catch (PHPExcel_Exception $ex) {
648 var_dump($ex->getMessage());
650 }
651 } // function MMULT()

References PHPExcel_Calculation_Functions\VALUE().

+ Here is the call graph for this function:

◆ MOD()

static PHPExcel_Calculation_MathTrig::MOD (   $a = 1,
  $b = 1 
)
static

MOD.

Parameters
int$aDividend
int$bDivisor
Returns
int Remainder

Definition at line 661 of file MathTrig.php.

661 {
664
665 if ($b == 0.0) {
667 } elseif (($a < 0.0) && ($b > 0.0)) {
668 return $b - fmod(abs($a),$b);
669 } elseif (($a > 0.0) && ($b < 0.0)) {
670 return $b + fmod($a,abs($b));
671 }
672
673 return fmod($a,$b);
674 } // function MOD()

References PHPExcel_Calculation_Functions\DIV0(), and PHPExcel_Calculation_Functions\flattenSingleValue().

+ Here is the call graph for this function:

◆ MROUND()

static PHPExcel_Calculation_MathTrig::MROUND (   $number,
  $multiple 
)
static

MROUND.

Rounds a number to the nearest multiple of a specified value

Parameters
float$numberNumber to round
int$multipleMultiple to which you want to round $number
Returns
float Rounded Number

Definition at line 686 of file MathTrig.php.

686 {
689
690 if ((is_numeric($number)) && (is_numeric($multiple))) {
691 if ($multiple == 0) {
692 return 0;
693 }
694 if ((self::SIGN($number)) == (self::SIGN($multiple))) {
695 $multiplier = 1 / $multiple;
696 return round($number * $multiplier) / $multiplier;
697 }
699 }
701 } // function MROUND()

References PHPExcel_Calculation_Functions\flattenSingleValue(), PHPExcel_Calculation_Functions\NaN(), and PHPExcel_Calculation_Functions\VALUE().

Referenced by PHPExcel_Calculation_TextData\DOLLAR().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MULTINOMIAL()

static PHPExcel_Calculation_MathTrig::MULTINOMIAL ( )
static

MULTINOMIAL.

Returns the ratio of the factorial of a sum of values to the product of factorials.

Parameters
arrayof mixed Data Series
Returns
float

Definition at line 712 of file MathTrig.php.

712 {
713 $summer = 0;
714 $divisor = 1;
715 // Loop through arguments
716 foreach (PHPExcel_Calculation_Functions::flattenArray(func_get_args()) as $arg) {
717 // Is it a numeric value?
718 if (is_numeric($arg)) {
719 if ($arg < 1) {
721 }
722 $summer += floor($arg);
723 $divisor *= self::FACT($arg);
724 } else {
726 }
727 }
728
729 // Return
730 if ($summer > 0) {
731 $summer = self::FACT($summer);
732 return $summer / $divisor;
733 }
734 return 0;
735 } // function MULTINOMIAL()

References FACT(), PHPExcel_Calculation_Functions\flattenArray(), PHPExcel_Calculation_Functions\NaN(), and PHPExcel_Calculation_Functions\VALUE().

+ Here is the call graph for this function:

◆ ODD()

static PHPExcel_Calculation_MathTrig::ODD (   $number)
static

ODD.

Returns number rounded up to the nearest odd integer.

Parameters
float$numberNumber to round
Returns
int Rounded Number

Definition at line 746 of file MathTrig.php.

746 {
748
749 if (is_null($number)) {
750 return 1;
751 } elseif (is_bool($number)) {
752 $number = (int) $number;
753 }
754
755 if (is_numeric($number)) {
756 $significance = self::SIGN($number);
757 if ($significance == 0) {
758 return 1;
759 }
760
761 $result = self::CEILING($number,$significance);
762 if ($result == self::EVEN($result)) {
763 $result += $significance;
764 }
765
766 return (int) $result;
767 }
769 } // function ODD()
$result

References $result, CEILING(), PHPExcel_Calculation_Functions\flattenSingleValue(), SIGN(), and PHPExcel_Calculation_Functions\VALUE().

+ Here is the call graph for this function:

◆ POWER()

static PHPExcel_Calculation_MathTrig::POWER (   $x = 0,
  $y = 2 
)
static

POWER.

Computes x raised to the power y.

Parameters
float$x
float$y
Returns
float

Definition at line 781 of file MathTrig.php.

781 {
784
785 // Validate parameters
786 if ($x == 0.0 && $y == 0.0) {
788 } elseif ($x == 0.0 && $y < 0.0) {
790 }
791
792 // Return
793 $result = pow($x, $y);
794 return (!is_nan($result) && !is_infinite($result)) ? $result : PHPExcel_Calculation_Functions::NaN();
795 } // function POWER()
$y
Definition: example_007.php:83
$x
Definition: example_009.php:98

References $result, $x, $y, PHPExcel_Calculation_Functions\DIV0(), PHPExcel_Calculation_Functions\flattenSingleValue(), and PHPExcel_Calculation_Functions\NaN().

+ Here is the call graph for this function:

◆ PRODUCT()

static PHPExcel_Calculation_MathTrig::PRODUCT ( )
static

Definition at line 811 of file MathTrig.php.

811 {
812 // Return value
813 $returnValue = null;
814
815 // Loop through arguments
816 foreach (PHPExcel_Calculation_Functions::flattenArray(func_get_args()) as $arg) {
817 // Is it a numeric value?
818 if ((is_numeric($arg)) && (!is_string($arg))) {
819 if (is_null($returnValue)) {
820 $returnValue = $arg;
821 } else {
822 $returnValue *= $arg;
823 }
824 }
825 }
826
827 // Return
828 if (is_null($returnValue)) {
829 return 0;
830 }
831 return $returnValue;
832 } // function PRODUCT()

References PHPExcel_Calculation_Functions\flattenArray().

Referenced by PHPExcel_Calculation_Database\DPRODUCT(), PHPExcel_Calculation_Statistical\GEOMEAN(), and SUBTOTAL().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ QUOTIENT()

static PHPExcel_Calculation_MathTrig::QUOTIENT ( )
static

Definition at line 849 of file MathTrig.php.

849 {
850 // Return value
851 $returnValue = null;
852
853 // Loop through arguments
854 foreach (PHPExcel_Calculation_Functions::flattenArray(func_get_args()) as $arg) {
855 // Is it a numeric value?
856 if ((is_numeric($arg)) && (!is_string($arg))) {
857 if (is_null($returnValue)) {
858 $returnValue = ($arg == 0) ? 0 : $arg;
859 } else {
860 if (($returnValue == 0) || ($arg == 0)) {
861 $returnValue = 0;
862 } else {
863 $returnValue /= $arg;
864 }
865 }
866 }
867 }
868
869 // Return
870 return intval($returnValue);
871 } // function QUOTIENT()

References PHPExcel_Calculation_Functions\flattenArray().

+ Here is the call graph for this function:

◆ RAND()

static PHPExcel_Calculation_MathTrig::RAND (   $min = 0,
  $max = 0 
)
static

RAND.

Parameters
int$minMinimal value
int$maxMaximal value
Returns
int Random number

Definition at line 881 of file MathTrig.php.

881 {
884
885 if ($min == 0 && $max == 0) {
886 return (mt_rand(0,10000000)) / 10000000;
887 } else {
888 return mt_rand($min, $max);
889 }
890 } // function RAND()

References PHPExcel_Calculation_Functions\flattenSingleValue().

+ Here is the call graph for this function:

◆ ROMAN()

static PHPExcel_Calculation_MathTrig::ROMAN (   $aValue,
  $style = 0 
)
static

Definition at line 893 of file MathTrig.php.

893 {
896 if ((!is_numeric($aValue)) || ($aValue < 0) || ($aValue >= 4000)) {
898 }
899 $aValue = (integer) $aValue;
900 if ($aValue == 0) {
901 return '';
902 }
903
904 $mill = Array('', 'M', 'MM', 'MMM', 'MMMM', 'MMMMM');
905 $cent = Array('', 'C', 'CC', 'CCC', 'CD', 'D', 'DC', 'DCC', 'DCCC', 'CM');
906 $tens = Array('', 'X', 'XX', 'XXX', 'XL', 'L', 'LX', 'LXX', 'LXXX', 'XC');
907 $ones = Array('', 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX');
908
909 $roman = '';
910 while ($aValue > 5999) {
911 $roman .= 'M';
912 $aValue -= 1000;
913 }
914 $m = self::_romanCut($aValue, 1000); $aValue %= 1000;
915 $c = self::_romanCut($aValue, 100); $aValue %= 100;
916 $t = self::_romanCut($aValue, 10); $aValue %= 10;
917
918 return $roman.$mill[$m].$cent[$c].$tens[$t].$ones[$aValue];
919 } // function ROMAN()
static _romanCut($num, $n)
Definition: MathTrig.php:73
$style
Definition: example_012.php:70

References $style, $t, _romanCut(), PHPExcel_Calculation_Functions\flattenSingleValue(), and PHPExcel_Calculation_Functions\VALUE().

+ Here is the call graph for this function:

◆ ROUNDDOWN()

static PHPExcel_Calculation_MathTrig::ROUNDDOWN (   $number,
  $digits 
)
static

ROUNDDOWN.

Rounds a number down to a specified number of decimal places

Parameters
float$numberNumber to round
int$digitsNumber of digits to which you want to round $number
Returns
float Rounded Number

Definition at line 956 of file MathTrig.php.

956 {
959
960 if ((is_numeric($number)) && (is_numeric($digits))) {
961 $significance = pow(10,(int) $digits);
962 if ($number < 0.0) {
963 return ceil($number * $significance) / $significance;
964 } else {
965 return floor($number * $significance) / $significance;
966 }
967 }
969 } // function ROUNDDOWN()

References PHPExcel_Calculation_Functions\flattenSingleValue(), and PHPExcel_Calculation_Functions\VALUE().

+ Here is the call graph for this function:

◆ ROUNDUP()

static PHPExcel_Calculation_MathTrig::ROUNDUP (   $number,
  $digits 
)
static

ROUNDUP.

Rounds a number up to a specified number of decimal places

Parameters
float$numberNumber to round
int$digitsNumber of digits to which you want to round $number
Returns
float Rounded Number

Definition at line 931 of file MathTrig.php.

931 {
934
935 if ((is_numeric($number)) && (is_numeric($digits))) {
936 $significance = pow(10,(int) $digits);
937 if ($number < 0.0) {
938 return floor($number * $significance) / $significance;
939 } else {
940 return ceil($number * $significance) / $significance;
941 }
942 }
944 } // function ROUNDUP()

References PHPExcel_Calculation_Functions\flattenSingleValue(), and PHPExcel_Calculation_Functions\VALUE().

+ Here is the call graph for this function:

◆ SERIESSUM()

static PHPExcel_Calculation_MathTrig::SERIESSUM ( )
static

SERIESSUM.

Returns the sum of a power series

Parameters
float$xInput value to the power series
float$nInitial power to which you want to raise $x
float$mStep by which to increase $n for each term in the series
arrayof mixed Data Series
Returns
float

Definition at line 983 of file MathTrig.php.

983 {
984 // Return value
985 $returnValue = 0;
986
987 // Loop through arguments
988 $aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
989
990 $x = array_shift($aArgs);
991 $n = array_shift($aArgs);
992 $m = array_shift($aArgs);
993
994 if ((is_numeric($x)) && (is_numeric($n)) && (is_numeric($m))) {
995 // Calculate
996 $i = 0;
997 foreach($aArgs as $arg) {
998 // Is it a numeric value?
999 if ((is_numeric($arg)) && (!is_string($arg))) {
1000 $returnValue += $arg * pow($x,$n + ($m * $i++));
1001 } else {
1003 }
1004 }
1005 // Return
1006 return $returnValue;
1007 }
1009 } // function SERIESSUM()

References $n, $x, PHPExcel_Calculation_Functions\flattenArray(), and PHPExcel_Calculation_Functions\VALUE().

+ Here is the call graph for this function:

◆ SIGN()

static PHPExcel_Calculation_MathTrig::SIGN (   $number)
static

SIGN.

Determines the sign of a number. Returns 1 if the number is positive, zero (0) if the number is 0, and -1 if the number is negative.

Parameters
float$numberNumber to round
Returns
int sign value

Definition at line 1021 of file MathTrig.php.

1021 {
1023
1024 if (is_bool($number))
1025 return (int) $number;
1026 if (is_numeric($number)) {
1027 if ($number == 0.0) {
1028 return 0;
1029 }
1030 return $number / abs($number);
1031 }
1033 } // function SIGN()

References PHPExcel_Calculation_Functions\flattenSingleValue(), and PHPExcel_Calculation_Functions\VALUE().

Referenced by EVEN(), and ODD().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SQRTPI()

static PHPExcel_Calculation_MathTrig::SQRTPI (   $number)
static

SQRTPI.

Returns the square root of (number * pi).

Parameters
float$numberNumber
Returns
float Square Root of Number * Pi

Definition at line 1044 of file MathTrig.php.

1044 {
1046
1047 if (is_numeric($number)) {
1048 if ($number < 0) {
1050 }
1051 return sqrt($number * M_PI) ;
1052 }
1054 } // function SQRTPI()

References PHPExcel_Calculation_Functions\flattenSingleValue(), PHPExcel_Calculation_Functions\NaN(), and PHPExcel_Calculation_Functions\VALUE().

+ Here is the call graph for this function:

◆ SUBTOTAL()

static PHPExcel_Calculation_MathTrig::SUBTOTAL ( )
static

SUBTOTAL.

Returns a subtotal in a list or database.

Parameters
intthe number 1 to 11 that specifies which function to use in calculating subtotals within a list.
arrayof mixed Data Series
Returns
float

Definition at line 1067 of file MathTrig.php.

1067 {
1068 $aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
1069
1070 // Calculate
1071 $subtotal = array_shift($aArgs);
1072
1073 if ((is_numeric($subtotal)) && (!is_string($subtotal))) {
1074 switch($subtotal) {
1075 case 1 :
1077 break;
1078 case 2 :
1080 break;
1081 case 3 :
1083 break;
1084 case 4 :
1086 break;
1087 case 5 :
1089 break;
1090 case 6 :
1091 return self::PRODUCT($aArgs);
1092 break;
1093 case 7 :
1095 break;
1096 case 8 :
1098 break;
1099 case 9 :
1100 return self::SUM($aArgs);
1101 break;
1102 case 10 :
1104 break;
1105 case 11 :
1107 break;
1108 }
1109 }
1111 } // function SUBTOTAL()

References PHPExcel_Calculation_Statistical\AVERAGE(), PHPExcel_Calculation_Statistical\COUNT(), PHPExcel_Calculation_Statistical\COUNTA(), PHPExcel_Calculation_Functions\flattenArray(), PHPExcel_Calculation_Statistical\MAX(), PHPExcel_Calculation_Statistical\MIN(), PRODUCT(), PHPExcel_Calculation_Statistical\STDEV(), PHPExcel_Calculation_Statistical\STDEVP(), SUM(), PHPExcel_Calculation_Functions\VALUE(), PHPExcel_Calculation_Statistical\VARFunc(), and PHPExcel_Calculation_Statistical\VARP().

+ Here is the call graph for this function:

◆ SUM()

static PHPExcel_Calculation_MathTrig::SUM ( )
static

Definition at line 1127 of file MathTrig.php.

1127 {
1128 // Return value
1129 $returnValue = 0;
1130
1131 // Loop through the arguments
1132 foreach (PHPExcel_Calculation_Functions::flattenArray(func_get_args()) as $arg) {
1133 // Is it a numeric value?
1134 if ((is_numeric($arg)) && (!is_string($arg))) {
1135 $returnValue += $arg;
1136 }
1137 }
1138
1139 // Return
1140 return $returnValue;
1141 } // function SUM()

References PHPExcel_Calculation_Functions\flattenArray().

Referenced by PHPExcel_Calculation_Database\DSUM(), and SUBTOTAL().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SUMIF()

static PHPExcel_Calculation_MathTrig::SUMIF (   $aArgs,
  $condition,
  $sumArgs = array() 
)
static

Definition at line 1158 of file MathTrig.php.

1158 {
1159 // Return value
1160 $returnValue = 0;
1161
1164 if (empty($sumArgs)) {
1165 $sumArgs = $aArgs;
1166 }
1167 $condition = PHPExcel_Calculation_Functions::_ifCondition($condition);
1168 // Loop through arguments
1169 foreach ($aArgs as $key => $arg) {
1170 if (!is_numeric($arg)) {
1171 $arg = str_replace('"', '""', $arg);
1172 $arg = PHPExcel_Calculation::_wrapResult(strtoupper($arg));
1173 }
1174
1175 $testCondition = '='.$arg.$condition;
1176 if (PHPExcel_Calculation::getInstance()->_calculateFormulaValue($testCondition)) {
1177 // Is it a value within our criteria
1178 $returnValue += $sumArgs[$key];
1179 }
1180 }
1181
1182 // Return
1183 return $returnValue;
1184 } // function SUMIF()
static _ifCondition($condition)
Definition: Functions.php:309
static getInstance(PHPExcel $workbook=NULL)
Get an instance of this class.
static _wrapResult($value)
Wrap string values in quotes.

References PHPExcel_Calculation_Functions\_ifCondition(), PHPExcel_Calculation\_wrapResult(), PHPExcel_Calculation_Functions\flattenArray(), and PHPExcel_Calculation\getInstance().

+ Here is the call graph for this function:

◆ SUMPRODUCT()

static PHPExcel_Calculation_MathTrig::SUMPRODUCT ( )
static

Definition at line 1198 of file MathTrig.php.

1198 {
1199 $arrayList = func_get_args();
1200
1201 $wrkArray = PHPExcel_Calculation_Functions::flattenArray(array_shift($arrayList));
1202 $wrkCellCount = count($wrkArray);
1203
1204 for ($i=0; $i< $wrkCellCount; ++$i) {
1205 if ((!is_numeric($wrkArray[$i])) || (is_string($wrkArray[$i]))) {
1206 $wrkArray[$i] = 0;
1207 }
1208 }
1209
1210 foreach($arrayList as $matrixData) {
1211 $array2 = PHPExcel_Calculation_Functions::flattenArray($matrixData);
1212 $count = count($array2);
1213 if ($wrkCellCount != $count) {
1215 }
1216
1217 foreach ($array2 as $i => $val) {
1218 if ((!is_numeric($val)) || (is_string($val))) {
1219 $val = 0;
1220 }
1221 $wrkArray[$i] *= $val;
1222 }
1223 }
1224
1225 return array_sum($wrkArray);
1226 } // function SUMPRODUCT()

References PHPExcel_Calculation_Functions\flattenArray(), and PHPExcel_Calculation_Functions\VALUE().

+ Here is the call graph for this function:

◆ SUMSQ()

static PHPExcel_Calculation_MathTrig::SUMSQ ( )
static

Definition at line 1242 of file MathTrig.php.

1242 {
1243 // Return value
1244 $returnValue = 0;
1245
1246 // Loop through arguments
1247 foreach (PHPExcel_Calculation_Functions::flattenArray(func_get_args()) as $arg) {
1248 // Is it a numeric value?
1249 if ((is_numeric($arg)) && (!is_string($arg))) {
1250 $returnValue += ($arg * $arg);
1251 }
1252 }
1253
1254 // Return
1255 return $returnValue;
1256 } // function SUMSQ()

References PHPExcel_Calculation_Functions\flattenArray().

+ Here is the call graph for this function:

◆ SUMX2MY2()

static PHPExcel_Calculation_MathTrig::SUMX2MY2 (   $matrixData1,
  $matrixData2 
)
static

SUMX2MY2.

Parameters
mixed[]$matrixData1Matrix #1
mixed[]$matrixData2Matrix #2
Returns
float

Definition at line 1266 of file MathTrig.php.

1266 {
1267 $array1 = PHPExcel_Calculation_Functions::flattenArray($matrixData1);
1268 $array2 = PHPExcel_Calculation_Functions::flattenArray($matrixData2);
1269 $count1 = count($array1);
1270 $count2 = count($array2);
1271 if ($count1 < $count2) {
1272 $count = $count1;
1273 } else {
1274 $count = $count2;
1275 }
1276
1277 $result = 0;
1278 for ($i = 0; $i < $count; ++$i) {
1279 if (((is_numeric($array1[$i])) && (!is_string($array1[$i]))) &&
1280 ((is_numeric($array2[$i])) && (!is_string($array2[$i])))) {
1281 $result += ($array1[$i] * $array1[$i]) - ($array2[$i] * $array2[$i]);
1282 }
1283 }
1284
1285 return $result;
1286 } // function SUMX2MY2()

References $result, and PHPExcel_Calculation_Functions\flattenArray().

+ Here is the call graph for this function:

◆ SUMX2PY2()

static PHPExcel_Calculation_MathTrig::SUMX2PY2 (   $matrixData1,
  $matrixData2 
)
static

SUMX2PY2.

Parameters
mixed[]$matrixData1Matrix #1
mixed[]$matrixData2Matrix #2
Returns
float

Definition at line 1296 of file MathTrig.php.

1296 {
1297 $array1 = PHPExcel_Calculation_Functions::flattenArray($matrixData1);
1298 $array2 = PHPExcel_Calculation_Functions::flattenArray($matrixData2);
1299 $count1 = count($array1);
1300 $count2 = count($array2);
1301 if ($count1 < $count2) {
1302 $count = $count1;
1303 } else {
1304 $count = $count2;
1305 }
1306
1307 $result = 0;
1308 for ($i = 0; $i < $count; ++$i) {
1309 if (((is_numeric($array1[$i])) && (!is_string($array1[$i]))) &&
1310 ((is_numeric($array2[$i])) && (!is_string($array2[$i])))) {
1311 $result += ($array1[$i] * $array1[$i]) + ($array2[$i] * $array2[$i]);
1312 }
1313 }
1314
1315 return $result;
1316 } // function SUMX2PY2()

References $result, and PHPExcel_Calculation_Functions\flattenArray().

+ Here is the call graph for this function:

◆ SUMXMY2()

static PHPExcel_Calculation_MathTrig::SUMXMY2 (   $matrixData1,
  $matrixData2 
)
static

SUMXMY2.

Parameters
mixed[]$matrixData1Matrix #1
mixed[]$matrixData2Matrix #2
Returns
float

Definition at line 1326 of file MathTrig.php.

1326 {
1327 $array1 = PHPExcel_Calculation_Functions::flattenArray($matrixData1);
1328 $array2 = PHPExcel_Calculation_Functions::flattenArray($matrixData2);
1329 $count1 = count($array1);
1330 $count2 = count($array2);
1331 if ($count1 < $count2) {
1332 $count = $count1;
1333 } else {
1334 $count = $count2;
1335 }
1336
1337 $result = 0;
1338 for ($i = 0; $i < $count; ++$i) {
1339 if (((is_numeric($array1[$i])) && (!is_string($array1[$i]))) &&
1340 ((is_numeric($array2[$i])) && (!is_string($array2[$i])))) {
1341 $result += ($array1[$i] - $array2[$i]) * ($array1[$i] - $array2[$i]);
1342 }
1343 }
1344
1345 return $result;
1346 } // function SUMXMY2()

References $result, and PHPExcel_Calculation_Functions\flattenArray().

+ Here is the call graph for this function:

◆ TRUNC()

static PHPExcel_Calculation_MathTrig::TRUNC (   $value = 0,
  $digits = 0 
)
static

TRUNC.

Truncates value to the number of fractional digits by number_digits.

Parameters
float$value
int$digits
Returns
float Truncated value

Definition at line 1358 of file MathTrig.php.

1358 {
1361
1362 // Validate parameters
1363 if ((!is_numeric($value)) || (!is_numeric($digits)))
1365 $digits = floor($digits);
1366
1367 // Truncate
1368 $adjust = pow(10, $digits);
1369
1370 if (($digits > 0) && (rtrim(intval((abs($value) - abs(intval($value))) * $adjust),'0') < $adjust/10))
1371 return $value;
1372
1373 return (intval($value * $adjust)) / $adjust;
1374 } // function TRUNC()

References PHPExcel_Calculation_Functions\flattenSingleValue(), and PHPExcel_Calculation_Functions\VALUE().

+ Here is the call graph for this function:

The documentation for this class was generated from the following file: