@@ 3407-3433 (lines=27) @@ | ||
3404 | * @param mixed $arg,... Data values |
|
3405 | * @return float |
|
3406 | */ |
|
3407 | public static function VARFunc() { |
|
3408 | // Return value |
|
3409 | $returnValue = PHPExcel_Calculation_Functions::DIV0(); |
|
3410 | ||
3411 | $summerA = $summerB = 0; |
|
3412 | ||
3413 | // Loop through arguments |
|
3414 | $aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args()); |
|
3415 | $aCount = 0; |
|
3416 | foreach ($aArgs as $arg) { |
|
3417 | if (is_bool($arg)) { $arg = (integer) $arg; } |
|
3418 | // Is it a numeric value? |
|
3419 | if ((is_numeric($arg)) && (!is_string($arg))) { |
|
3420 | $summerA += ($arg * $arg); |
|
3421 | $summerB += $arg; |
|
3422 | ++$aCount; |
|
3423 | } |
|
3424 | } |
|
3425 | ||
3426 | // Return |
|
3427 | if ($aCount > 1) { |
|
3428 | $summerA *= $aCount; |
|
3429 | $summerB *= $summerB; |
|
3430 | $returnValue = ($summerA - $summerB) / ($aCount * ($aCount - 1)); |
|
3431 | } |
|
3432 | return $returnValue; |
|
3433 | } // function VARFunc() |
|
3434 | ||
3435 | ||
3436 | /** |
|
@@ 3502-3528 (lines=27) @@ | ||
3499 | * @param mixed $arg,... Data values |
|
3500 | * @return float |
|
3501 | */ |
|
3502 | public static function VARP() { |
|
3503 | // Return value |
|
3504 | $returnValue = PHPExcel_Calculation_Functions::DIV0(); |
|
3505 | ||
3506 | $summerA = $summerB = 0; |
|
3507 | ||
3508 | // Loop through arguments |
|
3509 | $aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args()); |
|
3510 | $aCount = 0; |
|
3511 | foreach ($aArgs as $arg) { |
|
3512 | if (is_bool($arg)) { $arg = (integer) $arg; } |
|
3513 | // Is it a numeric value? |
|
3514 | if ((is_numeric($arg)) && (!is_string($arg))) { |
|
3515 | $summerA += ($arg * $arg); |
|
3516 | $summerB += $arg; |
|
3517 | ++$aCount; |
|
3518 | } |
|
3519 | } |
|
3520 | ||
3521 | // Return |
|
3522 | if ($aCount > 0) { |
|
3523 | $summerA *= $aCount; |
|
3524 | $summerB *= $summerB; |
|
3525 | $returnValue = ($summerA - $summerB) / ($aCount * $aCount); |
|
3526 | } |
|
3527 | return $returnValue; |
|
3528 | } // function VARP() |
|
3529 | ||
3530 | ||
3531 | /** |