feat:node-modules
This commit is contained in:
36
node_modules/mathjs/lib/cjs/function/utils/clone.js
generated
vendored
Normal file
36
node_modules/mathjs/lib/cjs/function/utils/clone.js
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.createClone = void 0;
|
||||
var _object = require("../../utils/object.js");
|
||||
var _factory = require("../../utils/factory.js");
|
||||
const name = 'clone';
|
||||
const dependencies = ['typed'];
|
||||
const createClone = exports.createClone = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
|
||||
let {
|
||||
typed
|
||||
} = _ref;
|
||||
/**
|
||||
* Clone an object. Will make a deep copy of the data.
|
||||
*
|
||||
* Syntax:
|
||||
*
|
||||
* math.clone(x)
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* math.clone(3.5) // returns number 3.5
|
||||
* math.clone(math.complex('2-4i')) // returns Complex 2 - 4i
|
||||
* math.clone(math.unit(45, 'deg')) // returns Unit 45 deg
|
||||
* math.clone([[1, 2], [3, 4]]) // returns Array [[1, 2], [3, 4]]
|
||||
* math.clone("hello world") // returns string "hello world"
|
||||
*
|
||||
* @param {*} x Object to be cloned
|
||||
* @return {*} A clone of object x
|
||||
*/
|
||||
return typed(name, {
|
||||
any: _object.clone
|
||||
});
|
||||
});
|
||||
56
node_modules/mathjs/lib/cjs/function/utils/hasNumericValue.js
generated
vendored
Normal file
56
node_modules/mathjs/lib/cjs/function/utils/hasNumericValue.js
generated
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.createHasNumericValue = void 0;
|
||||
var _factory = require("../../utils/factory.js");
|
||||
const name = 'hasNumericValue';
|
||||
const dependencies = ['typed', 'isNumeric'];
|
||||
const createHasNumericValue = exports.createHasNumericValue = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
|
||||
let {
|
||||
typed,
|
||||
isNumeric
|
||||
} = _ref;
|
||||
/**
|
||||
* Test whether a value is an numeric value.
|
||||
*
|
||||
* In case of a string, true is returned if the string contains a numeric value.
|
||||
*
|
||||
* Syntax:
|
||||
*
|
||||
* math.hasNumericValue(x)
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* math.hasNumericValue(2) // returns true
|
||||
* math.hasNumericValue('2') // returns true
|
||||
* math.isNumeric('2') // returns false
|
||||
* math.hasNumericValue(0) // returns true
|
||||
* math.hasNumericValue(math.bignumber('500')) // returns true
|
||||
* math.hasNumericValue(math.bigint('42')) // returns true
|
||||
* math.hasNumericValue(42n) // returns true
|
||||
* math.hasNumericValue(math.fraction(4)) // returns true
|
||||
* math.hasNumericValue(math.complex('2-4i')) // returns false
|
||||
* math.hasNumericValue(false) // returns true
|
||||
* math.hasNumericValue([2.3, 'foo', false]) // returns [true, false, true]
|
||||
*
|
||||
* See also:
|
||||
*
|
||||
* isZero, isPositive, isNegative, isInteger, isNumeric
|
||||
*
|
||||
* @param {*} x Value to be tested
|
||||
* @return {boolean} Returns true when `x` is a `number`, `BigNumber`,
|
||||
* `Fraction`, `Boolean`, or a `String` containing number. Returns false for other types.
|
||||
* Throws an error in case of unknown types.
|
||||
*/
|
||||
return typed(name, {
|
||||
boolean: () => true,
|
||||
string: function (x) {
|
||||
return x.trim().length > 0 && !isNaN(Number(x));
|
||||
},
|
||||
any: function (x) {
|
||||
return isNumeric(x);
|
||||
}
|
||||
});
|
||||
});
|
||||
60
node_modules/mathjs/lib/cjs/function/utils/isInteger.js
generated
vendored
Normal file
60
node_modules/mathjs/lib/cjs/function/utils/isInteger.js
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.createIsInteger = void 0;
|
||||
var _collection = require("../../utils/collection.js");
|
||||
var _number = require("../../utils/number.js");
|
||||
var _factory = require("../../utils/factory.js");
|
||||
const name = 'isInteger';
|
||||
const dependencies = ['typed'];
|
||||
const createIsInteger = exports.createIsInteger = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
|
||||
let {
|
||||
typed
|
||||
} = _ref;
|
||||
/**
|
||||
* Test whether a value is an integer number.
|
||||
* The function supports `number`, `BigNumber`, and `Fraction`.
|
||||
*
|
||||
* The function is evaluated element-wise in case of Array or Matrix input.
|
||||
*
|
||||
* Syntax:
|
||||
*
|
||||
* math.isInteger(x)
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* math.isInteger(2) // returns true
|
||||
* math.isInteger(0) // returns true
|
||||
* math.isInteger(0.5) // returns false
|
||||
* math.isInteger(math.bignumber(500)) // returns true
|
||||
* math.isInteger(math.fraction(4)) // returns true
|
||||
* math.isInteger('3') // returns true
|
||||
* math.isInteger([3, 0.5, -2]) // returns [true, false, true]
|
||||
* math.isInteger(math.complex('2-4i')) // throws an error
|
||||
*
|
||||
* See also:
|
||||
*
|
||||
* isNumeric, isPositive, isNegative, isZero
|
||||
*
|
||||
* @param {number | BigNumber | bigint | Fraction | Array | Matrix} x Value to be tested
|
||||
* @return {boolean} Returns true when `x` contains a numeric, integer value.
|
||||
* Throws an error in case of an unknown data type.
|
||||
*/
|
||||
return typed(name, {
|
||||
number: _number.isInteger,
|
||||
// TODO: what to do with isInteger(add(0.1, 0.2)) ?
|
||||
|
||||
BigNumber: function (x) {
|
||||
return x.isInt();
|
||||
},
|
||||
bigint: function (x) {
|
||||
return true;
|
||||
},
|
||||
Fraction: function (x) {
|
||||
return x.d === 1 && isFinite(x.n);
|
||||
},
|
||||
'Array | Matrix': typed.referToSelf(self => x => (0, _collection.deepMap)(x, self))
|
||||
});
|
||||
});
|
||||
64
node_modules/mathjs/lib/cjs/function/utils/isNaN.js
generated
vendored
Normal file
64
node_modules/mathjs/lib/cjs/function/utils/isNaN.js
generated
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.createIsNaN = void 0;
|
||||
var _collection = require("../../utils/collection.js");
|
||||
var _factory = require("../../utils/factory.js");
|
||||
var _index = require("../../plain/number/index.js");
|
||||
const name = 'isNaN';
|
||||
const dependencies = ['typed'];
|
||||
const createIsNaN = exports.createIsNaN = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
|
||||
let {
|
||||
typed
|
||||
} = _ref;
|
||||
/**
|
||||
* Test whether a value is NaN (not a number).
|
||||
* The function supports types `number`, `BigNumber`, `Fraction`, `Unit` and `Complex`.
|
||||
*
|
||||
* The function is evaluated element-wise in case of Array or Matrix input.
|
||||
*
|
||||
* Syntax:
|
||||
*
|
||||
* math.isNaN(x)
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* math.isNaN(3) // returns false
|
||||
* math.isNaN(NaN) // returns true
|
||||
* math.isNaN(0) // returns false
|
||||
* math.isNaN(math.bignumber(NaN)) // returns true
|
||||
* math.isNaN(math.bignumber(0)) // returns false
|
||||
* math.isNaN(math.fraction(-2, 5)) // returns false
|
||||
* math.isNaN('-2') // returns false
|
||||
* math.isNaN([2, 0, -3, NaN]) // returns [false, false, false, true]
|
||||
*
|
||||
* See also:
|
||||
*
|
||||
* isNumeric, isNegative, isPositive, isZero, isInteger
|
||||
*
|
||||
* @param {number | BigNumber | bigint | Fraction | Unit | Array | Matrix} x Value to be tested
|
||||
* @return {boolean} Returns true when `x` is NaN.
|
||||
* Throws an error in case of an unknown data type.
|
||||
*/
|
||||
return typed(name, {
|
||||
number: _index.isNaNNumber,
|
||||
BigNumber: function (x) {
|
||||
return x.isNaN();
|
||||
},
|
||||
bigint: function (x) {
|
||||
return false;
|
||||
},
|
||||
Fraction: function (x) {
|
||||
return false;
|
||||
},
|
||||
Complex: function (x) {
|
||||
return x.isNaN();
|
||||
},
|
||||
Unit: function (x) {
|
||||
return Number.isNaN(x.value);
|
||||
},
|
||||
'Array | Matrix': typed.referToSelf(self => x => (0, _collection.deepMap)(x, self))
|
||||
});
|
||||
});
|
||||
58
node_modules/mathjs/lib/cjs/function/utils/isNegative.js
generated
vendored
Normal file
58
node_modules/mathjs/lib/cjs/function/utils/isNegative.js
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.createIsNegative = void 0;
|
||||
var _collection = require("../../utils/collection.js");
|
||||
var _factory = require("../../utils/factory.js");
|
||||
var _index = require("../../plain/number/index.js");
|
||||
var _nearlyEqual = require("../../utils/bignumber/nearlyEqual.js");
|
||||
var _number = require("../../utils/number.js");
|
||||
const name = 'isNegative';
|
||||
const dependencies = ['typed', 'config'];
|
||||
const createIsNegative = exports.createIsNegative = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
|
||||
let {
|
||||
typed,
|
||||
config
|
||||
} = _ref;
|
||||
/**
|
||||
* Test whether a value is negative: smaller than zero.
|
||||
* The function supports types `number`, `BigNumber`, `Fraction`, and `Unit`.
|
||||
*
|
||||
* The function is evaluated element-wise in case of Array or Matrix input.
|
||||
*
|
||||
* Syntax:
|
||||
*
|
||||
* math.isNegative(x)
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* math.isNegative(3) // returns false
|
||||
* math.isNegative(-2) // returns true
|
||||
* math.isNegative(0) // returns false
|
||||
* math.isNegative(-0) // returns false
|
||||
* math.isNegative(math.bignumber(2)) // returns false
|
||||
* math.isNegative(math.fraction(-2, 5)) // returns true
|
||||
* math.isNegative('-2') // returns true
|
||||
* math.isNegative([2, 0, -3]) // returns [false, false, true]
|
||||
*
|
||||
* See also:
|
||||
*
|
||||
* isNumeric, isPositive, isZero, isInteger
|
||||
*
|
||||
* @param {number | BigNumber | bigint | Fraction | Unit | Array | Matrix} x Value to be tested
|
||||
* @return {boolean} Returns true when `x` is larger than zero.
|
||||
* Throws an error in case of an unknown data type.
|
||||
*/
|
||||
return typed(name, {
|
||||
number: x => (0, _number.nearlyEqual)(x, 0, config.relTol, config.absTol) ? false : (0, _index.isNegativeNumber)(x),
|
||||
BigNumber: x => (0, _nearlyEqual.nearlyEqual)(x, new x.constructor(0), config.relTol, config.absTol) ? false : x.isNeg() && !x.isZero() && !x.isNaN(),
|
||||
bigint: x => x < 0n,
|
||||
Fraction: x => x.s < 0,
|
||||
// It's enough to decide on the sign
|
||||
|
||||
Unit: typed.referToSelf(self => x => typed.find(self, x.valueType())(x.value)),
|
||||
'Array | Matrix': typed.referToSelf(self => x => (0, _collection.deepMap)(x, self))
|
||||
});
|
||||
});
|
||||
50
node_modules/mathjs/lib/cjs/function/utils/isNumeric.js
generated
vendored
Normal file
50
node_modules/mathjs/lib/cjs/function/utils/isNumeric.js
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.createIsNumeric = void 0;
|
||||
var _collection = require("../../utils/collection.js");
|
||||
var _factory = require("../../utils/factory.js");
|
||||
const name = 'isNumeric';
|
||||
const dependencies = ['typed'];
|
||||
const createIsNumeric = exports.createIsNumeric = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
|
||||
let {
|
||||
typed
|
||||
} = _ref;
|
||||
/**
|
||||
* Test whether a value is an numeric value.
|
||||
*
|
||||
* The function is evaluated element-wise in case of Array or Matrix input.
|
||||
*
|
||||
* Syntax:
|
||||
*
|
||||
* math.isNumeric(x)
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* math.isNumeric(2) // returns true
|
||||
* math.isNumeric('2') // returns false
|
||||
* math.hasNumericValue('2') // returns true
|
||||
* math.isNumeric(0) // returns true
|
||||
* math.isNumeric(math.bignumber('42')) // returns true
|
||||
* math.isNumeric(math.bigint('42')) // returns true
|
||||
* math.isNumeric(math.fraction(4)) // returns true
|
||||
* math.isNumeric(math.complex('2-4i')) // returns false
|
||||
* math.isNumeric([2.3, 'foo', false]) // returns [true, false, true]
|
||||
*
|
||||
* See also:
|
||||
*
|
||||
* isZero, isPositive, isNegative, isInteger, hasNumericValue
|
||||
*
|
||||
* @param {*} x Value to be tested
|
||||
* @return {boolean} Returns true when `x` is a `number`, `BigNumber`,
|
||||
* `Fraction`, or `boolean`. Returns false for other types.
|
||||
* Throws an error in case of unknown types.
|
||||
*/
|
||||
return typed(name, {
|
||||
'number | BigNumber | bigint | Fraction | boolean': () => true,
|
||||
'Complex | Unit | string | null | undefined | Node': () => false,
|
||||
'Array | Matrix': typed.referToSelf(self => x => (0, _collection.deepMap)(x, self))
|
||||
});
|
||||
});
|
||||
58
node_modules/mathjs/lib/cjs/function/utils/isPositive.js
generated
vendored
Normal file
58
node_modules/mathjs/lib/cjs/function/utils/isPositive.js
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.createIsPositive = void 0;
|
||||
var _collection = require("../../utils/collection.js");
|
||||
var _factory = require("../../utils/factory.js");
|
||||
var _index = require("../../plain/number/index.js");
|
||||
var _nearlyEqual = require("../../utils/bignumber/nearlyEqual.js");
|
||||
var _number = require("../../utils/number.js");
|
||||
const name = 'isPositive';
|
||||
const dependencies = ['typed', 'config'];
|
||||
const createIsPositive = exports.createIsPositive = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
|
||||
let {
|
||||
typed,
|
||||
config
|
||||
} = _ref;
|
||||
/**
|
||||
* Test whether a value is positive: larger than zero.
|
||||
* The function supports types `number`, `BigNumber`, `Fraction`, and `Unit`.
|
||||
*
|
||||
* The function is evaluated element-wise in case of Array or Matrix input.
|
||||
*
|
||||
* Syntax:
|
||||
*
|
||||
* math.isPositive(x)
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* math.isPositive(3) // returns true
|
||||
* math.isPositive(-2) // returns false
|
||||
* math.isPositive(0) // returns false
|
||||
* math.isPositive(-0) // returns false
|
||||
* math.isPositive(0.5) // returns true
|
||||
* math.isPositive(math.bignumber(2)) // returns true
|
||||
* math.isPositive(math.fraction(-2, 5)) // returns false
|
||||
* math.isPositive(math.fraction(1, 3)) // returns true
|
||||
* math.isPositive('2') // returns true
|
||||
* math.isPositive([2, 0, -3]) // returns [true, false, false]
|
||||
*
|
||||
* See also:
|
||||
*
|
||||
* isNumeric, isZero, isNegative, isInteger
|
||||
*
|
||||
* @param {number | BigNumber | bigint | Fraction | Unit | Array | Matrix} x Value to be tested
|
||||
* @return {boolean} Returns true when `x` is larger than zero.
|
||||
* Throws an error in case of an unknown data type.
|
||||
*/
|
||||
return typed(name, {
|
||||
number: x => (0, _number.nearlyEqual)(x, 0, config.relTol, config.absTol) ? false : (0, _index.isPositiveNumber)(x),
|
||||
BigNumber: x => (0, _nearlyEqual.nearlyEqual)(x, new x.constructor(0), config.relTol, config.absTol) ? false : !x.isNeg() && !x.isZero() && !x.isNaN(),
|
||||
bigint: x => x > 0n,
|
||||
Fraction: x => x.s > 0 && x.n > 0,
|
||||
Unit: typed.referToSelf(self => x => typed.find(self, x.valueType())(x.value)),
|
||||
'Array | Matrix': typed.referToSelf(self => x => (0, _collection.deepMap)(x, self))
|
||||
});
|
||||
});
|
||||
136
node_modules/mathjs/lib/cjs/function/utils/isPrime.js
generated
vendored
Normal file
136
node_modules/mathjs/lib/cjs/function/utils/isPrime.js
generated
vendored
Normal file
@@ -0,0 +1,136 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.createIsPrime = void 0;
|
||||
var _collection = require("../../utils/collection.js");
|
||||
var _factory = require("../../utils/factory.js");
|
||||
const name = 'isPrime';
|
||||
const dependencies = ['typed'];
|
||||
const createIsPrime = exports.createIsPrime = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
|
||||
let {
|
||||
typed
|
||||
} = _ref;
|
||||
/**
|
||||
* Test whether a value is prime: has no divisors other than itself and one.
|
||||
* The function supports type `number`, `bignumber`.
|
||||
*
|
||||
* The function is evaluated element-wise in case of Array or Matrix input.
|
||||
*
|
||||
* Syntax:
|
||||
*
|
||||
* math.isPrime(x)
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* math.isPrime(3) // returns true
|
||||
* math.isPrime(-2) // returns false
|
||||
* math.isPrime(0) // returns false
|
||||
* math.isPrime(-0) // returns false
|
||||
* math.isPrime(0.5) // returns false
|
||||
* math.isPrime('2') // returns true
|
||||
* math.isPrime([2, 17, 100]) // returns [true, true, false]
|
||||
*
|
||||
* See also:
|
||||
*
|
||||
* isNumeric, isZero, isNegative, isInteger
|
||||
*
|
||||
* @param {number | BigNumber | bigint | Array | Matrix} x Value to be tested
|
||||
* @return {boolean} Returns true when `x` is larger than zero.
|
||||
* Throws an error in case of an unknown data type.
|
||||
*/
|
||||
return typed(name, {
|
||||
number: function (x) {
|
||||
if (x <= 3) {
|
||||
return x > 1;
|
||||
}
|
||||
if (x % 2 === 0 || x % 3 === 0) {
|
||||
return false;
|
||||
}
|
||||
for (let i = 5; i * i <= x; i += 6) {
|
||||
if (x % i === 0 || x % (i + 2) === 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
},
|
||||
bigint: function (x) {
|
||||
if (x <= 3n) {
|
||||
return x > 1n;
|
||||
}
|
||||
if (x % 2n === 0n || x % 3n === 0n) {
|
||||
return false;
|
||||
}
|
||||
for (let i = 5n; i * i <= x; i += 6n) {
|
||||
if (x % i === 0n || x % (i + 2n) === 0n) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
},
|
||||
BigNumber: function (n) {
|
||||
if (n.lte(3)) return n.gt(1);
|
||||
if (n.mod(2).eq(0) || n.mod(3).eq(0)) return false;
|
||||
if (n.lt(Math.pow(2, 32))) {
|
||||
const x = n.toNumber();
|
||||
for (let i = 5; i * i <= x; i += 6) {
|
||||
if (x % i === 0 || x % (i + 2) === 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
function modPow(base, exponent, modulus) {
|
||||
// exponent can be huge, use non-recursive variant
|
||||
let accumulator = 1;
|
||||
while (!exponent.eq(0)) {
|
||||
if (exponent.mod(2).eq(0)) {
|
||||
exponent = exponent.div(2);
|
||||
base = base.mul(base).mod(modulus);
|
||||
} else {
|
||||
exponent = exponent.sub(1);
|
||||
accumulator = base.mul(accumulator).mod(modulus);
|
||||
}
|
||||
}
|
||||
return accumulator;
|
||||
}
|
||||
|
||||
// https://en.wikipedia.org/wiki/Miller%E2%80%93Rabin_primality_test#Deterministic_variants
|
||||
const Decimal = n.constructor.clone({
|
||||
precision: n.toFixed(0).length * 2
|
||||
});
|
||||
n = new Decimal(n);
|
||||
let r = 0;
|
||||
let d = n.sub(1);
|
||||
while (d.mod(2).eq(0)) {
|
||||
d = d.div(2);
|
||||
r += 1;
|
||||
}
|
||||
let bases = null;
|
||||
// https://en.wikipedia.org/wiki/Miller–Rabin_primality_test#Testing_against_small_sets_of_bases
|
||||
if (n.lt('3317044064679887385961981')) {
|
||||
bases = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41].filter(x => x < n);
|
||||
} else {
|
||||
const max = Math.min(n.toNumber() - 2, Math.floor(2 * Math.pow(n.toFixed(0).length * Math.log(10), 2)));
|
||||
bases = [];
|
||||
for (let i = 2; i <= max; i += 1) {
|
||||
bases.push(max);
|
||||
}
|
||||
}
|
||||
for (let i = 0; i < bases.length; i += 1) {
|
||||
const a = bases[i];
|
||||
const adn = modPow(n.sub(n).add(a), d, n);
|
||||
if (!adn.eq(1)) {
|
||||
for (let i = 0, x = adn; !x.eq(n.sub(1)); i += 1, x = x.mul(x).mod(n)) {
|
||||
if (i === r - 1) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
},
|
||||
'Array | Matrix': typed.referToSelf(self => x => (0, _collection.deepMap)(x, self))
|
||||
});
|
||||
});
|
||||
55
node_modules/mathjs/lib/cjs/function/utils/isZero.js
generated
vendored
Normal file
55
node_modules/mathjs/lib/cjs/function/utils/isZero.js
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.createIsZero = void 0;
|
||||
var _collection = require("../../utils/collection.js");
|
||||
var _factory = require("../../utils/factory.js");
|
||||
const name = 'isZero';
|
||||
const dependencies = ['typed', 'equalScalar'];
|
||||
const createIsZero = exports.createIsZero = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
|
||||
let {
|
||||
typed,
|
||||
equalScalar
|
||||
} = _ref;
|
||||
/**
|
||||
* Test whether a value is zero.
|
||||
* The function can check for zero for types `number`, `BigNumber`, `Fraction`,
|
||||
* `Complex`, and `Unit`.
|
||||
*
|
||||
* The function is evaluated element-wise in case of Array or Matrix input.
|
||||
*
|
||||
* Syntax:
|
||||
*
|
||||
* math.isZero(x)
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* math.isZero(0) // returns true
|
||||
* math.isZero(2) // returns false
|
||||
* math.isZero(0.5) // returns false
|
||||
* math.isZero(math.bignumber(0)) // returns true
|
||||
* math.isZero(math.fraction(0)) // returns true
|
||||
* math.isZero(math.fraction(1,3)) // returns false
|
||||
* math.isZero(math.complex('2 - 4i')) // returns false
|
||||
* math.isZero(math.complex('0i')) // returns true
|
||||
* math.isZero('0') // returns true
|
||||
* math.isZero('2') // returns false
|
||||
* math.isZero([2, 0, -3]) // returns [false, true, false]
|
||||
*
|
||||
* See also:
|
||||
*
|
||||
* isNumeric, isPositive, isNegative, isInteger
|
||||
*
|
||||
* @param {number | BigNumber | bigint | Complex | Fraction | Unit | Array | Matrix} x Value to be tested
|
||||
* @return {boolean} Returns true when `x` is zero.
|
||||
* Throws an error in case of an unknown data type.
|
||||
*/
|
||||
return typed(name, {
|
||||
'number | BigNumber | Complex | Fraction': x => equalScalar(x, 0),
|
||||
bigint: x => x === 0n,
|
||||
Unit: typed.referToSelf(self => x => typed.find(self, x.valueType())(x.value)),
|
||||
'Array | Matrix': typed.referToSelf(self => x => (0, _collection.deepMap)(x, self))
|
||||
});
|
||||
});
|
||||
81
node_modules/mathjs/lib/cjs/function/utils/numeric.js
generated
vendored
Normal file
81
node_modules/mathjs/lib/cjs/function/utils/numeric.js
generated
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.createNumeric = void 0;
|
||||
var _is = require("../../utils/is.js");
|
||||
var _factory = require("../../utils/factory.js");
|
||||
var _noop = require("../../utils/noop.js");
|
||||
const name = 'numeric';
|
||||
const dependencies = ['number', '?bignumber', '?fraction'];
|
||||
const createNumeric = exports.createNumeric = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
|
||||
let {
|
||||
number,
|
||||
bignumber,
|
||||
fraction
|
||||
} = _ref;
|
||||
const validInputTypes = {
|
||||
string: true,
|
||||
number: true,
|
||||
BigNumber: true,
|
||||
Fraction: true
|
||||
};
|
||||
|
||||
// Load the conversion functions for each output type
|
||||
const validOutputTypes = {
|
||||
number: x => number(x),
|
||||
BigNumber: bignumber ? x => bignumber(x) : _noop.noBignumber,
|
||||
bigint: x => BigInt(x),
|
||||
Fraction: fraction ? x => fraction(x) : _noop.noFraction
|
||||
};
|
||||
|
||||
/**
|
||||
* Convert a numeric input to a specific numeric type: number, BigNumber, bigint, or Fraction.
|
||||
*
|
||||
* Syntax:
|
||||
*
|
||||
* math.numeric(x)
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* math.numeric('4') // returns 4
|
||||
* math.numeric('4', 'number') // returns 4
|
||||
* math.numeric('4', 'bigint') // returns 4n
|
||||
* math.numeric('4', 'BigNumber') // returns BigNumber 4
|
||||
* math.numeric('4', 'Fraction') // returns Fraction 4
|
||||
* math.numeric(4, 'Fraction') // returns Fraction 4
|
||||
* math.numeric(math.fraction(2, 5), 'number') // returns 0.4
|
||||
*
|
||||
* See also:
|
||||
*
|
||||
* number, fraction, bignumber, bigint, string, format
|
||||
*
|
||||
* @param {string | number | BigNumber | bigint | Fraction } value
|
||||
* A numeric value or a string containing a numeric value
|
||||
* @param {string} outputType
|
||||
* Desired numeric output type.
|
||||
* Available values: 'number', 'BigNumber', or 'Fraction'
|
||||
* @return {number | BigNumber | bigint | Fraction}
|
||||
* Returns an instance of the numeric in the requested type
|
||||
*/
|
||||
return function numeric(value) {
|
||||
let outputType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'number';
|
||||
let check = arguments.length > 2 ? arguments[2] : undefined;
|
||||
if (check !== undefined) {
|
||||
throw new SyntaxError('numeric() takes one or two arguments');
|
||||
}
|
||||
const inputType = (0, _is.typeOf)(value);
|
||||
if (!(inputType in validInputTypes)) {
|
||||
throw new TypeError('Cannot convert ' + value + ' of type "' + inputType + '"; valid input types are ' + Object.keys(validInputTypes).join(', '));
|
||||
}
|
||||
if (!(outputType in validOutputTypes)) {
|
||||
throw new TypeError('Cannot convert ' + value + ' to type "' + outputType + '"; valid output types are ' + Object.keys(validOutputTypes).join(', '));
|
||||
}
|
||||
if (outputType === inputType) {
|
||||
return value;
|
||||
} else {
|
||||
return validOutputTypes[outputType](value);
|
||||
}
|
||||
};
|
||||
});
|
||||
71
node_modules/mathjs/lib/cjs/function/utils/typeOf.js
generated
vendored
Normal file
71
node_modules/mathjs/lib/cjs/function/utils/typeOf.js
generated
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.createTypeOf = void 0;
|
||||
var _factory = require("../../utils/factory.js");
|
||||
var _is = require("../../utils/is.js");
|
||||
const name = 'typeOf';
|
||||
const dependencies = ['typed'];
|
||||
const createTypeOf = exports.createTypeOf = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
|
||||
let {
|
||||
typed
|
||||
} = _ref;
|
||||
/**
|
||||
* Determine the type of an entity.
|
||||
*
|
||||
* Syntax:
|
||||
*
|
||||
* math.typeOf(x)
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* // This list is intended to include all relevant types, for testing
|
||||
* // purposes:
|
||||
* math.typeOf(3.5) // returns 'number'
|
||||
* math.typeOf(42n) // returns 'bigint'
|
||||
* math.typeOf(math.complex('2-4i')) // returns 'Complex'
|
||||
* math.typeOf(math.unit('45 deg')) // returns 'Unit'
|
||||
* math.typeOf('hello world') // returns 'string'
|
||||
* math.typeOf(null) // returns 'null'
|
||||
* math.typeOf(true) // returns 'boolean'
|
||||
* math.typeOf([1, 2, 3]) // returns 'Array'
|
||||
* math.typeOf(new Date()) // returns 'Date'
|
||||
* math.typeOf(function () {}) // returns 'function'
|
||||
* math.typeOf({a: 2, b: 3}) // returns 'Object'
|
||||
* math.typeOf(/a regexp/) // returns 'RegExp'
|
||||
* math.typeOf(undefined) // returns 'undefined'
|
||||
* math.typeOf(math.bignumber('23e99')) // returns 'BigNumber'
|
||||
* math.typeOf(math.chain(2)) // returns 'Chain'
|
||||
* math.typeOf(math.fraction(1, 3)) // returns 'Fraction'
|
||||
* math.typeOf(math.help('sqrt')) // returns 'Help'
|
||||
* math.typeOf(math.index(1, 3)) // returns 'Index'
|
||||
* math.typeOf(math.matrix([[1],[3]])) // returns 'DenseMatrix'
|
||||
* math.typeOf(math.matrix([],'sparse')) // returns 'SparseMatrix'
|
||||
* math.typeOf(new math.Range(0, 10)) // returns 'Range'
|
||||
* math.typeOf(math.evaluate('a=2\na')) // returns 'ResultSet'
|
||||
* math.typeOf(math.parse('A[2]')) // returns 'AccessorNode'
|
||||
* math.typeOf(math.parse('[1,2,3]')) // returns 'ArrayNode'
|
||||
* math.typeOf(math.parse('x=2')) // returns 'AssignmentNode'
|
||||
* math.typeOf(math.parse('a=2; b=3')) // returns 'BlockNode'
|
||||
* math.typeOf(math.parse('x<0?-1:1')) // returns 'ConditionalNode'
|
||||
* math.typeOf(math.parse('2.3')) // returns 'ConstantNode'
|
||||
* math.typeOf(math.parse('f(x)=x^2')) // returns 'FunctionAssignmentNode'
|
||||
* math.typeOf(math.parse('sqrt(4)')) // returns 'FunctionNode'
|
||||
* math.typeOf(math.parse('A[2]').index) // returns 'IndexNode'
|
||||
* math.typeOf(math.parse('{a:2}')) // returns 'ObjectNode'
|
||||
* math.typeOf(math.parse('(2+3)')) // returns 'ParenthesisNode'
|
||||
* math.typeOf(math.parse('1:10')) // returns 'RangeNode'
|
||||
* math.typeOf(math.parse('a<b<c')) // returns 'RelationalNode'
|
||||
* math.typeOf(math.parse('x')) // returns 'SymbolNode'
|
||||
*
|
||||
* @param {*} x The variable for which to test the type.
|
||||
* @return {string} Returns the name of the type. Primitive types are lower case,
|
||||
* non-primitive types are upper-camel-case.
|
||||
* For example 'number', 'string', 'Array', 'Date'.
|
||||
*/
|
||||
return typed(name, {
|
||||
any: _is.typeOf
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user