You are here

public static function PHPExcel_Calculation_Engineering::BESSELK in Loft Data Grids 7.2

Same name and namespace in other branches
  1. 6.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/Engineering.php \PHPExcel_Calculation_Engineering::BESSELK()

* BESSELK * * Returns the modified Bessel function Kn(x), which is equivalent to the Bessel functions evaluated * for purely imaginary arguments. * * Excel Function: * BESSELK(x,ord) * * @access public * @category Engineering Functions *

Parameters

float $x The value at which to evaluate the function.: * If x is nonnumeric, BESSELK returns the #VALUE! error value. * @param integer $ord The order of the Bessel function. If n is not an integer, it is truncated. * If $ord is nonnumeric, BESSELK returns the #VALUE! error value. * If $ord < 0, BESSELK returns the #NUM! error value. * @return float *

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/Engineering.php, line 937

Class

PHPExcel_Calculation_Engineering
PHPExcel_Calculation_Engineering

Code

public static function BESSELK($x, $ord) {
  $x = is_null($x) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($x);
  $ord = is_null($ord) ? 0.0 : PHPExcel_Calculation_Functions::flattenSingleValue($ord);
  if (is_numeric($x) && is_numeric($ord)) {
    if ($ord < 0 || $x == 0.0) {
      return PHPExcel_Calculation_Functions::NaN();
    }
    switch (floor($ord)) {
      case 0:
        return self::_Besselk0($x);
        break;
      case 1:
        return self::_Besselk1($x);
        break;
      default:
        $fTox = 2 / $x;
        $fBkm = self::_Besselk0($x);
        $fBk = self::_Besselk1($x);
        for ($n = 1; $n < $ord; ++$n) {
          $fBkp = $fBkm + $n * $fTox * $fBk;
          $fBkm = $fBk;
          $fBk = $fBkp;
        }
    }
    return is_nan($fBk) ? PHPExcel_Calculation_Functions::NaN() : $fBk;
  }
  return PHPExcel_Calculation_Functions::VALUE();
}