@@ 3449-3486 (lines=38) @@ | ||
3446 | * @param mixed $arg,... Data values |
|
3447 | * @return float |
|
3448 | */ |
|
3449 | public static function VARA() { |
|
3450 | // Return value |
|
3451 | $returnValue = PHPExcel_Calculation_Functions::DIV0(); |
|
3452 | ||
3453 | $summerA = $summerB = 0; |
|
3454 | ||
3455 | // Loop through arguments |
|
3456 | $aArgs = PHPExcel_Calculation_Functions::flattenArrayIndexed(func_get_args()); |
|
3457 | $aCount = 0; |
|
3458 | foreach ($aArgs as $k => $arg) { |
|
3459 | if ((is_string($arg)) && |
|
3460 | (PHPExcel_Calculation_Functions::isValue($k))) { |
|
3461 | return PHPExcel_Calculation_Functions::VALUE(); |
|
3462 | } elseif ((is_string($arg)) && |
|
3463 | (!PHPExcel_Calculation_Functions::isMatrixValue($k))) { |
|
3464 | } else { |
|
3465 | // Is it a numeric value? |
|
3466 | if ((is_numeric($arg)) || (is_bool($arg)) || ((is_string($arg) & ($arg != '')))) { |
|
3467 | if (is_bool($arg)) { |
|
3468 | $arg = (integer) $arg; |
|
3469 | } elseif (is_string($arg)) { |
|
3470 | $arg = 0; |
|
3471 | } |
|
3472 | $summerA += ($arg * $arg); |
|
3473 | $summerB += $arg; |
|
3474 | ++$aCount; |
|
3475 | } |
|
3476 | } |
|
3477 | } |
|
3478 | ||
3479 | // Return |
|
3480 | if ($aCount > 1) { |
|
3481 | $summerA *= $aCount; |
|
3482 | $summerB *= $summerB; |
|
3483 | $returnValue = ($summerA - $summerB) / ($aCount * ($aCount - 1)); |
|
3484 | } |
|
3485 | return $returnValue; |
|
3486 | } // function VARA() |
|
3487 | ||
3488 | ||
3489 | /** |
|
@@ 3544-3581 (lines=38) @@ | ||
3541 | * @param mixed $arg,... Data values |
|
3542 | * @return float |
|
3543 | */ |
|
3544 | public static function VARPA() { |
|
3545 | // Return value |
|
3546 | $returnValue = PHPExcel_Calculation_Functions::DIV0(); |
|
3547 | ||
3548 | $summerA = $summerB = 0; |
|
3549 | ||
3550 | // Loop through arguments |
|
3551 | $aArgs = PHPExcel_Calculation_Functions::flattenArrayIndexed(func_get_args()); |
|
3552 | $aCount = 0; |
|
3553 | foreach ($aArgs as $k => $arg) { |
|
3554 | if ((is_string($arg)) && |
|
3555 | (PHPExcel_Calculation_Functions::isValue($k))) { |
|
3556 | return PHPExcel_Calculation_Functions::VALUE(); |
|
3557 | } elseif ((is_string($arg)) && |
|
3558 | (!PHPExcel_Calculation_Functions::isMatrixValue($k))) { |
|
3559 | } else { |
|
3560 | // Is it a numeric value? |
|
3561 | if ((is_numeric($arg)) || (is_bool($arg)) || ((is_string($arg) & ($arg != '')))) { |
|
3562 | if (is_bool($arg)) { |
|
3563 | $arg = (integer) $arg; |
|
3564 | } elseif (is_string($arg)) { |
|
3565 | $arg = 0; |
|
3566 | } |
|
3567 | $summerA += ($arg * $arg); |
|
3568 | $summerB += $arg; |
|
3569 | ++$aCount; |
|
3570 | } |
|
3571 | } |
|
3572 | } |
|
3573 | ||
3574 | // Return |
|
3575 | if ($aCount > 0) { |
|
3576 | $summerA *= $aCount; |
|
3577 | $summerB *= $summerB; |
|
3578 | $returnValue = ($summerA - $summerB) / ($aCount * $aCount); |
|
3579 | } |
|
3580 | return $returnValue; |
|
3581 | } // function VARPA() |
|
3582 | ||
3583 | ||
3584 | /** |