mathjs 11.0.0 → 11.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTRIBUTING.md +1 -4
- package/HISTORY.md +27 -0
- package/lib/browser/math.js +1 -1
- package/lib/browser/math.js.LICENSE.txt +2 -2
- package/lib/browser/math.js.map +1 -1
- package/lib/cjs/core/create.js +1 -0
- package/lib/cjs/core/function/typed.js +3 -0
- package/lib/cjs/entry/typeChecks.js +6 -0
- package/lib/cjs/expression/embeddedDocs/construction/index.js +1 -1
- package/lib/cjs/function/algebra/derivative.js +3 -3
- package/lib/cjs/function/algebra/simplify.js +3 -1
- package/lib/cjs/function/algebra/symbolicEqual.js +5 -6
- package/lib/cjs/function/arithmetic/fix.js +1 -1
- package/lib/cjs/function/arithmetic/floor.js +1 -1
- package/lib/cjs/function/arithmetic/invmod.js +1 -1
- package/lib/cjs/function/arithmetic/nthRoot.js +3 -3
- package/lib/cjs/function/arithmetic/nthRoots.js +2 -2
- package/lib/cjs/function/bitwise/bitNot.js +1 -1
- package/lib/cjs/function/bitwise/leftShift.js +1 -1
- package/lib/cjs/function/bitwise/rightArithShift.js +1 -1
- package/lib/cjs/function/bitwise/rightLogShift.js +1 -1
- package/lib/cjs/function/geometry/distance.js +2 -2
- package/lib/cjs/function/matrix/diff.js +1 -1
- package/lib/cjs/function/matrix/rotate.js +5 -5
- package/lib/cjs/function/string/format.js +2 -2
- package/lib/cjs/function/string/hex.js +1 -2
- package/lib/cjs/function/trigonometry/acot.js +2 -3
- package/lib/cjs/function/trigonometry/acsc.js +2 -3
- package/lib/cjs/function/trigonometry/asec.js +2 -2
- package/lib/cjs/function/trigonometry/asin.js +1 -1
- package/lib/cjs/function/trigonometry/atan.js +1 -2
- package/lib/cjs/function/trigonometry/atan2.js +1 -1
- package/lib/cjs/function/utils/clone.js +1 -1
- package/lib/cjs/function/utils/hasNumericValue.js +1 -1
- package/lib/cjs/function/utils/isInteger.js +1 -1
- package/lib/cjs/function/utils/isNaN.js +1 -1
- package/lib/cjs/function/utils/isNegative.js +1 -1
- package/lib/cjs/function/utils/isNumeric.js +1 -1
- package/lib/cjs/function/utils/isPositive.js +1 -1
- package/lib/cjs/function/utils/isZero.js +11 -11
- package/lib/cjs/header.js +2 -2
- package/lib/cjs/type/unit/Unit.js +30 -25
- package/lib/cjs/type/unit/function/unit.js +5 -2
- package/lib/cjs/utils/is.js +5 -0
- package/lib/cjs/version.js +1 -1
- package/lib/esm/core/create.js +2 -1
- package/lib/esm/core/function/typed.js +4 -1
- package/lib/esm/entry/typeChecks.js +1 -1
- package/lib/esm/expression/embeddedDocs/construction/index.js +1 -1
- package/lib/esm/function/algebra/derivative.js +3 -3
- package/lib/esm/function/algebra/simplify.js +3 -1
- package/lib/esm/function/algebra/symbolicEqual.js +5 -6
- package/lib/esm/function/arithmetic/fix.js +1 -1
- package/lib/esm/function/arithmetic/floor.js +1 -1
- package/lib/esm/function/arithmetic/invmod.js +1 -1
- package/lib/esm/function/arithmetic/nthRoot.js +3 -3
- package/lib/esm/function/arithmetic/nthRoots.js +2 -2
- package/lib/esm/function/bitwise/bitNot.js +1 -1
- package/lib/esm/function/bitwise/leftShift.js +1 -1
- package/lib/esm/function/bitwise/rightArithShift.js +1 -1
- package/lib/esm/function/bitwise/rightLogShift.js +1 -1
- package/lib/esm/function/geometry/distance.js +2 -2
- package/lib/esm/function/matrix/diff.js +1 -1
- package/lib/esm/function/matrix/rotate.js +5 -5
- package/lib/esm/function/string/format.js +2 -2
- package/lib/esm/function/string/hex.js +1 -2
- package/lib/esm/function/trigonometry/acot.js +2 -3
- package/lib/esm/function/trigonometry/acsc.js +2 -3
- package/lib/esm/function/trigonometry/asec.js +2 -2
- package/lib/esm/function/trigonometry/asin.js +1 -1
- package/lib/esm/function/trigonometry/atan.js +1 -2
- package/lib/esm/function/trigonometry/atan2.js +1 -1
- package/lib/esm/function/utils/clone.js +1 -1
- package/lib/esm/function/utils/hasNumericValue.js +1 -1
- package/lib/esm/function/utils/isInteger.js +1 -1
- package/lib/esm/function/utils/isNaN.js +1 -1
- package/lib/esm/function/utils/isNegative.js +1 -1
- package/lib/esm/function/utils/isNumeric.js +1 -1
- package/lib/esm/function/utils/isPositive.js +1 -1
- package/lib/esm/function/utils/isZero.js +11 -11
- package/lib/esm/type/unit/Unit.js +25 -24
- package/lib/esm/type/unit/function/unit.js +5 -2
- package/lib/esm/utils/is.js +3 -0
- package/lib/esm/version.js +1 -1
- package/package.json +17 -18
- package/types/index.d.ts +33 -19
- package/types/index.ts +123 -95
- package/types/tsconfig.json +4 -1
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
* @param {Object<string, function>} signatures Object with one or multiple function signatures
|
|
36
36
|
* @returns {function} The created typed-function.
|
|
37
37
|
*/
|
|
38
|
-
import { isAccessorNode, isArray, isArrayNode, isAssignmentNode, isBigNumber, isBlockNode, isBoolean, isChain, isCollection, isComplex, isConditionalNode, isConstantNode, isDate, isDenseMatrix, isFraction, isFunction, isFunctionAssignmentNode, isFunctionNode, isHelp, isIndex, isIndexNode, isMatrix, isNode, isNull, isNumber, isObject, isObjectNode, isOperatorNode, isParenthesisNode, isRange, isRangeNode, isRegExp, isResultSet, isSparseMatrix, isString, isSymbolNode, isUndefined, isUnit } from '../../utils/is.js';
|
|
38
|
+
import { isAccessorNode, isArray, isArrayNode, isAssignmentNode, isBigNumber, isBlockNode, isBoolean, isChain, isCollection, isComplex, isConditionalNode, isConstantNode, isDate, isDenseMatrix, isFraction, isFunction, isFunctionAssignmentNode, isFunctionNode, isHelp, isIndex, isIndexNode, isMatrix, isNode, isNull, isNumber, isObject, isObjectNode, isOperatorNode, isParenthesisNode, isRange, isRangeNode, isRelationalNode, isRegExp, isResultSet, isSparseMatrix, isString, isSymbolNode, isUndefined, isUnit } from '../../utils/is.js';
|
|
39
39
|
import typedFunction from 'typed-function';
|
|
40
40
|
import { digits } from '../../utils/number.js';
|
|
41
41
|
import { factory } from '../../utils/factory.js';
|
|
@@ -183,6 +183,9 @@ export var createTyped = /* #__PURE__ */factory('typed', dependencies, function
|
|
|
183
183
|
}, {
|
|
184
184
|
name: 'RangeNode',
|
|
185
185
|
test: isRangeNode
|
|
186
|
+
}, {
|
|
187
|
+
name: 'RelationalNode',
|
|
188
|
+
test: isRelationalNode
|
|
186
189
|
}, {
|
|
187
190
|
name: 'SymbolNode',
|
|
188
191
|
test: isSymbolNode
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// util functions
|
|
2
|
-
export { isAccessorNode, isArray, isArrayNode, isAssignmentNode, isBigNumber, isBlockNode, isBoolean, isChain, isCollection, isComplex, isConditionalNode, isConstantNode, isDate, isDenseMatrix, isFraction, isFunction, isFunctionAssignmentNode, isFunctionNode, isHelp, isIndex, isIndexNode, isMatrix, isNode, isNull, isNumber, isString, isUndefined, isObject, isObjectNode, isOperatorNode, isParenthesisNode, isRange, isRangeNode, isRegExp, isResultSet, isSparseMatrix, isSymbolNode, isUnit } from '../utils/is.js';
|
|
2
|
+
export { isAccessorNode, isArray, isArrayNode, isAssignmentNode, isBigNumber, isBlockNode, isBoolean, isChain, isCollection, isComplex, isConditionalNode, isConstantNode, isDate, isDenseMatrix, isFraction, isFunction, isFunctionAssignmentNode, isFunctionNode, isHelp, isIndex, isIndexNode, isMatrix, isNode, isNull, isNumber, isString, isUndefined, isObject, isObjectNode, isOperatorNode, isParenthesisNode, isRange, isRangeNode, isRelationalNode, isRegExp, isResultSet, isSparseMatrix, isSymbolNode, isUnit } from '../utils/is.js';
|
|
@@ -3,6 +3,6 @@ export var indexDocs = {
|
|
|
3
3
|
category: 'Construction',
|
|
4
4
|
syntax: ['[start]', '[start:end]', '[start:step:end]', '[start1, start 2, ...]', '[start1:end1, start2:end2, ...]', '[start1:step1:end1, start2:step2:end2, ...]'],
|
|
5
5
|
description: 'Create an index to get or replace a subset of a matrix',
|
|
6
|
-
examples: ['[
|
|
6
|
+
examples: ['[1, 2, 3]', 'A = [1, 2, 3; 4, 5, 6]', 'A[1, :]', 'A[1, 2] = 50', 'A[1:2, 1:2] = ones(2, 2)'],
|
|
7
7
|
seealso: ['bignumber', 'boolean', 'complex', 'matrix,', 'number', 'range', 'string', 'unit']
|
|
8
8
|
};
|
|
@@ -35,9 +35,9 @@ export var createDerivative = /* #__PURE__ */factory(name, dependencies, _ref =>
|
|
|
35
35
|
*
|
|
36
36
|
* Examples:
|
|
37
37
|
*
|
|
38
|
-
* math.derivative('x^2', 'x') // Node
|
|
39
|
-
* math.derivative('x^2', 'x', {simplify: false}) // Node
|
|
40
|
-
* math.derivative('sin(2x)', 'x')) // Node
|
|
38
|
+
* math.derivative('x^2', 'x') // Node '2 * x'
|
|
39
|
+
* math.derivative('x^2', 'x', {simplify: false}) // Node '2 * 1 * x ^ (2 - 1)'
|
|
40
|
+
* math.derivative('sin(2x)', 'x')) // Node '2 * cos(2 * x)'
|
|
41
41
|
* math.derivative('2*x', 'x').evaluate() // number 2
|
|
42
42
|
* math.derivative('x^2', 'x').evaluate({x: 4}) // number 8
|
|
43
43
|
* const f = math.parse('x^2')
|
|
@@ -153,8 +153,10 @@ export var createSimplify = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
|
153
153
|
*
|
|
154
154
|
* @param {Node | string} expr
|
|
155
155
|
* The expression to be simplified
|
|
156
|
-
* @param {
|
|
156
|
+
* @param {SimplifyRule[]} [rules]
|
|
157
157
|
* Optional list with custom rules
|
|
158
|
+
* @param {Object} [scope] Optional scope with variables
|
|
159
|
+
* @param {SimplifyOptions} [options] Optional configuration settings
|
|
158
160
|
* @return {Node} Returns the simplified form of `expr`
|
|
159
161
|
*/
|
|
160
162
|
|
|
@@ -31,12 +31,11 @@ export var createSymbolicEqual = /* #__PURE__ */factory(name, dependencies, _ref
|
|
|
31
31
|
*
|
|
32
32
|
* Examples:
|
|
33
33
|
*
|
|
34
|
-
* symbolicEqual('x*y', 'y*x') // true
|
|
35
|
-
* symbolicEqual('x*y', 'y*x', {context: {multiply: {commutative: false}}})
|
|
36
|
-
*
|
|
37
|
-
* symbolicEqual('x
|
|
38
|
-
* symbolicEqual('abs(x)','x') //
|
|
39
|
-
* symbolicEqual('abs(x)','x', simplify.positiveContext) // true
|
|
34
|
+
* symbolicEqual('x*y', 'y*x') // Returns true
|
|
35
|
+
* symbolicEqual('x*y', 'y*x', {context: {multiply: {commutative: false}}}) // Returns false
|
|
36
|
+
* symbolicEqual('x/y', '(y*x^(-1))^(-1)') // Returns true
|
|
37
|
+
* symbolicEqual('abs(x)','x') // Returns false
|
|
38
|
+
* symbolicEqual('abs(x)','x', simplify.positiveContext) // Returns true
|
|
40
39
|
*
|
|
41
40
|
* See also:
|
|
42
41
|
*
|
|
@@ -65,7 +65,7 @@ export var createFix = /* #__PURE__ */factory(name, dependencies, _ref2 => {
|
|
|
65
65
|
*
|
|
66
66
|
* const c = math.complex(3.22, -2.78)
|
|
67
67
|
* math.fix(c) // returns Complex 3 - 2i
|
|
68
|
-
* math.fix(c, 1) // returns Complex 3.2 -
|
|
68
|
+
* math.fix(c, 1) // returns Complex 3.2 -2.7i
|
|
69
69
|
*
|
|
70
70
|
* math.fix([3.2, 3.8, -4.7]) // returns Array [3, 3, -4]
|
|
71
71
|
* math.fix([3.2, 3.8, -4.7], 1) // returns Array [3.2, 3.8, -4.7]
|
|
@@ -83,7 +83,7 @@ export var createFloor = /* #__PURE__ */factory(name, dependencies, _ref2 => {
|
|
|
83
83
|
*
|
|
84
84
|
* const c = math.complex(3.24, -2.71)
|
|
85
85
|
* math.floor(c) // returns Complex 3 - 3i
|
|
86
|
-
* math.floor(c, 1) // returns Complex 3.2 -
|
|
86
|
+
* math.floor(c, 1) // returns Complex 3.2 -2.8i
|
|
87
87
|
*
|
|
88
88
|
* math.floor([3.2, 3.8, -4.7]) // returns Array [3, 3, -5]
|
|
89
89
|
* math.floor([3.21, 3.82, -4.71], 1) // returns Array [3.2, 3.8, -4.8]
|
|
@@ -25,7 +25,7 @@ export var createInvmod = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
|
25
25
|
* Examples:
|
|
26
26
|
*
|
|
27
27
|
* math.invmod(8, 12) // returns NaN
|
|
28
|
-
* math.invmod(7, 13) //
|
|
28
|
+
* math.invmod(7, 13) // returns 2
|
|
29
29
|
* math.invmod(15151, 15122) // returns 10429
|
|
30
30
|
*
|
|
31
31
|
* See also:
|
|
@@ -49,9 +49,9 @@ export var createNthRoot = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
|
49
49
|
*
|
|
50
50
|
* Examples:
|
|
51
51
|
*
|
|
52
|
-
* math.nthRoot(9, 2) // returns 3
|
|
53
|
-
* math.sqrt(9) // returns 3
|
|
54
|
-
* math.nthRoot(64, 3) // returns 4
|
|
52
|
+
* math.nthRoot(9, 2) // returns 3 (since 3^2 == 9)
|
|
53
|
+
* math.sqrt(9) // returns 3 (since 3^2 == 9)
|
|
54
|
+
* math.nthRoot(64, 3) // returns 4 (since 4^3 == 64)
|
|
55
55
|
*
|
|
56
56
|
* See also:
|
|
57
57
|
*
|
|
@@ -92,12 +92,12 @@ export var createNthRoots = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
|
92
92
|
* // {re: 1, im: 0},
|
|
93
93
|
* // {re: -1, im: 0}
|
|
94
94
|
* // ]
|
|
95
|
-
* nthRoots(1, 3)
|
|
95
|
+
* math.nthRoots(1, 3)
|
|
96
96
|
* // returns [
|
|
97
97
|
* // { re: 1, im: 0 },
|
|
98
98
|
* // { re: -0.4999999999999998, im: 0.8660254037844387 },
|
|
99
99
|
* // { re: -0.5000000000000004, im: -0.8660254037844385 }
|
|
100
|
-
* ]
|
|
100
|
+
* // ]
|
|
101
101
|
*
|
|
102
102
|
* See also:
|
|
103
103
|
*
|
|
@@ -22,7 +22,7 @@ export var createBitNot = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
|
22
22
|
*
|
|
23
23
|
* math.bitNot(1) // returns number -2
|
|
24
24
|
*
|
|
25
|
-
* math.bitNot([2, -3, 4]) // returns Array [-3, 2, 5]
|
|
25
|
+
* math.bitNot([2, -3, 4]) // returns Array [-3, 2, -5]
|
|
26
26
|
*
|
|
27
27
|
* See also:
|
|
28
28
|
*
|
|
@@ -62,7 +62,7 @@ export var createLeftShift = /* #__PURE__ */factory(name, dependencies, _ref =>
|
|
|
62
62
|
*
|
|
63
63
|
* math.leftShift(1, 2) // returns number 4
|
|
64
64
|
*
|
|
65
|
-
* math.leftShift([1, 2,
|
|
65
|
+
* math.leftShift([1, 2, 4], 4) // returns Array [16, 32, 64]
|
|
66
66
|
*
|
|
67
67
|
* See also:
|
|
68
68
|
*
|
|
@@ -62,7 +62,7 @@ export var createRightArithShift = /* #__PURE__ */factory(name, dependencies, _r
|
|
|
62
62
|
*
|
|
63
63
|
* math.rightArithShift(4, 2) // returns number 1
|
|
64
64
|
*
|
|
65
|
-
* math.rightArithShift([16, -32, 64], 4) // returns Array [1, -2,
|
|
65
|
+
* math.rightArithShift([16, -32, 64], 4) // returns Array [1, -2, 4]
|
|
66
66
|
*
|
|
67
67
|
* See also:
|
|
68
68
|
*
|
|
@@ -61,7 +61,7 @@ export var createRightLogShift = /* #__PURE__ */factory(name, dependencies, _ref
|
|
|
61
61
|
*
|
|
62
62
|
* math.rightLogShift(4, 2) // returns number 1
|
|
63
63
|
*
|
|
64
|
-
* math.rightLogShift([16,
|
|
64
|
+
* math.rightLogShift([16, 32, 64], 4) // returns Array [1, 2, 4]
|
|
65
65
|
*
|
|
66
66
|
* See also:
|
|
67
67
|
*
|
|
@@ -41,11 +41,11 @@ export var createDistance = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
|
41
41
|
* math.distance({pointX: 2, pointY: 5, pointZ: 9}, {x0: 4, y0: 6, z0: 3, a: 4, b: 2, c: 0})
|
|
42
42
|
*
|
|
43
43
|
* Examples:
|
|
44
|
-
* math.distance([0,0], [4,4]) // Returns 5.
|
|
44
|
+
* math.distance([0,0], [4,4]) // Returns 5.656854249492381
|
|
45
45
|
* math.distance(
|
|
46
46
|
* {pointOneX: 0, pointOneY: 0},
|
|
47
47
|
* {pointTwoX: 10, pointTwoY: 10}) // Returns 14.142135623730951
|
|
48
|
-
* math.distance([1, 0, 1], [4, -2, 2]) // Returns 3.
|
|
48
|
+
* math.distance([1, 0, 1], [4, -2, 2]) // Returns 3.7416573867739413
|
|
49
49
|
* math.distance(
|
|
50
50
|
* {pointOneX: 4, pointOneY: 5, pointOneZ: 8},
|
|
51
51
|
* {pointTwoX: 2, pointTwoY: 7, pointTwoZ: 9}) // Returns 3
|
|
@@ -29,7 +29,7 @@ export var createDiff = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
|
29
29
|
*
|
|
30
30
|
* const arr = [1, 2, 4, 7, 0]
|
|
31
31
|
* math.diff(arr) // returns [1, 2, 3, -7] (no dimension passed so 0 is assumed)
|
|
32
|
-
* math.diff(math.matrix(arr)) // returns
|
|
32
|
+
* math.diff(math.matrix(arr)) // returns Matrix [1, 2, 3, -7]
|
|
33
33
|
*
|
|
34
34
|
* const arr = [[1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [9, 8, 7, 6, 4]]
|
|
35
35
|
* math.diff(arr) // returns [[0, 0, 0, 0, 0], [8, 6, 4, 2, -1]]
|
|
@@ -20,13 +20,13 @@ export var createRotate = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
|
20
20
|
*
|
|
21
21
|
* Examples:
|
|
22
22
|
*
|
|
23
|
-
* math.rotate([11, 12], math.pi / 2) // returns
|
|
24
|
-
* math.rotate(matrix([11, 12]), math.pi / 2) // returns
|
|
23
|
+
* math.rotate([11, 12], math.pi / 2) // returns [-12, 11]
|
|
24
|
+
* math.rotate(matrix([11, 12]), math.pi / 2) // returns [-12, 11]
|
|
25
25
|
*
|
|
26
|
-
* math.rotate([1, 0, 0], unit('90deg'), [0, 0, 1]) // returns
|
|
27
|
-
* math.rotate(matrix([1, 0, 0]), unit('90deg'), [0, 0, 1]) // returns
|
|
26
|
+
* math.rotate([1, 0, 0], unit('90deg'), [0, 0, 1]) // returns [0, 1, 0]
|
|
27
|
+
* math.rotate(matrix([1, 0, 0]), unit('90deg'), [0, 0, 1]) // returns Matrix [0, 1, 0]
|
|
28
28
|
*
|
|
29
|
-
* math.rotate([1, 0], math.complex(1 + i)) // returns
|
|
29
|
+
* math.rotate([1, 0], math.complex(1 + i)) // returns [cos(1 + i) - sin(1 + i), sin(1 + i) + cos(1 + i)]
|
|
30
30
|
*
|
|
31
31
|
* See also:
|
|
32
32
|
*
|
|
@@ -98,14 +98,14 @@ export var createFormat = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
|
98
98
|
* Examples:
|
|
99
99
|
*
|
|
100
100
|
* math.format(6.4) // returns '6.4'
|
|
101
|
-
* math.format(1240000) // returns '1.
|
|
101
|
+
* math.format(1240000) // returns '1.24e+6'
|
|
102
102
|
* math.format(1/3) // returns '0.3333333333333333'
|
|
103
103
|
* math.format(1/3, 3) // returns '0.333'
|
|
104
104
|
* math.format(21385, 2) // returns '21000'
|
|
105
105
|
* math.format(12e8, {notation: 'fixed'}) // returns '1200000000'
|
|
106
106
|
* math.format(2.3, {notation: 'fixed', precision: 4}) // returns '2.3000'
|
|
107
107
|
* math.format(52.8, {notation: 'exponential'}) // returns '5.28e+1'
|
|
108
|
-
* math.format(12400,{notation: 'engineering'})
|
|
108
|
+
* math.format(12400, {notation: 'engineering'}) // returns '12.4e+3'
|
|
109
109
|
* math.format(2000, {lowerExp: -2, upperExp: 2}) // returns '2e+3'
|
|
110
110
|
*
|
|
111
111
|
* function formatCurrency(value) {
|
|
@@ -20,11 +20,10 @@ export var createAcot = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
|
20
20
|
*
|
|
21
21
|
* Examples:
|
|
22
22
|
*
|
|
23
|
-
* math.acot(0.5) // returns number
|
|
23
|
+
* math.acot(0.5) // returns number 1.1071487177940904
|
|
24
|
+
* math.acot(2) // returns number 0.4636476090008061
|
|
24
25
|
* math.acot(math.cot(1.5)) // returns number 1.5
|
|
25
26
|
*
|
|
26
|
-
* math.acot(2) // returns Complex 1.5707963267948966 -1.3169578969248166 i
|
|
27
|
-
*
|
|
28
27
|
* See also:
|
|
29
28
|
*
|
|
30
29
|
* cot, atan
|
|
@@ -22,11 +22,10 @@ export var createAcsc = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
|
22
22
|
*
|
|
23
23
|
* Examples:
|
|
24
24
|
*
|
|
25
|
-
* math.acsc(
|
|
25
|
+
* math.acsc(2) // returns 0.5235987755982989
|
|
26
|
+
* math.acsc(0.5) // returns Complex 1.5707963267948966 -1.3169578969248166i
|
|
26
27
|
* math.acsc(math.csc(1.5)) // returns number ~1.5
|
|
27
28
|
*
|
|
28
|
-
* math.acsc(2) // returns Complex 1.5707963267948966 -1.3169578969248166 i
|
|
29
|
-
*
|
|
30
29
|
* See also:
|
|
31
30
|
*
|
|
32
31
|
* csc, asin, asec
|
|
@@ -22,10 +22,10 @@ export var createAsec = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
|
22
22
|
*
|
|
23
23
|
* Examples:
|
|
24
24
|
*
|
|
25
|
-
* math.asec(
|
|
25
|
+
* math.asec(2) // returns 1.0471975511965979
|
|
26
26
|
* math.asec(math.sec(1.5)) // returns 1.5
|
|
27
27
|
*
|
|
28
|
-
* math.asec(
|
|
28
|
+
* math.asec(0.5) // returns Complex 0 + 1.3169578969248166i
|
|
29
29
|
*
|
|
30
30
|
* See also:
|
|
31
31
|
*
|
|
@@ -23,7 +23,7 @@ export var createAsin = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
|
23
23
|
* math.asin(0.5) // returns number 0.5235987755982989
|
|
24
24
|
* math.asin(math.sin(1.5)) // returns number ~1.5
|
|
25
25
|
*
|
|
26
|
-
* math.asin(2) // returns Complex 1.5707963267948966 -1.
|
|
26
|
+
* math.asin(2) // returns Complex 1.5707963267948966 -1.3169578969248166i
|
|
27
27
|
*
|
|
28
28
|
* See also:
|
|
29
29
|
*
|
|
@@ -19,10 +19,9 @@ export var createAtan = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
|
19
19
|
* Examples:
|
|
20
20
|
*
|
|
21
21
|
* math.atan(0.5) // returns number 0.4636476090008061
|
|
22
|
+
* math.atan(2) // returns number 1.1071487177940904
|
|
22
23
|
* math.atan(math.tan(1.5)) // returns number 1.5
|
|
23
24
|
*
|
|
24
|
-
* math.atan(2) // returns Complex 1.5707963267948966 -1.3169578969248166 i
|
|
25
|
-
*
|
|
26
25
|
* See also:
|
|
27
26
|
*
|
|
28
27
|
* tan, asin, acos
|
|
@@ -57,7 +57,7 @@ export var createAtan2 = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
|
57
57
|
* const x = math.cos(angle)
|
|
58
58
|
* const y = math.sin(angle)
|
|
59
59
|
*
|
|
60
|
-
* math.atan(2) // returns
|
|
60
|
+
* math.atan(2) // returns number 1.1071487177940904
|
|
61
61
|
*
|
|
62
62
|
* See also:
|
|
63
63
|
*
|
|
@@ -17,7 +17,7 @@ export var createClone = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
|
17
17
|
* Examples:
|
|
18
18
|
*
|
|
19
19
|
* math.clone(3.5) // returns number 3.5
|
|
20
|
-
* math.clone(math.complex('2-4i')
|
|
20
|
+
* math.clone(math.complex('2-4i')) // returns Complex 2 - 4i
|
|
21
21
|
* math.clone(math.unit(45, 'deg')) // returns Unit 45 deg
|
|
22
22
|
* math.clone([[1, 2], [3, 4]]) // returns Array [[1, 2], [3, 4]]
|
|
23
23
|
* math.clone("hello world") // returns string "hello world"
|
|
@@ -24,7 +24,7 @@ export var createHasNumericValue = /* #__PURE__ */factory(name, dependencies, _r
|
|
|
24
24
|
* math.hasNumericValue(0) // returns true
|
|
25
25
|
* math.hasNumericValue(math.bignumber(500)) // returns true
|
|
26
26
|
* math.hasNumericValue(math.fraction(4)) // returns true
|
|
27
|
-
* math.hasNumericValue(math.complex('2-4i')
|
|
27
|
+
* math.hasNumericValue(math.complex('2-4i')) // returns false
|
|
28
28
|
* math.hasNumericValue(false) // returns true
|
|
29
29
|
* math.hasNumericValue([2.3, 'foo', false]) // returns [true, false, true]
|
|
30
30
|
*
|
|
@@ -27,7 +27,7 @@ export var createIsInteger = /* #__PURE__ */factory(name, dependencies, _ref =>
|
|
|
27
27
|
* math.isInteger(math.fraction(4)) // returns true
|
|
28
28
|
* math.isInteger('3') // returns true
|
|
29
29
|
* math.isInteger([3, 0.5, -2]) // returns [true, false, true]
|
|
30
|
-
* math.isInteger(math.complex('2-4i')
|
|
30
|
+
* math.isInteger(math.complex('2-4i')) // throws an error
|
|
31
31
|
*
|
|
32
32
|
* See also:
|
|
33
33
|
*
|
|
@@ -27,7 +27,7 @@ export var createIsNaN = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
|
27
27
|
* math.isNaN(math.bignumber(0)) // returns false
|
|
28
28
|
* math.isNaN(math.fraction(-2, 5)) // returns false
|
|
29
29
|
* math.isNaN('-2') // returns false
|
|
30
|
-
* math.isNaN([2, 0, -3, NaN]
|
|
30
|
+
* math.isNaN([2, 0, -3, NaN]) // returns [false, false, false, true]
|
|
31
31
|
*
|
|
32
32
|
* See also:
|
|
33
33
|
*
|
|
@@ -27,7 +27,7 @@ export var createIsNegative = /* #__PURE__ */factory(name, dependencies, _ref =>
|
|
|
27
27
|
* math.isNegative(math.bignumber(2)) // returns false
|
|
28
28
|
* math.isNegative(math.fraction(-2, 5)) // returns true
|
|
29
29
|
* math.isNegative('-2') // returns true
|
|
30
|
-
* math.isNegative([2, 0, -3]
|
|
30
|
+
* math.isNegative([2, 0, -3]) // returns [false, false, true]
|
|
31
31
|
*
|
|
32
32
|
* See also:
|
|
33
33
|
*
|
|
@@ -24,7 +24,7 @@ export var createIsNumeric = /* #__PURE__ */factory(name, dependencies, _ref =>
|
|
|
24
24
|
* math.isNumeric(0) // returns true
|
|
25
25
|
* math.isNumeric(math.bignumber(500)) // returns true
|
|
26
26
|
* math.isNumeric(math.fraction(4)) // returns true
|
|
27
|
-
* math.isNumeric(math.complex('2-4i')
|
|
27
|
+
* math.isNumeric(math.complex('2-4i')) // returns false
|
|
28
28
|
* math.isNumeric([2.3, 'foo', false]) // returns [true, false, true]
|
|
29
29
|
*
|
|
30
30
|
* See also:
|
|
@@ -27,7 +27,7 @@ export var createIsPositive = /* #__PURE__ */factory(name, dependencies, _ref =>
|
|
|
27
27
|
* math.isPositive(0.5) // returns true
|
|
28
28
|
* math.isPositive(math.bignumber(2)) // returns true
|
|
29
29
|
* math.isPositive(math.fraction(-2, 5)) // returns false
|
|
30
|
-
* math.isPositive(math.fraction(1,3))
|
|
30
|
+
* math.isPositive(math.fraction(1, 3)) // returns true
|
|
31
31
|
* math.isPositive('2') // returns true
|
|
32
32
|
* math.isPositive([2, 0, -3]) // returns [true, false, false]
|
|
33
33
|
*
|
|
@@ -21,17 +21,17 @@ export var createIsZero = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
|
21
21
|
*
|
|
22
22
|
* Examples:
|
|
23
23
|
*
|
|
24
|
-
* math.isZero(0)
|
|
25
|
-
* math.isZero(2)
|
|
26
|
-
* math.isZero(0.5)
|
|
27
|
-
* math.isZero(math.bignumber(0))
|
|
28
|
-
* math.isZero(math.fraction(0))
|
|
29
|
-
* math.isZero(math.fraction(1,3))
|
|
30
|
-
* math.isZero(math.complex('2 - 4i') // returns false
|
|
31
|
-
* math.isZero(math.complex('0i') // returns true
|
|
32
|
-
* math.isZero('0')
|
|
33
|
-
* math.isZero('2')
|
|
34
|
-
* math.isZero([2, 0, -3]
|
|
24
|
+
* math.isZero(0) // returns true
|
|
25
|
+
* math.isZero(2) // returns false
|
|
26
|
+
* math.isZero(0.5) // returns false
|
|
27
|
+
* math.isZero(math.bignumber(0)) // returns true
|
|
28
|
+
* math.isZero(math.fraction(0)) // returns true
|
|
29
|
+
* math.isZero(math.fraction(1,3)) // returns false
|
|
30
|
+
* math.isZero(math.complex('2 - 4i')) // returns false
|
|
31
|
+
* math.isZero(math.complex('0i')) // returns true
|
|
32
|
+
* math.isZero('0') // returns true
|
|
33
|
+
* math.isZero('2') // returns false
|
|
34
|
+
* math.isZero([2, 0, -3]) // returns [false, true, false]
|
|
35
35
|
*
|
|
36
36
|
* See also:
|
|
37
37
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
3
3
|
|
|
4
4
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
5
5
|
|
|
@@ -37,8 +37,8 @@ export var createUnitClass = /* #__PURE__ */factory(name, dependencies, _ref =>
|
|
|
37
37
|
/**
|
|
38
38
|
* A unit can be constructed in the following ways:
|
|
39
39
|
*
|
|
40
|
-
* const a = new Unit(value,
|
|
41
|
-
* const b = new Unit(null,
|
|
40
|
+
* const a = new Unit(value, valuelessUnit)
|
|
41
|
+
* const b = new Unit(null, valuelessUnit)
|
|
42
42
|
* const c = Unit.parse(str)
|
|
43
43
|
*
|
|
44
44
|
* Example usage:
|
|
@@ -51,10 +51,10 @@ export var createUnitClass = /* #__PURE__ */factory(name, dependencies, _ref =>
|
|
|
51
51
|
* @class Unit
|
|
52
52
|
* @constructor Unit
|
|
53
53
|
* @param {number | BigNumber | Fraction | Complex | boolean} [value] A value like 5.2
|
|
54
|
-
* @param {string}
|
|
54
|
+
* @param {string | Unit} valuelessUnit A unit without value. Can have prefix, like "cm"
|
|
55
55
|
*/
|
|
56
56
|
|
|
57
|
-
function Unit(value,
|
|
57
|
+
function Unit(value, valuelessUnit) {
|
|
58
58
|
if (!(this instanceof Unit)) {
|
|
59
59
|
throw new Error('Constructor must be called with the new operator');
|
|
60
60
|
}
|
|
@@ -63,31 +63,32 @@ export var createUnitClass = /* #__PURE__ */factory(name, dependencies, _ref =>
|
|
|
63
63
|
throw new TypeError('First parameter in Unit constructor must be number, BigNumber, Fraction, Complex, or undefined');
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
if (name !== undefined && (typeof name !== 'string' || name === '')) {
|
|
67
|
-
throw new TypeError('Second parameter in Unit constructor must be a string');
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (name !== undefined) {
|
|
71
|
-
var u = Unit.parse(name);
|
|
72
|
-
this.units = u.units;
|
|
73
|
-
this.dimensions = u.dimensions;
|
|
74
|
-
} else {
|
|
75
|
-
this.units = [];
|
|
76
|
-
this.dimensions = [];
|
|
77
|
-
|
|
78
|
-
for (var i = 0; i < BASE_DIMENSIONS.length; i++) {
|
|
79
|
-
this.dimensions[i] = 0;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
this.value = value !== undefined && value !== null ? this._normalize(value) : null;
|
|
84
66
|
this.fixPrefix = false; // if true, function format will not search for the
|
|
85
67
|
// best prefix but leave it as initially provided.
|
|
86
68
|
// fixPrefix is set true by the method Unit.to
|
|
87
69
|
// The justification behind this is that if the constructor is explicitly called,
|
|
88
|
-
// the caller wishes the units to be returned exactly as
|
|
70
|
+
// the caller wishes the units to be returned exactly as supplied.
|
|
89
71
|
|
|
90
72
|
this.skipAutomaticSimplification = true;
|
|
73
|
+
|
|
74
|
+
if (valuelessUnit === undefined) {
|
|
75
|
+
this.units = [];
|
|
76
|
+
this.dimensions = BASE_DIMENSIONS.map(x => 0);
|
|
77
|
+
} else if (typeof valuelessUnit === 'string') {
|
|
78
|
+
var u = Unit.parse(valuelessUnit);
|
|
79
|
+
this.units = u.units;
|
|
80
|
+
this.dimensions = u.dimensions;
|
|
81
|
+
} else if (isUnit(valuelessUnit) && valuelessUnit.value === null) {
|
|
82
|
+
// clone from valuelessUnit
|
|
83
|
+
this.fixPrefix = valuelessUnit.fixPrefix;
|
|
84
|
+
this.skipAutomaticSimplification = valuelessUnit.skipAutomaticSimplification;
|
|
85
|
+
this.dimensions = valuelessUnit.dimensions.slice(0);
|
|
86
|
+
this.units = valuelessUnit.units.map(u => _extends({}, u));
|
|
87
|
+
} else {
|
|
88
|
+
throw new TypeError('Second parameter in Unit constructor must be a string or valueless Unit');
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
this.value = this._normalize(value);
|
|
91
92
|
}
|
|
92
93
|
/**
|
|
93
94
|
* Attach type information
|
|
@@ -17,10 +17,13 @@ export var createUnitFunction = /* #__PURE__ */factory(name, dependencies, _ref
|
|
|
17
17
|
* Syntax:
|
|
18
18
|
*
|
|
19
19
|
* math.unit(unit : string)
|
|
20
|
-
* math.unit(value : number,
|
|
20
|
+
* math.unit(value : number, valuelessUnit : Unit)
|
|
21
|
+
* math.unit(value : number, valuelessUnit : string)
|
|
21
22
|
*
|
|
22
23
|
* Examples:
|
|
23
24
|
*
|
|
25
|
+
* const kph = math.unit('km/h') // returns Unit km/h (valueless)
|
|
26
|
+
* const v = math.unit(25, kph) // returns Unit 25 km/h
|
|
24
27
|
* const a = math.unit(5, 'cm') // returns Unit 50 mm
|
|
25
28
|
* const b = math.unit('23 kg') // returns Unit 23 kg
|
|
26
29
|
* a.to('m') // returns Unit 0.05 m
|
|
@@ -45,7 +48,7 @@ export var createUnitFunction = /* #__PURE__ */factory(name, dependencies, _ref
|
|
|
45
48
|
allowNoUnits: true
|
|
46
49
|
}); // a unit with value, like '5cm'
|
|
47
50
|
},
|
|
48
|
-
'number | BigNumber | Fraction | Complex, string': function
|
|
51
|
+
'number | BigNumber | Fraction | Complex, string | Unit': function numberBigNumberFractionComplexStringUnit(value, unit) {
|
|
49
52
|
return new Unit(value, unit);
|
|
50
53
|
},
|
|
51
54
|
'number | BigNumber | Fraction': function numberBigNumberFraction(value) {
|
package/lib/esm/utils/is.js
CHANGED
|
@@ -149,6 +149,9 @@ export function isParenthesisNode(x) {
|
|
|
149
149
|
export function isRangeNode(x) {
|
|
150
150
|
return x && x.isRangeNode === true && x.constructor.prototype.isNode === true || false;
|
|
151
151
|
}
|
|
152
|
+
export function isRelationalNode(x) {
|
|
153
|
+
return x && x.isRelationalNode === true && x.constructor.prototype.isNode === true || false;
|
|
154
|
+
}
|
|
152
155
|
export function isSymbolNode(x) {
|
|
153
156
|
return x && x.isSymbolNode === true && x.constructor.prototype.isNode === true || false;
|
|
154
157
|
}
|
package/lib/esm/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export var version = '11.
|
|
1
|
+
export var version = '11.2.0'; // Note: This file is automatically generated when building math.js.
|
|
2
2
|
// Changes made in this file will be overwritten.
|