You are here

public static function PHPExcel_Calculation_MathTrig::SERIESSUM in Loft Data Grids 7.2

Same name and namespace in other branches
  1. 6.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/MathTrig.php \PHPExcel_Calculation_MathTrig::SERIESSUM()

* SERIESSUM * * Returns the sum of a power series * *

Parameters

float $x Input value to the power series: * @param float $n Initial power to which you want to raise $x * @param float $m Step by which to increase $n for each term in the series * @param array of mixed Data Series * @return float

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/MathTrig.php, line 983

Class

PHPExcel_Calculation_MathTrig
PHPExcel_Calculation_MathTrig

Code

public static function SERIESSUM() {

  // Return value
  $returnValue = 0;

  // Loop through arguments
  $aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());
  $x = array_shift($aArgs);
  $n = array_shift($aArgs);
  $m = array_shift($aArgs);
  if (is_numeric($x) && is_numeric($n) && is_numeric($m)) {

    // Calculate
    $i = 0;
    foreach ($aArgs as $arg) {

      // Is it a numeric value?
      if (is_numeric($arg) && !is_string($arg)) {
        $returnValue += $arg * pow($x, $n + $m * $i++);
      }
      else {
        return PHPExcel_Calculation_Functions::VALUE();
      }
    }

    // Return
    return $returnValue;
  }
  return PHPExcel_Calculation_Functions::VALUE();
}