You are here

public static function PHPExcel_Calculation_Engineering::BESSELI 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::BESSELI()

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

Parameters

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

2 calls to PHPExcel_Calculation_Engineering::BESSELI()
PHPExcel_Calculation_Engineering::_Besselk0 in vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/Engineering.php
PHPExcel_Calculation_Engineering::_Besselk1 in vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/Engineering.php

File

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

Class

PHPExcel_Calculation_Engineering
PHPExcel_Calculation_Engineering

Code

public static function BESSELI($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)) {
    $ord = floor($ord);
    if ($ord < 0) {
      return PHPExcel_Calculation_Functions::NaN();
    }
    if (abs($x) <= 30) {
      $fResult = $fTerm = pow($x / 2, $ord) / PHPExcel_Calculation_MathTrig::FACT($ord);
      $ordK = 1;
      $fSqrX = $x * $x / 4;
      do {
        $fTerm *= $fSqrX;
        $fTerm /= $ordK * ($ordK + $ord);
        $fResult += $fTerm;
      } while (abs($fTerm) > 1.0E-12 && ++$ordK < 100);
    }
    else {
      $f_2_PI = 2 * M_PI;
      $fXAbs = abs($x);
      $fResult = exp($fXAbs) / sqrt($f_2_PI * $fXAbs);
      if ($ord & 1 && $x < 0) {
        $fResult = -$fResult;
      }
    }
    return is_nan($fResult) ? PHPExcel_Calculation_Functions::NaN() : $fResult;
  }
  return PHPExcel_Calculation_Functions::VALUE();
}