include node_modules so release .zip is deployable
This commit is contained in:
+12
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std
|
||||
*/
|
||||
import { INegatable } from "./INegatable";
|
||||
export interface IComputable<Param, Ret = Param> extends INegatable<Ret> {
|
||||
plus(val: Param): Ret;
|
||||
minus(val: Param): Ret;
|
||||
multiplies(val: Param): Ret;
|
||||
divides(val: Param): Ret;
|
||||
modules(val: Param): Ret;
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=IComputable.js.map
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std
|
||||
*/
|
||||
export interface INegatable<Ret> {
|
||||
negate(): Ret;
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=INegatable.js.map
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std
|
||||
*/
|
||||
export * from "./operators";
|
||||
export * from "./operations";
|
||||
export * from "./special_math/index";
|
||||
export * from "./IComputable";
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//================================================================
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std
|
||||
*/
|
||||
//================================================================
|
||||
__exportStar(require("./operators"), exports);
|
||||
__exportStar(require("./operations"), exports);
|
||||
__exportStar(require("./special_math/index"), exports);
|
||||
__exportStar(require("./IComputable"), exports);
|
||||
//# sourceMappingURL=index.js.map
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std
|
||||
*/
|
||||
import { IForwardIterator } from "../iterator/IForwardIterator";
|
||||
import { General } from "../internal/functional/General";
|
||||
import { Writeonly } from "../internal/functional/Writeonly";
|
||||
import { IPointer } from "../functional/IPointer";
|
||||
/**
|
||||
* Greatest Common Divider.
|
||||
*/
|
||||
export declare function gcd(x: number, y: number): number;
|
||||
/**
|
||||
* Least Common Multiple.
|
||||
*/
|
||||
export declare function lcm(x: number, y: number): number;
|
||||
export declare function iota<ForwardIterator extends General<IForwardIterator<number, ForwardIterator>>>(first: ForwardIterator, last: ForwardIterator, value: number): void;
|
||||
export declare function accumulate<InputIterator extends General<IForwardIterator<IPointer.ValueType<InputIterator>, InputIterator>>>(first: InputIterator, last: InputIterator, init: IPointer.ValueType<InputIterator>, op?: Operator<InputIterator, InputIterator>): IPointer.ValueType<InputIterator>;
|
||||
export declare function inner_product<InputIterator1 extends General<IForwardIterator<IPointer.ValueType<InputIterator1>, InputIterator1>>, InputIterator2 extends General<IForwardIterator<IPointer.ValueType<InputIterator2>, InputIterator2>>>(first1: InputIterator1, last1: InputIterator1, first2: InputIterator2, value: IPointer.ValueType<InputIterator1>, adder?: Operator<InputIterator1, InputIterator1>, multiplier?: Operator<InputIterator1, InputIterator2>): IPointer.ValueType<InputIterator1>;
|
||||
export declare function adjacent_difference<InputIterator extends Readonly<IForwardIterator<IPointer.ValueType<InputIterator>, InputIterator>>, OutputIterator extends Writeonly<IForwardIterator<IPointer.ValueType<InputIterator>, OutputIterator>>>(first: InputIterator, last: InputIterator, output: OutputIterator, subtracter?: Operator<InputIterator, InputIterator>): OutputIterator;
|
||||
export declare function partial_sum<InputIterator extends Readonly<IForwardIterator<IPointer.ValueType<InputIterator>, InputIterator>>, OutputIterator extends Writeonly<IForwardIterator<IPointer.ValueType<InputIterator>, OutputIterator>>>(first: InputIterator, last: InputIterator, output: OutputIterator, adder?: Operator<InputIterator, InputIterator>): OutputIterator;
|
||||
export declare function inclusive_scan<InputIterator extends Readonly<IForwardIterator<IPointer.ValueType<InputIterator>, InputIterator>>, OutputIterator extends Writeonly<IForwardIterator<IPointer.ValueType<InputIterator>, OutputIterator>>>(first: InputIterator, last: InputIterator, output: OutputIterator, adder?: Operator<InputIterator, InputIterator>, init?: IPointer.ValueType<InputIterator>): OutputIterator;
|
||||
export declare function exclusive_scan<InputIterator extends Readonly<IForwardIterator<IPointer.ValueType<InputIterator>, InputIterator>>, OutputIterator extends Writeonly<IForwardIterator<IPointer.ValueType<InputIterator>, OutputIterator>>>(first: InputIterator, last: InputIterator, output: OutputIterator, init: IPointer.ValueType<InputIterator>, op?: Operator<InputIterator, InputIterator>): OutputIterator;
|
||||
export declare function transform_inclusive_scan<InputIterator extends Readonly<IForwardIterator<IPointer.ValueType<InputIterator>, InputIterator>>, OutputIterator extends Writeonly<IForwardIterator<IPointer.ValueType<OutputIterator>, OutputIterator>>>(first: InputIterator, last: InputIterator, output: OutputIterator, binary: Operator<OutputIterator, OutputIterator>, unary: Transformer<InputIterator, OutputIterator>, init?: IPointer.ValueType<InputIterator>): OutputIterator;
|
||||
export declare function transform_exclusive_scan<InputIterator extends Readonly<IForwardIterator<IPointer.ValueType<InputIterator>, InputIterator>>, OutputIterator extends Writeonly<IForwardIterator<IPointer.ValueType<OutputIterator>, OutputIterator>>>(first: InputIterator, last: InputIterator, output: OutputIterator, init: IPointer.ValueType<InputIterator>, binary: Operator<OutputIterator, OutputIterator>, unary: Transformer<InputIterator, OutputIterator>): OutputIterator;
|
||||
declare type Operator<Iterator1 extends Readonly<IForwardIterator<IPointer.ValueType<Iterator1>, Iterator1>>, Iterator2 extends Readonly<IForwardIterator<IPointer.ValueType<Iterator2>, Iterator2>>> = (x: IPointer.ValueType<Iterator1>, y: IPointer.ValueType<Iterator2>) => IPointer.ValueType<Iterator1>;
|
||||
declare type Transformer<InputIterator extends Readonly<IForwardIterator<IPointer.ValueType<InputIterator>, InputIterator>>, OutputIterator extends Writeonly<IForwardIterator<IPointer.ValueType<OutputIterator>, OutputIterator>>> = (val: IPointer.ValueType<InputIterator>) => IPointer.ValueType<OutputIterator>;
|
||||
export {};
|
||||
+155
@@ -0,0 +1,155 @@
|
||||
"use strict";
|
||||
var __read = (this && this.__read) || function (o, n) {
|
||||
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
||||
if (!m) return o;
|
||||
var i = m.call(o), r, ar = [], e;
|
||||
try {
|
||||
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
||||
}
|
||||
catch (error) { e = { error: error }; }
|
||||
finally {
|
||||
try {
|
||||
if (r && !r.done && (m = i["return"])) m.call(i);
|
||||
}
|
||||
finally { if (e) throw e.error; }
|
||||
}
|
||||
return ar;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.transform_exclusive_scan = exports.transform_inclusive_scan = exports.exclusive_scan = exports.inclusive_scan = exports.partial_sum = exports.adjacent_difference = exports.inner_product = exports.accumulate = exports.iota = exports.lcm = exports.gcd = void 0;
|
||||
var operators_1 = require("./operators");
|
||||
/**
|
||||
* Greatest Common Divider.
|
||||
*/
|
||||
function gcd(x, y) {
|
||||
var _a;
|
||||
y = y.valueOf(); // `Number` to `number`
|
||||
while (y !== 0)
|
||||
_a = __read([y, x % y], 2), x = _a[0], y = _a[1];
|
||||
return x;
|
||||
}
|
||||
exports.gcd = gcd;
|
||||
/**
|
||||
* Least Common Multiple.
|
||||
*/
|
||||
function lcm(x, y) {
|
||||
return (x * y) / gcd(x, y);
|
||||
}
|
||||
exports.lcm = lcm;
|
||||
/* ---------------------------------------------------------
|
||||
COMMON ALGORITHMS
|
||||
--------------------------------------------------------- */
|
||||
function iota(first, last, value) {
|
||||
for (; !first.equals(last); first = first.next())
|
||||
first.value = value++;
|
||||
}
|
||||
exports.iota = iota;
|
||||
function accumulate(first, last, init, op) {
|
||||
if (op === void 0) { op = operators_1.plus; }
|
||||
for (; !first.equals(last); first = first.next())
|
||||
init = op(init, first.value);
|
||||
return init;
|
||||
}
|
||||
exports.accumulate = accumulate;
|
||||
function inner_product(first1, last1, first2, value, adder, multiplier) {
|
||||
if (adder === void 0) { adder = operators_1.plus; }
|
||||
if (multiplier === void 0) { multiplier = operators_1.multiplies; }
|
||||
for (; !first1.equals(last1); first1 = first1.next()) {
|
||||
value = adder(value, multiplier(first1.value, first2.value));
|
||||
first2 = first2.next();
|
||||
}
|
||||
return value;
|
||||
}
|
||||
exports.inner_product = inner_product;
|
||||
function adjacent_difference(first, last, output, subtracter) {
|
||||
var _a;
|
||||
if (subtracter === void 0) { subtracter = operators_1.minus; }
|
||||
if (first.equals(last))
|
||||
return output;
|
||||
// INITIALIZE
|
||||
var before;
|
||||
_a = __read(_Initialize(first, output), 3), first = _a[0], output = _a[1], before = _a[2];
|
||||
// COMPUTE OPERATIONS
|
||||
for (; !first.equals(last); first = first.next()) {
|
||||
output.value = subtracter(first.value, before);
|
||||
before = first.value;
|
||||
output = output.next();
|
||||
}
|
||||
return output;
|
||||
}
|
||||
exports.adjacent_difference = adjacent_difference;
|
||||
function partial_sum(first, last, output, adder) {
|
||||
var _a;
|
||||
if (adder === void 0) { adder = operators_1.plus; }
|
||||
if (first.equals(last))
|
||||
return output;
|
||||
// INITIALIZE
|
||||
var sum;
|
||||
_a = __read(_Initialize(first, output), 3), first = _a[0], output = _a[1], sum = _a[2];
|
||||
// COMPUTE OPERATIONS
|
||||
for (; !first.equals(last); first = first.next()) {
|
||||
sum = adder(sum, first.value);
|
||||
output.value = sum;
|
||||
output = output.next();
|
||||
}
|
||||
return output;
|
||||
}
|
||||
exports.partial_sum = partial_sum;
|
||||
/* ---------------------------------------------------------
|
||||
PREFIX SUMS
|
||||
--------------------------------------------------------- */
|
||||
function inclusive_scan(first, last, output, adder, init) {
|
||||
if (adder === void 0) { adder = operators_1.plus; }
|
||||
return transform_inclusive_scan(first, last, output, adder, function (val) { return val; }, init);
|
||||
}
|
||||
exports.inclusive_scan = inclusive_scan;
|
||||
function exclusive_scan(first, last, output, init, op) {
|
||||
if (op === void 0) { op = operators_1.plus; }
|
||||
return transform_exclusive_scan(first, last, output, init, op, function (val) { return val; });
|
||||
}
|
||||
exports.exclusive_scan = exclusive_scan;
|
||||
function transform_inclusive_scan(first, last, output, binary, unary, init) {
|
||||
var _a;
|
||||
if (first.equals(last))
|
||||
return output;
|
||||
// INITIALIZE
|
||||
var before;
|
||||
_a = __read(_Transform_initialize(first, output, unary, init), 3), first = _a[0], output = _a[1], before = _a[2];
|
||||
// COMPUTE OPERATIONS
|
||||
for (; !first.equals(last); first = first.next()) {
|
||||
before = binary(before, unary(first.value));
|
||||
output.value = before;
|
||||
output = output.next();
|
||||
}
|
||||
return output;
|
||||
}
|
||||
exports.transform_inclusive_scan = transform_inclusive_scan;
|
||||
function transform_exclusive_scan(first, last, output, init, binary, unary) {
|
||||
var _a;
|
||||
if (first.equals(last))
|
||||
return output;
|
||||
// INITIALIZE
|
||||
var x = unary(first.value);
|
||||
var y;
|
||||
_a = __read(_Transform_initialize(first, output, unary, init), 3), first = _a[0], output = _a[1], y = _a[2];
|
||||
// COMPUTE OPERATIONS
|
||||
for (; !first.equals(last); first = first.next()) {
|
||||
y = binary(x, y);
|
||||
x = unary(first.value);
|
||||
output.value = y;
|
||||
output = output.next();
|
||||
}
|
||||
return output;
|
||||
}
|
||||
exports.transform_exclusive_scan = transform_exclusive_scan;
|
||||
function _Initialize(first, output, init) {
|
||||
return _Transform_initialize(first, output, function (val) { return val; }, init);
|
||||
}
|
||||
function _Transform_initialize(first, output, unary, init) {
|
||||
// WRITE THE FIRST OR INITIAL VALUE
|
||||
var ret = unary(init === undefined ? first.value : init);
|
||||
output.value = ret;
|
||||
// RETURNS WITH ADVANCES
|
||||
return [first.next(), output.next(), ret];
|
||||
}
|
||||
//# sourceMappingURL=operations.js.map
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std
|
||||
*/
|
||||
import { INegatable } from "./INegatable";
|
||||
import { IComputable } from "./IComputable";
|
||||
declare type PlusParam<Y, Ret> = number | string | Pick<IComputable<Y, Ret>, "plus">;
|
||||
declare type Param<Y, Ret, Key extends keyof IComputable<Y, Ret>> = number | Pick<IComputable<Y, Ret>, Key>;
|
||||
export declare function plus<X extends PlusParam<Y, Ret>, Y = X, Ret = X>(x: X, y: Y): Ret;
|
||||
export declare function minus<X extends Param<Y, Ret, "minus">, Y = X, Ret = X>(x: X, y: Y): Ret;
|
||||
export declare function negate<X extends number | INegatable<Ret>, Ret = X>(x: X): Ret;
|
||||
export declare function multiplies<X extends Param<Y, Ret, "multiplies">, Y = X, Ret = X>(x: X, y: Y): Ret;
|
||||
export declare function divides<X extends Param<Y, Ret, "divides">, Y = X, Ret = X>(x: X, y: Y): Ret;
|
||||
export declare function modules<X extends Param<Y, Ret, "modules">, Y = X, Ret = X>(x: X, y: Y): Ret;
|
||||
export {};
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.modules = exports.divides = exports.multiplies = exports.negate = exports.minus = exports.plus = void 0;
|
||||
/* ---------------------------------------------------------
|
||||
PLUS
|
||||
--------------------------------------------------------- */
|
||||
function plus(x, y) {
|
||||
if (x.plus instanceof Function)
|
||||
return x.plus(y);
|
||||
else
|
||||
return x + y;
|
||||
}
|
||||
exports.plus = plus;
|
||||
function minus(x, y) {
|
||||
if (x.minus instanceof Function)
|
||||
return x.minus(y);
|
||||
else
|
||||
return (x - y);
|
||||
}
|
||||
exports.minus = minus;
|
||||
function negate(x) {
|
||||
if (x.negate instanceof Function)
|
||||
return x.negate();
|
||||
else
|
||||
return -x;
|
||||
}
|
||||
exports.negate = negate;
|
||||
/* ---------------------------------------------------------
|
||||
MULTIPLY
|
||||
--------------------------------------------------------- */
|
||||
function multiplies(x, y) {
|
||||
if (x.multiplies instanceof Function)
|
||||
return x.multiplies(y);
|
||||
else
|
||||
return (x * y);
|
||||
}
|
||||
exports.multiplies = multiplies;
|
||||
function divides(x, y) {
|
||||
if (x.divides instanceof Function)
|
||||
return x.divides(y);
|
||||
else
|
||||
return (x / y);
|
||||
}
|
||||
exports.divides = divides;
|
||||
function modules(x, y) {
|
||||
if (x.modules instanceof Function)
|
||||
return x.modules(y);
|
||||
else
|
||||
return (x % y);
|
||||
}
|
||||
exports.modules = modules;
|
||||
//# sourceMappingURL=operators.js.map
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* Bessel function of the 1st kind.
|
||||
*
|
||||
* @reference https://en.wikipedia.org/wiki/Bessel_function#Bessel_functions_of_the_first_kind:_J.CE.B1
|
||||
*/
|
||||
export declare function cyl_bessel_j(n: number, x: number): number;
|
||||
/**
|
||||
* Bessel function of the 2nd kind.
|
||||
*
|
||||
* @reference https://en.wikipedia.org/wiki/Bessel_function#Bessel_functions_of_the_second_kind:_Y.CE.B1
|
||||
*/
|
||||
export declare function cyl_neumann(v: number, x: number): number;
|
||||
/**
|
||||
* Spherical Bessel function of the 1st kind.
|
||||
*
|
||||
* @reference https://en.wikipedia.org/wiki/Bessel_function#Spherical_Bessel_functions:_jn.2C_yn
|
||||
*/
|
||||
export declare function sph_bessel(n: number, x: number): number;
|
||||
/**
|
||||
* Spherical Bessel function of the 2nd kind.
|
||||
*
|
||||
* @reference https://en.wikipedia.org/wiki/Bessel_function#Spherical_Bessel_functions:_jn.2C_yn
|
||||
*/
|
||||
export declare function sph_neumann(n: number, x: number): number;
|
||||
/**
|
||||
* Modified cylindrical Bessel function of the 1st kind.
|
||||
*
|
||||
* @reference https://en.wikipedia.org/wiki/Bessel_function#Modified_Bessel_functions:_I.CE.B1_.2C_K.CE.B1
|
||||
*/
|
||||
export declare function cyl_bessel_i(n: number, x: number): number;
|
||||
/**
|
||||
* Modified cylindrical Bessel function of the 2nd kind.
|
||||
*
|
||||
* @reference https://en.wikipedia.org/wiki/Bessel_function#Modified_Bessel_functions:_I.CE.B1_.2C_K.CE.B1
|
||||
*/
|
||||
export declare function cyl_bessel_k(n: number, x: number): number;
|
||||
+141
@@ -0,0 +1,141 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.cyl_bessel_k = exports.cyl_bessel_i = exports.sph_neumann = exports.sph_bessel = exports.cyl_neumann = exports.cyl_bessel_j = void 0;
|
||||
//================================================================
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std
|
||||
*/
|
||||
//================================================================
|
||||
var MathUtil_1 = require("../../internal/numeric/MathUtil");
|
||||
var InvalidArgument_1 = require("../../exception/InvalidArgument");
|
||||
var gamma_1 = require("./gamma");
|
||||
var INFINITY = 100; // (1 / 30!) is nearby 0.
|
||||
/*================================================================
|
||||
ORIGINAL FUNCTIONS
|
||||
- CYLINDRICAL
|
||||
- SPHERICAL
|
||||
==================================================================
|
||||
FIRST KIND
|
||||
--------------------------------------------------------------- */
|
||||
/**
|
||||
* Bessel function of the 1st kind.
|
||||
*
|
||||
* @reference https://en.wikipedia.org/wiki/Bessel_function#Bessel_functions_of_the_first_kind:_J.CE.B1
|
||||
*/
|
||||
function cyl_bessel_j(n, x) {
|
||||
// VALIDATION
|
||||
if (x < 0 && Math.floor(n) !== n)
|
||||
throw new InvalidArgument_1.InvalidArgument("Error on std.cyl_bessel_j(): n must be integer when x is negative -> (n = ".concat(n, ", x = ").concat(x, ")."));
|
||||
else if (x === 0 && n !== 0)
|
||||
throw new InvalidArgument_1.InvalidArgument("Error on std.cyl_bessel_j(): n must be zero when x is zero -> (n = ".concat(n, ", x = ").concat(x, ")."));
|
||||
// COMPUTATION
|
||||
if (n === Math.floor(n))
|
||||
return _J_int(n, x);
|
||||
else
|
||||
return _J_positive(n, x);
|
||||
}
|
||||
exports.cyl_bessel_j = cyl_bessel_j;
|
||||
/**
|
||||
* Bessel function of the 2nd kind.
|
||||
*
|
||||
* @reference https://en.wikipedia.org/wiki/Bessel_function#Bessel_functions_of_the_second_kind:_Y.CE.B1
|
||||
*/
|
||||
function cyl_neumann(v, x) {
|
||||
if (x <= 0)
|
||||
throw new InvalidArgument_1.InvalidArgument("Error on std.cyl_neumann(): x must be greater than zero -> (x = ".concat(x, ")."));
|
||||
var numerator = cyl_bessel_j(v, x) * Math.cos(v * Math.PI) - cyl_bessel_j(-v, x);
|
||||
var denominator = Math.sin(v * Math.PI);
|
||||
return numerator / denominator;
|
||||
}
|
||||
exports.cyl_neumann = cyl_neumann;
|
||||
function _J_int(n, x) {
|
||||
if (n < 0)
|
||||
return Math.pow(-1, n) * _J_positive(-n, x);
|
||||
else
|
||||
return _J_positive(n, x);
|
||||
}
|
||||
function _J_positive(v, x) {
|
||||
var sigma = MathUtil_1.MathUtil.sigma(function (k) {
|
||||
var ret = Math.pow(-1, k) * Math.pow(x / 2, v + 2 * k);
|
||||
ret /= MathUtil_1.MathUtil.factorial(k) * (0, gamma_1.tgamma)(v + k + 1);
|
||||
return ret;
|
||||
}, 0, INFINITY);
|
||||
return sigma;
|
||||
}
|
||||
/* ---------------------------------------------------------------
|
||||
SPHERICAL
|
||||
--------------------------------------------------------------- */
|
||||
/**
|
||||
* Spherical Bessel function of the 1st kind.
|
||||
*
|
||||
* @reference https://en.wikipedia.org/wiki/Bessel_function#Spherical_Bessel_functions:_jn.2C_yn
|
||||
*/
|
||||
function sph_bessel(n, x) {
|
||||
return Math.sqrt(Math.PI / (2 * x)) * cyl_bessel_j(n + 0.5, x);
|
||||
}
|
||||
exports.sph_bessel = sph_bessel;
|
||||
/**
|
||||
* Spherical Bessel function of the 2nd kind.
|
||||
*
|
||||
* @reference https://en.wikipedia.org/wiki/Bessel_function#Spherical_Bessel_functions:_jn.2C_yn
|
||||
*/
|
||||
function sph_neumann(n, x) {
|
||||
var ret = Math.sqrt(Math.PI / (2 * x));
|
||||
ret *= cyl_neumann(n + 0.5, x);
|
||||
return ret;
|
||||
}
|
||||
exports.sph_neumann = sph_neumann;
|
||||
/*================================================================
|
||||
REQGULAR MODIFIED
|
||||
- FIRST KIND
|
||||
- SECOND KIND
|
||||
==================================================================
|
||||
FIRST KIND
|
||||
--------------------------------------------------------------- */
|
||||
/**
|
||||
* Modified cylindrical Bessel function of the 1st kind.
|
||||
*
|
||||
* @reference https://en.wikipedia.org/wiki/Bessel_function#Modified_Bessel_functions:_I.CE.B1_.2C_K.CE.B1
|
||||
*/
|
||||
function cyl_bessel_i(n, x) {
|
||||
// VALIDATION
|
||||
if (x < 0 && Math.floor(n) !== n)
|
||||
throw new InvalidArgument_1.InvalidArgument("Error on std.cyl_bessel_i(): n must be integer when x is negative -> (n = ".concat(n, ", x = ").concat(x, ")."));
|
||||
else if (x === 0 && n !== 0)
|
||||
throw new InvalidArgument_1.InvalidArgument("Error on std.cyl_bessel_i(): n must be zero when x is zero -> (n = ".concat(n, ", x = ").concat(x, ")."));
|
||||
// COMPUTATION
|
||||
if (n === 0.5)
|
||||
return Math.sqrt(2.0 / (Math.PI * x)) * Math.sinh(x);
|
||||
else
|
||||
return _Bessel_i(n, x);
|
||||
}
|
||||
exports.cyl_bessel_i = cyl_bessel_i;
|
||||
function _Bessel_i(v, x) {
|
||||
return MathUtil_1.MathUtil.sigma(function (k) {
|
||||
var numerator = Math.pow(x / 2, v + 2 * k);
|
||||
var denominator = MathUtil_1.MathUtil.factorial(k) * (0, gamma_1.tgamma)(v + k + 1);
|
||||
return numerator / denominator;
|
||||
}, 0, INFINITY);
|
||||
}
|
||||
/* ---------------------------------------------------------------
|
||||
SECOND KIND
|
||||
--------------------------------------------------------------- */
|
||||
/**
|
||||
* Modified cylindrical Bessel function of the 2nd kind.
|
||||
*
|
||||
* @reference https://en.wikipedia.org/wiki/Bessel_function#Modified_Bessel_functions:_I.CE.B1_.2C_K.CE.B1
|
||||
*/
|
||||
function cyl_bessel_k(n, x) {
|
||||
if (x <= 0)
|
||||
throw new InvalidArgument_1.InvalidArgument("Error on std.cyl_bessel_k(): requires x > 0 -> (x = ".concat(x, ")."));
|
||||
return _Bessel_k(n, x);
|
||||
}
|
||||
exports.cyl_bessel_k = cyl_bessel_k;
|
||||
function _Bessel_k(v, z) {
|
||||
var ret = Math.PI / 2;
|
||||
ret *= cyl_bessel_i(-v, z) - cyl_bessel_i(v, z);
|
||||
ret /= Math.sin(v * Math.PI);
|
||||
return ret;
|
||||
}
|
||||
//# sourceMappingURL=bessels.js.map
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* Beta function.
|
||||
*
|
||||
* @reference https://en.wikipedia.org/wiki/Beta_function
|
||||
*/
|
||||
export declare function beta(x: number, y: number): number;
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.beta = void 0;
|
||||
//================================================================
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std
|
||||
*/
|
||||
//================================================================
|
||||
var gamma_1 = require("./gamma");
|
||||
/**
|
||||
* Beta function.
|
||||
*
|
||||
* @reference https://en.wikipedia.org/wiki/Beta_function
|
||||
*/
|
||||
function beta(x, y) {
|
||||
return ((0, gamma_1.tgamma)(x) * (0, gamma_1.tgamma)(y)) / (0, gamma_1.tgamma)(x + y);
|
||||
}
|
||||
exports.beta = beta;
|
||||
//# sourceMappingURL=beta.js.map
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* Incomplete elliptic integral of the 1st kind.
|
||||
*
|
||||
* @reference https://en.wikipedia.org/wiki/Elliptic_integral#Complete_elliptic_integral_of_the_first_kind
|
||||
*/
|
||||
export declare function ellint_1(k: number, phi: number): number;
|
||||
/**
|
||||
* Complete elliptic integral of the 1st kind.
|
||||
*
|
||||
* @reference https://en.wikipedia.org/wiki/Elliptic_integral#Elliptic_integral_of_the_first_kind
|
||||
*/
|
||||
export declare function comp_ellint_1(k: number): number;
|
||||
/**
|
||||
* Incomplete elliptic integral of the 2nd kind.
|
||||
*
|
||||
* @reference https://en.wikipedia.org/wiki/Elliptic_integral#Incomplete_elliptic_integral_of_the_second_kind
|
||||
*/
|
||||
export declare function ellint_2(k: number, phi: number): number;
|
||||
/**
|
||||
* Complete elliptic integral of the 2nd kind.
|
||||
*
|
||||
* @reference https://en.wikipedia.org/wiki/Elliptic_integral#Complete_elliptic_integral_of_the_second_kind
|
||||
*/
|
||||
export declare function comp_ellint_2(k: number): number;
|
||||
/**
|
||||
* Incomplete elliptic integral of the 3rd kind.
|
||||
*
|
||||
* @reference https://en.wikipedia.org/wiki/Elliptic_integral#Complete_elliptic_integral_of_the_third_kind
|
||||
*/
|
||||
export declare function ellint_3(k: number, v: number, phi: number): number;
|
||||
/**
|
||||
* Complete elliptic integral of the 3rd kind.
|
||||
*
|
||||
* @reference https://en.wikipedia.org/wiki/Elliptic_integral#Incomplete_elliptic_integral_of_the_third_kind
|
||||
*/
|
||||
export declare function comp_ellint_3(k: number, n: number): number;
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.comp_ellint_3 = exports.ellint_3 = exports.comp_ellint_2 = exports.ellint_2 = exports.comp_ellint_1 = exports.ellint_1 = void 0;
|
||||
//================================================================
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std
|
||||
*/
|
||||
//================================================================
|
||||
var MathUtil_1 = require("../../internal/numeric/MathUtil");
|
||||
var InvalidArgument_1 = require("../../exception/InvalidArgument");
|
||||
/* ---------------------------------------------------------------
|
||||
FIRST
|
||||
--------------------------------------------------------------- */
|
||||
/**
|
||||
* Incomplete elliptic integral of the 1st kind.
|
||||
*
|
||||
* @reference https://en.wikipedia.org/wiki/Elliptic_integral#Complete_elliptic_integral_of_the_first_kind
|
||||
*/
|
||||
function ellint_1(k, phi) {
|
||||
// FORMULA OF INTEGRAL
|
||||
var formula = function (x) {
|
||||
return 1.0 / _Common_formula(k, x);
|
||||
};
|
||||
return _Post_process("ellint_1", k, phi, formula);
|
||||
}
|
||||
exports.ellint_1 = ellint_1;
|
||||
/**
|
||||
* Complete elliptic integral of the 1st kind.
|
||||
*
|
||||
* @reference https://en.wikipedia.org/wiki/Elliptic_integral#Elliptic_integral_of_the_first_kind
|
||||
*/
|
||||
function comp_ellint_1(k) {
|
||||
return ellint_1(k, Math.PI / 2);
|
||||
}
|
||||
exports.comp_ellint_1 = comp_ellint_1;
|
||||
/* ---------------------------------------------------------------
|
||||
SECOND
|
||||
--------------------------------------------------------------- */
|
||||
/**
|
||||
* Incomplete elliptic integral of the 2nd kind.
|
||||
*
|
||||
* @reference https://en.wikipedia.org/wiki/Elliptic_integral#Incomplete_elliptic_integral_of_the_second_kind
|
||||
*/
|
||||
function ellint_2(k, phi) {
|
||||
var formula = function (x) {
|
||||
return _Common_formula(k, x);
|
||||
};
|
||||
return _Post_process("ellint_2", k, phi, formula);
|
||||
}
|
||||
exports.ellint_2 = ellint_2;
|
||||
/**
|
||||
* Complete elliptic integral of the 2nd kind.
|
||||
*
|
||||
* @reference https://en.wikipedia.org/wiki/Elliptic_integral#Complete_elliptic_integral_of_the_second_kind
|
||||
*/
|
||||
function comp_ellint_2(k) {
|
||||
return ellint_2(k, Math.PI / 2);
|
||||
}
|
||||
exports.comp_ellint_2 = comp_ellint_2;
|
||||
/* ---------------------------------------------------------------
|
||||
THIRD
|
||||
--------------------------------------------------------------- */
|
||||
/**
|
||||
* Incomplete elliptic integral of the 3rd kind.
|
||||
*
|
||||
* @reference https://en.wikipedia.org/wiki/Elliptic_integral#Complete_elliptic_integral_of_the_third_kind
|
||||
*/
|
||||
function ellint_3(k, v, phi) {
|
||||
// SPECIAL VALIDATIONS ONLY FOR SERIES-3
|
||||
var predicator = 1 / Math.pow(Math.sin(phi), 2);
|
||||
if (v > predicator)
|
||||
throw new InvalidArgument_1.InvalidArgument("Error on std.ellint_3(): must be v < (1 / sin^2(phi)) -> (v = ".concat(v, ", 1 / sin^2(phi) = ").concat(predicator, ")."));
|
||||
return _Ellint_3(k, v, phi);
|
||||
}
|
||||
exports.ellint_3 = ellint_3;
|
||||
/**
|
||||
* Complete elliptic integral of the 3rd kind.
|
||||
*
|
||||
* @reference https://en.wikipedia.org/wiki/Elliptic_integral#Incomplete_elliptic_integral_of_the_third_kind
|
||||
*/
|
||||
function comp_ellint_3(k, n) {
|
||||
return ellint_3(k, n, Math.PI / 2);
|
||||
}
|
||||
exports.comp_ellint_3 = comp_ellint_3;
|
||||
function _Ellint_3(k, v, phi) {
|
||||
var formula = function (x) {
|
||||
var denominator = 1 - v * Math.pow(Math.sin(x), 2);
|
||||
denominator *= _Common_formula(k, x);
|
||||
return 1.0 / denominator;
|
||||
};
|
||||
return _Post_process("ellint_3", k, phi, formula);
|
||||
}
|
||||
/* ---------------------------------------------------------------
|
||||
BACKGROUNDS
|
||||
--------------------------------------------------------------- */
|
||||
function _Common_formula(k, x) {
|
||||
return Math.sqrt(1 - Math.pow(k * Math.sin(x), 2));
|
||||
}
|
||||
function _Post_process(func, k, phi, formula) {
|
||||
if (Math.abs(k) > 1)
|
||||
throw new InvalidArgument_1.InvalidArgument("Error on std.".concat(func, "(): must be |k| <= 1 -> (k = ").concat(k, ")."));
|
||||
var area = MathUtil_1.MathUtil.integral(formula, 0, phi);
|
||||
return phi < 0 ? -area : area;
|
||||
}
|
||||
//# sourceMappingURL=ellints.js.map
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
/**
|
||||
* Exponential integral.
|
||||
*/
|
||||
export declare function expint(x: number): number;
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.expint = void 0;
|
||||
//================================================================
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std
|
||||
*/
|
||||
//================================================================
|
||||
var MathUtil_1 = require("../../internal/numeric/MathUtil");
|
||||
/**
|
||||
* Exponential integral.
|
||||
*/
|
||||
function expint(x) {
|
||||
if (x === 0)
|
||||
return -Infinity;
|
||||
else if (x < 0)
|
||||
return -_E1_G(-x);
|
||||
else
|
||||
return _EI_Factorial(x);
|
||||
}
|
||||
exports.expint = expint;
|
||||
function _EI_Factorial(x) {
|
||||
return (EULER +
|
||||
Math.log(Math.abs(x)) / Math.log(Math.E) +
|
||||
MathUtil_1.MathUtil.sigma(function (k) {
|
||||
return Math.pow(x, k) / (k * MathUtil_1.MathUtil.factorial(k));
|
||||
}, 1, MAX_K));
|
||||
}
|
||||
/* ---------------------------------------------------------------
|
||||
SWAMEE AND OHIJA APPROXIMATION
|
||||
--------------------------------------------------------------- */
|
||||
// function _E1_AB(x: number): number
|
||||
// {
|
||||
// const A: number = _Compute_A(x);
|
||||
// const B: number = _Compute_B(x);
|
||||
// const ret: number = Math.pow(A, -7.7) + B;
|
||||
// return Math.pow(ret, -0.13);
|
||||
// }
|
||||
// function _Compute_A(x: number): number
|
||||
// {
|
||||
// const ret: number = 0.56146 / x + 0.65;
|
||||
// ret *= 1 + x;
|
||||
// ret = Math.log(ret) / Math.log(Math.E);
|
||||
// return ret;
|
||||
// }
|
||||
// function _Compute_B(x: number): number
|
||||
// {
|
||||
// const ret: number = Math.pow(x, 4);
|
||||
// ret *= Math.pow(Math.E, 7.7*x);
|
||||
// ret *= Math.pow(2 + x, 3.7);
|
||||
// return ret;
|
||||
// }
|
||||
/* ---------------------------------------------------------------
|
||||
BARRY APPROXIMATION
|
||||
--------------------------------------------------------------- */
|
||||
function _E1_G(x) {
|
||||
var h = _Compute_h(x);
|
||||
var ret = G + (1 - G) * Math.pow(Math.E, -x / (1 - G));
|
||||
ret = Math.pow(Math.E, -x) / ret;
|
||||
var ln = 1 + G / x - (1 - G) / Math.pow(h + B * x, 2);
|
||||
ln = Math.log(ln) / Math.log(Math.E);
|
||||
return ret * ln;
|
||||
}
|
||||
function _Compute_h(x) {
|
||||
var q = _Compute_q(x);
|
||||
var left = 1 / (1 + Math.pow(x, 1.5));
|
||||
var right = (H_INF * q) / (1 + q);
|
||||
return left + right;
|
||||
}
|
||||
function _Compute_q(x) {
|
||||
return (20 / 47) * Math.pow(x, Math.sqrt(31 / 26));
|
||||
}
|
||||
var EULER = 0.5772156649015328606;
|
||||
var MAX_K = 150;
|
||||
var G = Math.pow(Math.E, -EULER);
|
||||
var B = Math.sqrt((2 * (1 - G)) / (G * (2 - G)));
|
||||
var H_INF = ((1 - G) * (G * G - 6 * G + 12)) / (3 * G * Math.pow(2 - G, 2) * B);
|
||||
//# sourceMappingURL=expint.js.map
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std
|
||||
*/
|
||||
/**
|
||||
* Gamma function.
|
||||
*
|
||||
* @reference https://en.wikipedia.org/wiki/Gamma_function, https://rosettacode.org/wiki/Gamma_function#JavaScript
|
||||
*/
|
||||
export declare function tgamma(x: number): number;
|
||||
/**
|
||||
* Log gamma function.
|
||||
*/
|
||||
export declare function lgamma(x: number): number;
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.lgamma = exports.tgamma = void 0;
|
||||
//================================================================
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std
|
||||
*/
|
||||
//================================================================
|
||||
/**
|
||||
* Gamma function.
|
||||
*
|
||||
* @reference https://en.wikipedia.org/wiki/Gamma_function, https://rosettacode.org/wiki/Gamma_function#JavaScript
|
||||
*/
|
||||
function tgamma(x) {
|
||||
if (x < 0.5)
|
||||
return Math.PI / (Math.sin(Math.PI * x) * tgamma(1 - x));
|
||||
/*else if (x >= 1 && x === Math.floor(x))
|
||||
return base.MathUtil.factorial(x - 1);*/
|
||||
x -= 1;
|
||||
var a = P[0];
|
||||
var t = x + G + 0.5;
|
||||
for (var i = 1; i < P.length; ++i)
|
||||
a += P[i] / (x + i);
|
||||
return Math.sqrt(2 * Math.PI) * Math.pow(t, x + 0.5) * Math.exp(-t) * a;
|
||||
}
|
||||
exports.tgamma = tgamma;
|
||||
/**
|
||||
* Log gamma function.
|
||||
*/
|
||||
function lgamma(x) {
|
||||
return Math.log(tgamma(x));
|
||||
}
|
||||
exports.lgamma = lgamma;
|
||||
var P = [
|
||||
0.99999999999980993, 676.5203681218851, -1259.1392167224028,
|
||||
771.32342877765313, -176.61502916214059, 12.507343278686905,
|
||||
-0.13857109526572012, 9.9843695780195716e-6, 1.5056327351493116e-7,
|
||||
];
|
||||
var G = 7;
|
||||
//# sourceMappingURL=gamma.js.map
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* Hermite polynomial
|
||||
*
|
||||
* @reference https://en.wikipedia.org/wiki/Hermite_polynomials
|
||||
*/
|
||||
export declare function hermite(n: number, x: number): number;
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.hermite = void 0;
|
||||
//================================================================
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std
|
||||
*/
|
||||
//================================================================
|
||||
var InvalidArgument_1 = require("../../exception/InvalidArgument");
|
||||
/**
|
||||
* Hermite polynomial
|
||||
*
|
||||
* @reference https://en.wikipedia.org/wiki/Hermite_polynomials
|
||||
*/
|
||||
function hermite(n, x) {
|
||||
// VALIDATE PARAMETER
|
||||
if ((n = Math.floor(n)) < 0)
|
||||
throw new InvalidArgument_1.InvalidArgument("Error on std.hermite(): n must be unsigned integer -> (n = ".concat(n, ")."));
|
||||
// MEMORIZATION
|
||||
var solutions = [1, 2 * x];
|
||||
// COMPUTE RETURN VALUE
|
||||
return _Hermite(n, x, solutions);
|
||||
}
|
||||
exports.hermite = hermite;
|
||||
function _Hermite(n, x, solutions) {
|
||||
if (solutions.length > n)
|
||||
return solutions[n];
|
||||
var hn_1 = _Hermite(n - 1, x, solutions);
|
||||
var hn_2 = _Hermite(n - 2, x, solutions);
|
||||
var ret = x * hn_1 - (n - 1) * hn_2;
|
||||
ret *= 2;
|
||||
solutions[n] = ret;
|
||||
return ret;
|
||||
}
|
||||
//# sourceMappingURL=hermite.js.map
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std
|
||||
*/
|
||||
export * from "./beta";
|
||||
export * from "./gamma";
|
||||
export * from "./bessels";
|
||||
export * from "./ellints";
|
||||
export * from "./expint";
|
||||
export * from "./hermite";
|
||||
export * from "./legendres";
|
||||
export * from "./laguerres";
|
||||
export * from "./zeta";
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
"use strict";
|
||||
//================================================================
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std
|
||||
*/
|
||||
//================================================================
|
||||
// <special_math>
|
||||
//
|
||||
// @reference http://en.cppreference.com/w/cpp/numeric/special_math
|
||||
// @author Jeongho Nam - https://github.com/samchon
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__exportStar(require("./beta"), exports);
|
||||
__exportStar(require("./gamma"), exports);
|
||||
__exportStar(require("./bessels"), exports);
|
||||
__exportStar(require("./ellints"), exports);
|
||||
__exportStar(require("./expint"), exports);
|
||||
__exportStar(require("./hermite"), exports);
|
||||
__exportStar(require("./legendres"), exports);
|
||||
__exportStar(require("./laguerres"), exports);
|
||||
__exportStar(require("./zeta"), exports);
|
||||
//# sourceMappingURL=index.js.map
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* Laguerre polynomials.
|
||||
*
|
||||
* @reference https://en.wikipedia.org/wiki/Laguerre_polynomials
|
||||
*/
|
||||
export declare function laguerre(n: number, x: number): number;
|
||||
/**
|
||||
* Associated laguerre polynomials.
|
||||
*
|
||||
* @reference https://en.wikipedia.org/wiki/Laguerre_polynomials#Generalized_Laguerre_polynomials
|
||||
*/
|
||||
export declare function assoc_laguerre(n: number, m: number, x: number): number;
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.assoc_laguerre = exports.laguerre = void 0;
|
||||
//================================================================
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std
|
||||
*/
|
||||
//================================================================
|
||||
var InvalidArgument_1 = require("../../exception/InvalidArgument");
|
||||
/**
|
||||
* Laguerre polynomials.
|
||||
*
|
||||
* @reference https://en.wikipedia.org/wiki/Laguerre_polynomials
|
||||
*/
|
||||
function laguerre(n, x) {
|
||||
return assoc_laguerre(n, 0, x);
|
||||
}
|
||||
exports.laguerre = laguerre;
|
||||
/**
|
||||
* Associated laguerre polynomials.
|
||||
*
|
||||
* @reference https://en.wikipedia.org/wiki/Laguerre_polynomials#Generalized_Laguerre_polynomials
|
||||
*/
|
||||
function assoc_laguerre(n, m, x) {
|
||||
// VALIDATE PARAMETERS
|
||||
if ((n = Math.floor(n)) < 0 || (m = Math.floor(m)) < 0)
|
||||
throw new InvalidArgument_1.InvalidArgument("Error on std.assoc_laguerre(): both n and m must be unsigned integer -> (n = ".concat(n, ", m = ").concat(m, ")."));
|
||||
// MEMORIZATION
|
||||
var solutions = [1, -x + m + 1];
|
||||
// COMPUTE RETURN VALUE
|
||||
return _Compute_assoc_laguerre(n, m, x, solutions);
|
||||
}
|
||||
exports.assoc_laguerre = assoc_laguerre;
|
||||
function _Compute_assoc_laguerre(n, m, x, solutions) {
|
||||
if (solutions.length > n)
|
||||
return solutions[n];
|
||||
var ln_1 = _Compute_assoc_laguerre(n - 1, m, x, solutions);
|
||||
var ln_2 = _Compute_assoc_laguerre(n - 2, m, x, solutions);
|
||||
var ret = (2 * n - 1 + m - x) * ln_1 - (n + m - 1) * ln_2;
|
||||
ret = ret / n;
|
||||
solutions[n] = ret;
|
||||
return ret;
|
||||
}
|
||||
//# sourceMappingURL=laguerres.js.map
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* Legendre polynomials.
|
||||
*
|
||||
* @reference http://en.cppreference.com/w/cpp/numeric/special_math/legendre
|
||||
*/
|
||||
export declare function legendre(n: number, x: number): number;
|
||||
/**
|
||||
* Associated Legendre polynomials.
|
||||
*
|
||||
* @reference https://en.wikipedia.org/wiki/Associated_Legendre_polynomials
|
||||
*/
|
||||
export declare function assoc_legendre(n: number, m: number, x: number): number;
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.assoc_legendre = exports.legendre = void 0;
|
||||
//================================================================
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std
|
||||
*/
|
||||
//================================================================
|
||||
var InvalidArgument_1 = require("../../exception/InvalidArgument");
|
||||
/**
|
||||
* Legendre polynomials.
|
||||
*
|
||||
* @reference http://en.cppreference.com/w/cpp/numeric/special_math/legendre
|
||||
*/
|
||||
function legendre(n, x) {
|
||||
return assoc_legendre(n, 0, x);
|
||||
}
|
||||
exports.legendre = legendre;
|
||||
/**
|
||||
* Associated Legendre polynomials.
|
||||
*
|
||||
* @reference https://en.wikipedia.org/wiki/Associated_Legendre_polynomials
|
||||
*/
|
||||
function assoc_legendre(n, m, x) {
|
||||
// VALIDATE PARAMETERS
|
||||
if ((n = Math.floor(n)) < 0 || (m = Math.floor(m)) < 0)
|
||||
throw new InvalidArgument_1.InvalidArgument("Error on std.assoc_legendre(): both n and m must be unsigned integer -> (n = ".concat(n, ", m = ").concat(m, ")."));
|
||||
else if (Math.abs(x) > 1)
|
||||
throw new InvalidArgument_1.InvalidArgument("Error on std.assoc_legendre(): must be |x| <= 1 -> (x = ".concat(x, ")."));
|
||||
// MEMORIZATION
|
||||
var matrix = [[1, x]];
|
||||
matrix.length = m + 1;
|
||||
for (var i = 1; i < matrix.length; ++i)
|
||||
matrix[i] = [];
|
||||
// COMPUTE RETURN VALUE
|
||||
return _Compute_assoc_legendre(n, m, x, matrix);
|
||||
}
|
||||
exports.assoc_legendre = assoc_legendre;
|
||||
function _Compute_legendre(n, x, memory) {
|
||||
if (memory.length > n)
|
||||
return memory[n];
|
||||
var pn_1 = _Compute_legendre(n - 1, x, memory);
|
||||
var pn_2 = _Compute_legendre(n - 2, x, memory);
|
||||
var ret = (2 * n - 1) * x * pn_1 - (n - 1) * pn_2;
|
||||
ret /= n;
|
||||
memory[n] = ret;
|
||||
return ret;
|
||||
}
|
||||
function _Compute_assoc_legendre(n, m, x, matrix) {
|
||||
if (n < 0)
|
||||
n = -n - 1;
|
||||
if (m === 0)
|
||||
return _Compute_legendre(n, x, matrix[0]);
|
||||
else if (matrix[m].length > n && matrix[m][n] !== undefined)
|
||||
return matrix[m][n];
|
||||
var left = (n - m + 1) *
|
||||
(n - m + 2) *
|
||||
_Compute_assoc_legendre(n + 1, m - 1, x, matrix);
|
||||
var right = (n + m - 1) *
|
||||
(n + m) *
|
||||
_Compute_assoc_legendre(n - 1, m - 1, x, matrix);
|
||||
var ret = (left - right) / (2 * n + 1);
|
||||
ret /= Math.sqrt(1 - x * x);
|
||||
matrix[m][n] = ret;
|
||||
return ret;
|
||||
}
|
||||
//# sourceMappingURL=legendres.js.map
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* Riemann zeta function.
|
||||
*
|
||||
* @reference http://en.cppreference.com/w/cpp/numeric/special_math/riemann_zeta
|
||||
*/
|
||||
export declare function riemann_zeta(arg: number): number;
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.riemann_zeta = void 0;
|
||||
//================================================================
|
||||
/**
|
||||
* @packageDocumentation
|
||||
* @module std
|
||||
*/
|
||||
//================================================================
|
||||
var MathUtil_1 = require("../../internal/numeric/MathUtil");
|
||||
var gamma_1 = require("./gamma");
|
||||
/**
|
||||
* Riemann zeta function.
|
||||
*
|
||||
* @reference http://en.cppreference.com/w/cpp/numeric/special_math/riemann_zeta
|
||||
*/
|
||||
function riemann_zeta(arg) {
|
||||
if (arg < 0)
|
||||
return _Negative(arg);
|
||||
else if (arg === 0)
|
||||
return -0.5;
|
||||
else if (arg < 1)
|
||||
return _Fractional(arg);
|
||||
else if (arg === 1)
|
||||
return Infinity;
|
||||
else
|
||||
return _Positive(arg);
|
||||
}
|
||||
exports.riemann_zeta = riemann_zeta;
|
||||
function _Negative(arg) {
|
||||
return (Math.pow(2, arg) *
|
||||
Math.pow(Math.PI, arg - 1) *
|
||||
Math.sin((Math.PI * arg) / 2) *
|
||||
(0, gamma_1.tgamma)(1 - arg) *
|
||||
riemann_zeta(1 - arg));
|
||||
}
|
||||
function _Fractional(arg) {
|
||||
var divider = 1 - Math.pow(2, 1 - arg);
|
||||
var sigma = MathUtil_1.MathUtil.sigma(function (n) {
|
||||
return Math.pow(-1, n - 1) * Math.pow(n, -arg);
|
||||
}, 1, INFINITY);
|
||||
return sigma / divider;
|
||||
}
|
||||
function _Positive(arg) {
|
||||
return MathUtil_1.MathUtil.sigma(function (n) {
|
||||
return Math.pow(n, -arg);
|
||||
}, 1, INFINITY);
|
||||
}
|
||||
var INFINITY = 100 * 1000;
|
||||
//# sourceMappingURL=zeta.js.map
|
||||
Reference in New Issue
Block a user