@@ 1005-1037 (lines=33) @@ | ||
1002 | * If $ord < 0, BESSELK returns the #NUM! error value. |
|
1003 | * @return float |
|
1004 | */ |
|
1005 | public static function BESSELK($x, $ord) |
|
1006 | { |
|
1007 | $x = (is_null($x)) ? 0.0 : Functions::flattenSingleValue($x); |
|
1008 | $ord = (is_null($ord)) ? 0.0 : Functions::flattenSingleValue($ord); |
|
1009 | ||
1010 | if ((is_numeric($x)) && (is_numeric($ord))) { |
|
1011 | if (($ord < 0) || ($x == 0.0)) { |
|
1012 | return Functions::NAN(); |
|
1013 | } |
|
1014 | ||
1015 | switch (floor($ord)) { |
|
1016 | case 0: |
|
1017 | $fBk = self::besselK0($x); |
|
1018 | break; |
|
1019 | case 1: |
|
1020 | $fBk = self::besselK1($x); |
|
1021 | break; |
|
1022 | default: |
|
1023 | $fTox = 2 / $x; |
|
1024 | $fBkm = self::besselK0($x); |
|
1025 | $fBk = self::besselK1($x); |
|
1026 | for ($n = 1; $n < $ord; ++$n) { |
|
1027 | $fBkp = $fBkm + $n * $fTox * $fBk; |
|
1028 | $fBkm = $fBk; |
|
1029 | $fBk = $fBkp; |
|
1030 | } |
|
1031 | } |
|
1032 | ||
1033 | return (is_nan($fBk)) ? Functions::NAN() : $fBk; |
|
1034 | } |
|
1035 | ||
1036 | return Functions::VALUE(); |
|
1037 | } |
|
1038 | ||
1039 | private static function besselY0($fNum) |
|
1040 | { |
|
@@ 1091-1123 (lines=33) @@ | ||
1088 | * |
|
1089 | * @return float |
|
1090 | */ |
|
1091 | public static function BESSELY($x, $ord) |
|
1092 | { |
|
1093 | $x = (is_null($x)) ? 0.0 : Functions::flattenSingleValue($x); |
|
1094 | $ord = (is_null($ord)) ? 0.0 : Functions::flattenSingleValue($ord); |
|
1095 | ||
1096 | if ((is_numeric($x)) && (is_numeric($ord))) { |
|
1097 | if (($ord < 0) || ($x == 0.0)) { |
|
1098 | return Functions::NAN(); |
|
1099 | } |
|
1100 | ||
1101 | switch (floor($ord)) { |
|
1102 | case 0: |
|
1103 | $fBy = self::besselY0($x); |
|
1104 | break; |
|
1105 | case 1: |
|
1106 | $fBy = self::besselY1($x); |
|
1107 | break; |
|
1108 | default: |
|
1109 | $fTox = 2 / $x; |
|
1110 | $fBym = self::besselY0($x); |
|
1111 | $fBy = self::besselY1($x); |
|
1112 | for ($n = 1; $n < $ord; ++$n) { |
|
1113 | $fByp = $n * $fTox * $fBy - $fBym; |
|
1114 | $fBym = $fBy; |
|
1115 | $fBy = $fByp; |
|
1116 | } |
|
1117 | } |
|
1118 | ||
1119 | return (is_nan($fBy)) ? Functions::NAN() : $fBy; |
|
1120 | } |
|
1121 | ||
1122 | return Functions::VALUE(); |
|
1123 | } |
|
1124 | ||
1125 | /** |
|
1126 | * BINTODEC |