feat:node-modules
This commit is contained in:
53
node_modules/mathjs/lib/cjs/function/combinatorics/bellNumbers.js
generated
vendored
Normal file
53
node_modules/mathjs/lib/cjs/function/combinatorics/bellNumbers.js
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.createBellNumbers = void 0;
|
||||
var _factory = require("../../utils/factory.js");
|
||||
const name = 'bellNumbers';
|
||||
const dependencies = ['typed', 'addScalar', 'isNegative', 'isInteger', 'stirlingS2'];
|
||||
const createBellNumbers = exports.createBellNumbers = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
|
||||
let {
|
||||
typed,
|
||||
addScalar,
|
||||
isNegative,
|
||||
isInteger,
|
||||
stirlingS2
|
||||
} = _ref;
|
||||
/**
|
||||
* The Bell Numbers count the number of partitions of a set. A partition is a pairwise disjoint subset of S whose union is S.
|
||||
* bellNumbers only takes integer arguments.
|
||||
* The following condition must be enforced: n >= 0
|
||||
*
|
||||
* Syntax:
|
||||
*
|
||||
* math.bellNumbers(n)
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* math.bellNumbers(3) // returns 5
|
||||
* math.bellNumbers(8) // returns 4140
|
||||
*
|
||||
* See also:
|
||||
*
|
||||
* stirlingS2
|
||||
*
|
||||
* @param {Number | BigNumber} n Total number of objects in the set
|
||||
* @return {Number | BigNumber} B(n)
|
||||
*/
|
||||
return typed(name, {
|
||||
'number | BigNumber': function (n) {
|
||||
if (!isInteger(n) || isNegative(n)) {
|
||||
throw new TypeError('Non-negative integer value expected in function bellNumbers');
|
||||
}
|
||||
|
||||
// Sum (k=0, n) S(n,k).
|
||||
let result = 0;
|
||||
for (let i = 0; i <= n; i++) {
|
||||
result = addScalar(result, stirlingS2(n, i));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
});
|
||||
});
|
||||
49
node_modules/mathjs/lib/cjs/function/combinatorics/catalan.js
generated
vendored
Normal file
49
node_modules/mathjs/lib/cjs/function/combinatorics/catalan.js
generated
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.createCatalan = void 0;
|
||||
var _factory = require("../../utils/factory.js");
|
||||
const name = 'catalan';
|
||||
const dependencies = ['typed', 'addScalar', 'divideScalar', 'multiplyScalar', 'combinations', 'isNegative', 'isInteger'];
|
||||
const createCatalan = exports.createCatalan = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
|
||||
let {
|
||||
typed,
|
||||
addScalar,
|
||||
divideScalar,
|
||||
multiplyScalar,
|
||||
combinations,
|
||||
isNegative,
|
||||
isInteger
|
||||
} = _ref;
|
||||
/**
|
||||
* The Catalan Numbers enumerate combinatorial structures of many different types.
|
||||
* catalan only takes integer arguments.
|
||||
* The following condition must be enforced: n >= 0
|
||||
*
|
||||
* Syntax:
|
||||
*
|
||||
* math.catalan(n)
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* math.catalan(3) // returns 5
|
||||
* math.catalan(8) // returns 1430
|
||||
*
|
||||
* See also:
|
||||
*
|
||||
* bellNumbers
|
||||
*
|
||||
* @param {Number | BigNumber} n nth Catalan number
|
||||
* @return {Number | BigNumber} Cn(n)
|
||||
*/
|
||||
return typed(name, {
|
||||
'number | BigNumber': function (n) {
|
||||
if (!isInteger(n) || isNegative(n)) {
|
||||
throw new TypeError('Non-negative integer value expected in function catalan');
|
||||
}
|
||||
return divideScalar(combinations(multiplyScalar(n, 2), n), addScalar(n, 1));
|
||||
}
|
||||
});
|
||||
});
|
||||
52
node_modules/mathjs/lib/cjs/function/combinatorics/composition.js
generated
vendored
Normal file
52
node_modules/mathjs/lib/cjs/function/combinatorics/composition.js
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.createComposition = void 0;
|
||||
var _factory = require("../../utils/factory.js");
|
||||
const name = 'composition';
|
||||
const dependencies = ['typed', 'addScalar', 'combinations', 'isNegative', 'isPositive', 'isInteger', 'larger'];
|
||||
const createComposition = exports.createComposition = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
|
||||
let {
|
||||
typed,
|
||||
addScalar,
|
||||
combinations,
|
||||
isPositive,
|
||||
isNegative,
|
||||
isInteger,
|
||||
larger
|
||||
} = _ref;
|
||||
/**
|
||||
* The composition counts of n into k parts.
|
||||
*
|
||||
* composition only takes integer arguments.
|
||||
* The following condition must be enforced: k <= n.
|
||||
*
|
||||
* Syntax:
|
||||
*
|
||||
* math.composition(n, k)
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* math.composition(5, 3) // returns 6
|
||||
*
|
||||
* See also:
|
||||
*
|
||||
* combinations
|
||||
*
|
||||
* @param {Number | BigNumber} n Total number of objects in the set
|
||||
* @param {Number | BigNumber} k Number of objects in the subset
|
||||
* @return {Number | BigNumber} Returns the composition counts of n into k parts.
|
||||
*/
|
||||
return typed(name, {
|
||||
'number | BigNumber, number | BigNumber': function (n, k) {
|
||||
if (!isInteger(n) || !isPositive(n) || !isInteger(k) || !isPositive(k)) {
|
||||
throw new TypeError('Positive integer value expected in function composition');
|
||||
} else if (larger(k, n)) {
|
||||
throw new TypeError('k must be less than or equal to n in function composition');
|
||||
}
|
||||
return combinations(addScalar(n, -1), addScalar(k, -1));
|
||||
}
|
||||
});
|
||||
});
|
||||
92
node_modules/mathjs/lib/cjs/function/combinatorics/stirlingS2.js
generated
vendored
Normal file
92
node_modules/mathjs/lib/cjs/function/combinatorics/stirlingS2.js
generated
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.createStirlingS2 = void 0;
|
||||
var _factory = require("../../utils/factory.js");
|
||||
var _is = require("../../utils/is.js");
|
||||
const name = 'stirlingS2';
|
||||
const dependencies = ['typed', 'addScalar', 'subtractScalar', 'multiplyScalar', 'divideScalar', 'pow', 'factorial', 'combinations', 'isNegative', 'isInteger', 'number', '?bignumber', 'larger'];
|
||||
const createStirlingS2 = exports.createStirlingS2 = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
|
||||
let {
|
||||
typed,
|
||||
addScalar,
|
||||
subtractScalar,
|
||||
multiplyScalar,
|
||||
divideScalar,
|
||||
pow,
|
||||
factorial,
|
||||
combinations,
|
||||
isNegative,
|
||||
isInteger,
|
||||
number,
|
||||
bignumber,
|
||||
larger
|
||||
} = _ref;
|
||||
const smallCache = [];
|
||||
const bigCache = [];
|
||||
/**
|
||||
* The Stirling numbers of the second kind, counts the number of ways to partition
|
||||
* a set of n labelled objects into k nonempty unlabelled subsets.
|
||||
* stirlingS2 only takes integer arguments.
|
||||
* The following condition must be enforced: k <= n.
|
||||
*
|
||||
* If n = k or k = 1 <= n, then s(n,k) = 1
|
||||
* If k = 0 < n, then s(n,k) = 0
|
||||
*
|
||||
* Note that if either n or k is supplied as a BigNumber, the result will be
|
||||
* as well.
|
||||
*
|
||||
* Syntax:
|
||||
*
|
||||
* math.stirlingS2(n, k)
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* math.stirlingS2(5, 3) //returns 25
|
||||
*
|
||||
* See also:
|
||||
*
|
||||
* bellNumbers
|
||||
*
|
||||
* @param {Number | BigNumber} n Total number of objects in the set
|
||||
* @param {Number | BigNumber} k Number of objects in the subset
|
||||
* @return {Number | BigNumber} S(n,k)
|
||||
*/
|
||||
return typed(name, {
|
||||
'number | BigNumber, number | BigNumber': function (n, k) {
|
||||
if (!isInteger(n) || isNegative(n) || !isInteger(k) || isNegative(k)) {
|
||||
throw new TypeError('Non-negative integer value expected in function stirlingS2');
|
||||
} else if (larger(k, n)) {
|
||||
throw new TypeError('k must be less than or equal to n in function stirlingS2');
|
||||
}
|
||||
const big = !((0, _is.isNumber)(n) && (0, _is.isNumber)(k));
|
||||
const cache = big ? bigCache : smallCache;
|
||||
const make = big ? bignumber : number;
|
||||
const nn = number(n);
|
||||
const nk = number(k);
|
||||
/* See if we already have the value: */
|
||||
if (cache[nn] && cache[nn].length > nk) {
|
||||
return cache[nn][nk];
|
||||
}
|
||||
/* Fill the cache */
|
||||
for (let m = 0; m <= nn; ++m) {
|
||||
if (!cache[m]) {
|
||||
cache[m] = [m === 0 ? make(1) : make(0)];
|
||||
}
|
||||
if (m === 0) continue;
|
||||
const row = cache[m];
|
||||
const prev = cache[m - 1];
|
||||
for (let i = row.length; i <= m && i <= nk; ++i) {
|
||||
if (i === m) {
|
||||
row[i] = 1;
|
||||
} else {
|
||||
row[i] = addScalar(multiplyScalar(make(i), prev[i]), prev[i - 1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return cache[nn][nk];
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user