@@ 994-1028 (lines=35) @@ | ||
991 | * |
|
992 | * @return float |
|
993 | */ |
|
994 | public static function BESSELK($x, $ord) |
|
995 | { |
|
996 | $x = ($x === null) ? 0.0 : Functions::flattenSingleValue($x); |
|
997 | $ord = ($ord === null) ? 0.0 : Functions::flattenSingleValue($ord); |
|
998 | ||
999 | if ((is_numeric($x)) && (is_numeric($ord))) { |
|
1000 | if (($ord < 0) || ($x == 0.0)) { |
|
1001 | return Functions::NAN(); |
|
1002 | } |
|
1003 | ||
1004 | switch (floor($ord)) { |
|
1005 | case 0: |
|
1006 | $fBk = self::besselK0($x); |
|
1007 | ||
1008 | break; |
|
1009 | case 1: |
|
1010 | $fBk = self::besselK1($x); |
|
1011 | ||
1012 | break; |
|
1013 | default: |
|
1014 | $fTox = 2 / $x; |
|
1015 | $fBkm = self::besselK0($x); |
|
1016 | $fBk = self::besselK1($x); |
|
1017 | for ($n = 1; $n < $ord; ++$n) { |
|
1018 | $fBkp = $fBkm + $n * $fTox * $fBk; |
|
1019 | $fBkm = $fBk; |
|
1020 | $fBk = $fBkp; |
|
1021 | } |
|
1022 | } |
|
1023 | ||
1024 | return (is_nan($fBk)) ? Functions::NAN() : $fBk; |
|
1025 | } |
|
1026 | ||
1027 | return Functions::VALUE(); |
|
1028 | } |
|
1029 | ||
1030 | private static function besselY0($fNum) |
|
1031 | { |
|
@@ 1083-1117 (lines=35) @@ | ||
1080 | * |
|
1081 | * @return float |
|
1082 | */ |
|
1083 | public static function BESSELY($x, $ord) |
|
1084 | { |
|
1085 | $x = ($x === null) ? 0.0 : Functions::flattenSingleValue($x); |
|
1086 | $ord = ($ord === null) ? 0.0 : Functions::flattenSingleValue($ord); |
|
1087 | ||
1088 | if ((is_numeric($x)) && (is_numeric($ord))) { |
|
1089 | if (($ord < 0) || ($x == 0.0)) { |
|
1090 | return Functions::NAN(); |
|
1091 | } |
|
1092 | ||
1093 | switch (floor($ord)) { |
|
1094 | case 0: |
|
1095 | $fBy = self::besselY0($x); |
|
1096 | ||
1097 | break; |
|
1098 | case 1: |
|
1099 | $fBy = self::besselY1($x); |
|
1100 | ||
1101 | break; |
|
1102 | default: |
|
1103 | $fTox = 2 / $x; |
|
1104 | $fBym = self::besselY0($x); |
|
1105 | $fBy = self::besselY1($x); |
|
1106 | for ($n = 1; $n < $ord; ++$n) { |
|
1107 | $fByp = $n * $fTox * $fBy - $fBym; |
|
1108 | $fBym = $fBy; |
|
1109 | $fBy = $fByp; |
|
1110 | } |
|
1111 | } |
|
1112 | ||
1113 | return (is_nan($fBy)) ? Functions::NAN() : $fBy; |
|
1114 | } |
|
1115 | ||
1116 | return Functions::VALUE(); |
|
1117 | } |
|
1118 | ||
1119 | /** |
|
1120 | * BINTODEC. |