mathjs 11.6.0 → 11.7.0
Sign up to get free protection for your applications and to get access to all the features.
- package/HISTORY.md +13 -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/expression/embeddedDocs/function/matrix/partitionSelect.js +1 -1
- package/lib/cjs/function/arithmetic/expm1.js +1 -1
- package/lib/cjs/function/arithmetic/gcd.js +35 -12
- package/lib/cjs/function/arithmetic/nthRoots.js +2 -1
- package/lib/cjs/function/arithmetic/round.js +1 -1
- package/lib/cjs/function/arithmetic/sign.js +1 -1
- package/lib/cjs/function/bitwise/rightArithShift.js +1 -1
- package/lib/cjs/function/matrix/det.js +7 -1
- package/lib/cjs/function/matrix/diff.js +3 -3
- package/lib/cjs/function/matrix/partitionSelect.js +7 -2
- package/lib/cjs/function/set/setIsSubset.js +1 -1
- package/lib/cjs/function/set/setSize.js +3 -2
- package/lib/cjs/header.js +2 -2
- package/lib/cjs/version.js +1 -1
- package/lib/esm/expression/embeddedDocs/function/matrix/partitionSelect.js +1 -1
- package/lib/esm/function/arithmetic/expm1.js +1 -1
- package/lib/esm/function/arithmetic/gcd.js +27 -10
- package/lib/esm/function/arithmetic/nthRoots.js +2 -1
- package/lib/esm/function/arithmetic/round.js +1 -1
- package/lib/esm/function/arithmetic/sign.js +1 -1
- package/lib/esm/function/bitwise/rightArithShift.js +1 -1
- package/lib/esm/function/matrix/det.js +7 -1
- package/lib/esm/function/matrix/diff.js +3 -3
- package/lib/esm/function/matrix/partitionSelect.js +7 -2
- package/lib/esm/function/set/setIsSubset.js +1 -1
- package/lib/esm/function/set/setSize.js +3 -2
- package/lib/esm/version.js +1 -1
- package/package.json +9 -9
- package/types/index.d.ts +245 -469
@@ -9,7 +9,7 @@ var partitionSelectDocs = {
|
|
9
9
|
category: 'Matrix',
|
10
10
|
syntax: ['partitionSelect(x, k)', 'partitionSelect(x, k, compare)'],
|
11
11
|
description: 'Partition-based selection of an array or 1D matrix. Will find the kth smallest value, and mutates the input array. Uses Quickselect.',
|
12
|
-
examples: ['partitionSelect([5, 10, 1], 2)', 'partitionSelect(["C", "B", "A", "D"], 1)'],
|
12
|
+
examples: ['partitionSelect([5, 10, 1], 2)', 'partitionSelect(["C", "B", "A", "D"], 1, compareText)', 'arr = [5, 2, 1]', 'partitionSelect(arr, 0) # returns 1, arr is now: [1, 2, 5]', 'arr', 'partitionSelect(arr, 1, \'desc\') # returns 2, arr is now: [5, 2, 1]', 'arr'],
|
13
13
|
seealso: ['sort']
|
14
14
|
};
|
15
15
|
exports.partitionSelectDocs = partitionSelectDocs;
|
@@ -41,7 +41,7 @@ var createExpm1 = /* #__PURE__ */(0, _factory.factory)(name, dependencies, funct
|
|
41
41
|
*
|
42
42
|
* exp, expm, log, pow
|
43
43
|
*
|
44
|
-
* @param {number | BigNumber | Complex} x
|
44
|
+
* @param {number | BigNumber | Complex} x The number to exponentiate
|
45
45
|
* @return {number | BigNumber | Complex} Exponential of `x`, minus one
|
46
46
|
*/
|
47
47
|
return typed(name, {
|
@@ -1,18 +1,30 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
4
5
|
value: true
|
5
6
|
});
|
6
7
|
exports.createGcd = void 0;
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
9
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
7
10
|
var _factory = require("../../utils/factory.js");
|
8
11
|
var _matAlgo01xDSid = require("../../type/matrix/utils/matAlgo01xDSid.js");
|
9
12
|
var _matAlgo04xSidSid = require("../../type/matrix/utils/matAlgo04xSidSid.js");
|
10
13
|
var _matAlgo10xSids = require("../../type/matrix/utils/matAlgo10xSids.js");
|
11
14
|
var _matrixAlgorithmSuite = require("../../type/matrix/utils/matrixAlgorithmSuite.js");
|
12
15
|
var _index = require("../../plain/number/index.js");
|
16
|
+
var _ArgumentsError = require("../../error/ArgumentsError.js");
|
13
17
|
var name = 'gcd';
|
14
18
|
var dependencies = ['typed', 'matrix', 'equalScalar', 'BigNumber', 'DenseMatrix', 'concat'];
|
19
|
+
var gcdTypes = 'number | BigNumber | Fraction | Matrix | Array';
|
20
|
+
var gcdManyTypesSignature = "".concat(gcdTypes, ", ").concat(gcdTypes, ", ...").concat(gcdTypes);
|
21
|
+
function is1d(array) {
|
22
|
+
return !array.some(function (element) {
|
23
|
+
return Array.isArray(element);
|
24
|
+
});
|
25
|
+
}
|
15
26
|
var createGcd = /* #__PURE__ */(0, _factory.factory)(name, dependencies, function (_ref) {
|
27
|
+
var _typed;
|
16
28
|
var typed = _ref.typed,
|
17
29
|
matrix = _ref.matrix,
|
18
30
|
equalScalar = _ref.equalScalar,
|
@@ -35,17 +47,6 @@ var createGcd = /* #__PURE__ */(0, _factory.factory)(name, dependencies, functio
|
|
35
47
|
matrix: matrix,
|
36
48
|
concat: concat
|
37
49
|
});
|
38
|
-
var gcdTypes = 'number | BigNumber | Fraction | Matrix | Array';
|
39
|
-
var gcdManySignature = {};
|
40
|
-
gcdManySignature["".concat(gcdTypes, ", ").concat(gcdTypes, ", ...").concat(gcdTypes)] = typed.referToSelf(function (self) {
|
41
|
-
return function (a, b, args) {
|
42
|
-
var res = self(a, b);
|
43
|
-
for (var i = 0; i < args.length; i++) {
|
44
|
-
res = self(res, args[i]);
|
45
|
-
}
|
46
|
-
return res;
|
47
|
-
};
|
48
|
-
});
|
49
50
|
|
50
51
|
/**
|
51
52
|
* Calculate the greatest common divisor for two or more values or arrays.
|
@@ -82,7 +83,29 @@ var createGcd = /* #__PURE__ */(0, _factory.factory)(name, dependencies, functio
|
|
82
83
|
SS: matAlgo04xSidSid,
|
83
84
|
DS: matAlgo01xDSid,
|
84
85
|
Ss: matAlgo10xSids
|
85
|
-
}),
|
86
|
+
}), (_typed = {}, (0, _defineProperty2["default"])(_typed, gcdManyTypesSignature, typed.referToSelf(function (self) {
|
87
|
+
return function (a, b, args) {
|
88
|
+
var res = self(a, b);
|
89
|
+
for (var i = 0; i < args.length; i++) {
|
90
|
+
res = self(res, args[i]);
|
91
|
+
}
|
92
|
+
return res;
|
93
|
+
};
|
94
|
+
})), (0, _defineProperty2["default"])(_typed, "Array", typed.referToSelf(function (self) {
|
95
|
+
return function (array) {
|
96
|
+
if (array.length === 1 && Array.isArray(array[0]) && is1d(array[0])) {
|
97
|
+
return self.apply(void 0, (0, _toConsumableArray2["default"])(array[0]));
|
98
|
+
}
|
99
|
+
if (is1d(array)) {
|
100
|
+
return self.apply(void 0, (0, _toConsumableArray2["default"])(array));
|
101
|
+
}
|
102
|
+
throw new _ArgumentsError.ArgumentsError('gcd() supports only 1d matrices!');
|
103
|
+
};
|
104
|
+
})), (0, _defineProperty2["default"])(_typed, "Matrix", typed.referToSelf(function (self) {
|
105
|
+
return function (matrix) {
|
106
|
+
return self(matrix.toArray());
|
107
|
+
};
|
108
|
+
})), _typed));
|
86
109
|
|
87
110
|
/**
|
88
111
|
* Calculate gcd for BigNumbers
|
@@ -104,7 +104,8 @@ var createNthRoots = /* #__PURE__ */(0, _factory.factory)(name, dependencies, fu
|
|
104
104
|
* nthRoot, pow, sqrt
|
105
105
|
*
|
106
106
|
* @param {number | BigNumber | Fraction | Complex} x Number to be rounded
|
107
|
-
* @
|
107
|
+
* @param {number} [root=2] Optional root, default value is 2
|
108
|
+
* @return {number | BigNumber | Fraction | Complex} Returns the nth roots
|
108
109
|
*/
|
109
110
|
return typed(name, {
|
110
111
|
Complex: function Complex(x) {
|
@@ -33,7 +33,7 @@ var createRound = /* #__PURE__ */(0, _factory.factory)(name, dependencies, funct
|
|
33
33
|
});
|
34
34
|
|
35
35
|
/**
|
36
|
-
* Round a value towards the nearest
|
36
|
+
* Round a value towards the nearest rounded value.
|
37
37
|
* For matrices, the function is evaluated element wise.
|
38
38
|
*
|
39
39
|
* Syntax:
|
@@ -41,7 +41,7 @@ var createSign = /* #__PURE__ */(0, _factory.factory)(name, dependencies, functi
|
|
41
41
|
*
|
42
42
|
* @param {number | BigNumber | Fraction | Complex | Array | Matrix | Unit} x
|
43
43
|
* The number for which to determine the sign
|
44
|
-
* @return {number | BigNumber | Fraction | Complex | Array | Matrix | Unit}
|
44
|
+
* @return {number | BigNumber | Fraction | Complex | Array | Matrix | Unit}
|
45
45
|
* The sign of `x`
|
46
46
|
*/
|
47
47
|
return typed(name, {
|
@@ -77,7 +77,7 @@ var createRightArithShift = /* #__PURE__ */(0, _factory.factory)(name, dependenc
|
|
77
77
|
*
|
78
78
|
* @param {number | BigNumber | Array | Matrix} x Value to be shifted
|
79
79
|
* @param {number | BigNumber} y Amount of shifts
|
80
|
-
* @return {number | BigNumber | Array | Matrix} `x`
|
80
|
+
* @return {number | BigNumber | Array | Matrix} `x` zero-filled shifted right `y` times
|
81
81
|
*/
|
82
82
|
return typed(name, {
|
83
83
|
'number, number': _index.rightArithShiftNumber,
|
@@ -66,16 +66,22 @@ var createDet = /* #__PURE__ */(0, _factory.factory)(name, dependencies, functio
|
|
66
66
|
// vector
|
67
67
|
if (size[0] === 1) {
|
68
68
|
return (0, _object.clone)(x.valueOf()[0]);
|
69
|
+
}
|
70
|
+
if (size[0] === 0) {
|
71
|
+
return 1; // det of an empty matrix is per definition 1
|
69
72
|
} else {
|
70
73
|
throw new RangeError('Matrix must be square ' + '(size: ' + (0, _string.format)(size) + ')');
|
71
74
|
}
|
72
75
|
case 2:
|
73
76
|
{
|
74
|
-
// two
|
77
|
+
// two-dimensional array
|
75
78
|
var rows = size[0];
|
76
79
|
var cols = size[1];
|
77
80
|
if (rows === cols) {
|
78
81
|
return _det(x.clone().valueOf(), rows, cols);
|
82
|
+
}
|
83
|
+
if (cols === 0) {
|
84
|
+
return 1; // det of an empty matrix is per definition 1
|
79
85
|
} else {
|
80
86
|
throw new RangeError('Matrix must be square ' + '(size: ' + (0, _string.format)(size) + ')');
|
81
87
|
}
|
@@ -56,9 +56,9 @@ var createDiff = /* #__PURE__ */(0, _factory.factory)(name, dependencies, functi
|
|
56
56
|
* subtract
|
57
57
|
* partitionSelect
|
58
58
|
*
|
59
|
-
* @param {Array | Matrix} arr
|
60
|
-
* @param {number} dim
|
61
|
-
* @return {Array | Matrix}
|
59
|
+
* @param {Array | Matrix} arr An array or matrix
|
60
|
+
* @param {number | BigNumber} dim Dimension
|
61
|
+
* @return {Array | Matrix} Difference between array elements in given dimension
|
62
62
|
*/
|
63
63
|
return typed(name, {
|
64
64
|
'Array | Matrix': function ArrayMatrix(arr) {
|
@@ -31,14 +31,19 @@ var createPartitionSelect = /* #__PURE__ */(0, _factory.factory)(name, dependenc
|
|
31
31
|
*
|
32
32
|
* Examples:
|
33
33
|
*
|
34
|
-
* math.partitionSelect([5, 10, 1], 2)
|
35
|
-
* math.partitionSelect(['C', 'B', 'A', 'D'], 1)
|
34
|
+
* math.partitionSelect([5, 10, 1], 2) // returns 10
|
35
|
+
* math.partitionSelect(['C', 'B', 'A', 'D'], 1, math.compareText) // returns 'B'
|
36
36
|
*
|
37
37
|
* function sortByLength (a, b) {
|
38
38
|
* return a.length - b.length
|
39
39
|
* }
|
40
40
|
* math.partitionSelect(['Langdon', 'Tom', 'Sara'], 2, sortByLength) // returns 'Langdon'
|
41
41
|
*
|
42
|
+
* // the input array is mutated
|
43
|
+
* arr = [5, 2, 1]
|
44
|
+
* math.partitionSelect(arr, 0) // returns 1, arr is now: [1, 2, 5]
|
45
|
+
* math.partitionSelect(arr, 1, 'desc') // returns 2, arr is now: [5, 2, 1]
|
46
|
+
*
|
42
47
|
* See also:
|
43
48
|
*
|
44
49
|
* sort
|
@@ -33,7 +33,7 @@ var createSetIsSubset = /* #__PURE__ */(0, _factory.factory)(name, dependencies,
|
|
33
33
|
*
|
34
34
|
* @param {Array | Matrix} a1 A (multi)set
|
35
35
|
* @param {Array | Matrix} a2 A (multi)set
|
36
|
-
* @return {boolean}
|
36
|
+
* @return {boolean} Returns true when a1 is a subset of a2, returns false otherwise
|
37
37
|
*/
|
38
38
|
return typed(name, {
|
39
39
|
'Array | Matrix, Array | Matrix': function ArrayMatrixArrayMatrix(a1, a2) {
|
@@ -29,8 +29,9 @@ var createSetSize = /* #__PURE__ */(0, _factory.factory)(name, dependencies, fun
|
|
29
29
|
*
|
30
30
|
* setUnion, setIntersect, setDifference
|
31
31
|
*
|
32
|
-
* @param {Array | Matrix}
|
33
|
-
* @
|
32
|
+
* @param {Array | Matrix} a A multiset
|
33
|
+
* @param {boolean} [unique] If true, only the unique values are counted. False by default
|
34
|
+
* @return {number} The number of elements of the (multi)set
|
34
35
|
*/
|
35
36
|
return typed(name, {
|
36
37
|
'Array | Matrix': function ArrayMatrix(a) {
|
package/lib/cjs/header.js
CHANGED
@@ -6,8 +6,8 @@
|
|
6
6
|
* It features real and complex numbers, units, matrices, a large set of
|
7
7
|
* mathematical functions, and a flexible expression parser.
|
8
8
|
*
|
9
|
-
* @version 11.
|
10
|
-
* @date 2023-
|
9
|
+
* @version 11.7.0
|
10
|
+
* @date 2023-03-15
|
11
11
|
*
|
12
12
|
* @license
|
13
13
|
* Copyright (C) 2013-2023 Jos de Jong <wjosdejong@gmail.com>
|
package/lib/cjs/version.js
CHANGED
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.version = void 0;
|
7
|
-
var version = '11.
|
7
|
+
var version = '11.7.0';
|
8
8
|
// Note: This file is automatically generated when building math.js.
|
9
9
|
// Changes made in this file will be overwritten.
|
10
10
|
exports.version = version;
|
@@ -3,6 +3,6 @@ export var partitionSelectDocs = {
|
|
3
3
|
category: 'Matrix',
|
4
4
|
syntax: ['partitionSelect(x, k)', 'partitionSelect(x, k, compare)'],
|
5
5
|
description: 'Partition-based selection of an array or 1D matrix. Will find the kth smallest value, and mutates the input array. Uses Quickselect.',
|
6
|
-
examples: ['partitionSelect([5, 10, 1], 2)', 'partitionSelect(["C", "B", "A", "D"], 1)'],
|
6
|
+
examples: ['partitionSelect([5, 10, 1], 2)', 'partitionSelect(["C", "B", "A", "D"], 1, compareText)', 'arr = [5, 2, 1]', 'partitionSelect(arr, 0) # returns 1, arr is now: [1, 2, 5]', 'arr', 'partitionSelect(arr, 1, \'desc\') # returns 2, arr is now: [5, 2, 1]', 'arr'],
|
7
7
|
seealso: ['sort']
|
8
8
|
};
|
@@ -37,7 +37,7 @@ export var createExpm1 = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
37
37
|
*
|
38
38
|
* exp, expm, log, pow
|
39
39
|
*
|
40
|
-
* @param {number | BigNumber | Complex} x
|
40
|
+
* @param {number | BigNumber | Complex} x The number to exponentiate
|
41
41
|
* @return {number | BigNumber | Complex} Exponential of `x`, minus one
|
42
42
|
*/
|
43
43
|
return typed(name, {
|
@@ -4,8 +4,14 @@ import { createMatAlgo04xSidSid } from '../../type/matrix/utils/matAlgo04xSidSid
|
|
4
4
|
import { createMatAlgo10xSids } from '../../type/matrix/utils/matAlgo10xSids.js';
|
5
5
|
import { createMatrixAlgorithmSuite } from '../../type/matrix/utils/matrixAlgorithmSuite.js';
|
6
6
|
import { gcdNumber } from '../../plain/number/index.js';
|
7
|
+
import { ArgumentsError } from '../../error/ArgumentsError.js';
|
7
8
|
var name = 'gcd';
|
8
9
|
var dependencies = ['typed', 'matrix', 'equalScalar', 'BigNumber', 'DenseMatrix', 'concat'];
|
10
|
+
var gcdTypes = 'number | BigNumber | Fraction | Matrix | Array';
|
11
|
+
var gcdManyTypesSignature = "".concat(gcdTypes, ", ").concat(gcdTypes, ", ...").concat(gcdTypes);
|
12
|
+
function is1d(array) {
|
13
|
+
return !array.some(element => Array.isArray(element));
|
14
|
+
}
|
9
15
|
export var createGcd = /* #__PURE__ */factory(name, dependencies, _ref => {
|
10
16
|
var {
|
11
17
|
typed,
|
@@ -31,15 +37,6 @@ export var createGcd = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
31
37
|
matrix,
|
32
38
|
concat
|
33
39
|
});
|
34
|
-
var gcdTypes = 'number | BigNumber | Fraction | Matrix | Array';
|
35
|
-
var gcdManySignature = {};
|
36
|
-
gcdManySignature["".concat(gcdTypes, ", ").concat(gcdTypes, ", ...").concat(gcdTypes)] = typed.referToSelf(self => (a, b, args) => {
|
37
|
-
var res = self(a, b);
|
38
|
-
for (var i = 0; i < args.length; i++) {
|
39
|
-
res = self(res, args[i]);
|
40
|
-
}
|
41
|
-
return res;
|
42
|
-
});
|
43
40
|
|
44
41
|
/**
|
45
42
|
* Calculate the greatest common divisor for two or more values or arrays.
|
@@ -74,7 +71,27 @@ export var createGcd = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
74
71
|
SS: matAlgo04xSidSid,
|
75
72
|
DS: matAlgo01xDSid,
|
76
73
|
Ss: matAlgo10xSids
|
77
|
-
}),
|
74
|
+
}), {
|
75
|
+
[gcdManyTypesSignature]: typed.referToSelf(self => (a, b, args) => {
|
76
|
+
var res = self(a, b);
|
77
|
+
for (var i = 0; i < args.length; i++) {
|
78
|
+
res = self(res, args[i]);
|
79
|
+
}
|
80
|
+
return res;
|
81
|
+
}),
|
82
|
+
Array: typed.referToSelf(self => array => {
|
83
|
+
if (array.length === 1 && Array.isArray(array[0]) && is1d(array[0])) {
|
84
|
+
return self(...array[0]);
|
85
|
+
}
|
86
|
+
if (is1d(array)) {
|
87
|
+
return self(...array);
|
88
|
+
}
|
89
|
+
throw new ArgumentsError('gcd() supports only 1d matrices!');
|
90
|
+
}),
|
91
|
+
Matrix: typed.referToSelf(self => matrix => {
|
92
|
+
return self(matrix.toArray());
|
93
|
+
})
|
94
|
+
});
|
78
95
|
|
79
96
|
/**
|
80
97
|
* Calculate gcd for BigNumbers
|
@@ -100,7 +100,8 @@ export var createNthRoots = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
100
100
|
* nthRoot, pow, sqrt
|
101
101
|
*
|
102
102
|
* @param {number | BigNumber | Fraction | Complex} x Number to be rounded
|
103
|
-
* @
|
103
|
+
* @param {number} [root=2] Optional root, default value is 2
|
104
|
+
* @return {number | BigNumber | Fraction | Complex} Returns the nth roots
|
104
105
|
*/
|
105
106
|
return typed(name, {
|
106
107
|
Complex: function Complex(x) {
|
@@ -29,7 +29,7 @@ export var createRound = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
29
29
|
});
|
30
30
|
|
31
31
|
/**
|
32
|
-
* Round a value towards the nearest
|
32
|
+
* Round a value towards the nearest rounded value.
|
33
33
|
* For matrices, the function is evaluated element wise.
|
34
34
|
*
|
35
35
|
* Syntax:
|
@@ -37,7 +37,7 @@ export var createSign = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
37
37
|
*
|
38
38
|
* @param {number | BigNumber | Fraction | Complex | Array | Matrix | Unit} x
|
39
39
|
* The number for which to determine the sign
|
40
|
-
* @return {number | BigNumber | Fraction | Complex | Array | Matrix | Unit}
|
40
|
+
* @return {number | BigNumber | Fraction | Complex | Array | Matrix | Unit}
|
41
41
|
* The sign of `x`
|
42
42
|
*/
|
43
43
|
return typed(name, {
|
@@ -73,7 +73,7 @@ export var createRightArithShift = /* #__PURE__ */factory(name, dependencies, _r
|
|
73
73
|
*
|
74
74
|
* @param {number | BigNumber | Array | Matrix} x Value to be shifted
|
75
75
|
* @param {number | BigNumber} y Amount of shifts
|
76
|
-
* @return {number | BigNumber | Array | Matrix} `x`
|
76
|
+
* @return {number | BigNumber | Array | Matrix} `x` zero-filled shifted right `y` times
|
77
77
|
*/
|
78
78
|
return typed(name, {
|
79
79
|
'number, number': rightArithShiftNumber,
|
@@ -62,16 +62,22 @@ export var createDet = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
62
62
|
// vector
|
63
63
|
if (size[0] === 1) {
|
64
64
|
return clone(x.valueOf()[0]);
|
65
|
+
}
|
66
|
+
if (size[0] === 0) {
|
67
|
+
return 1; // det of an empty matrix is per definition 1
|
65
68
|
} else {
|
66
69
|
throw new RangeError('Matrix must be square ' + '(size: ' + format(size) + ')');
|
67
70
|
}
|
68
71
|
case 2:
|
69
72
|
{
|
70
|
-
// two
|
73
|
+
// two-dimensional array
|
71
74
|
var rows = size[0];
|
72
75
|
var cols = size[1];
|
73
76
|
if (rows === cols) {
|
74
77
|
return _det(x.clone().valueOf(), rows, cols);
|
78
|
+
}
|
79
|
+
if (cols === 0) {
|
80
|
+
return 1; // det of an empty matrix is per definition 1
|
75
81
|
} else {
|
76
82
|
throw new RangeError('Matrix must be square ' + '(size: ' + format(size) + ')');
|
77
83
|
}
|
@@ -52,9 +52,9 @@ export var createDiff = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
52
52
|
* subtract
|
53
53
|
* partitionSelect
|
54
54
|
*
|
55
|
-
* @param {Array | Matrix} arr
|
56
|
-
* @param {number} dim
|
57
|
-
* @return {Array | Matrix}
|
55
|
+
* @param {Array | Matrix} arr An array or matrix
|
56
|
+
* @param {number | BigNumber} dim Dimension
|
57
|
+
* @return {Array | Matrix} Difference between array elements in given dimension
|
58
58
|
*/
|
59
59
|
return typed(name, {
|
60
60
|
'Array | Matrix': function ArrayMatrix(arr) {
|
@@ -25,14 +25,19 @@ export var createPartitionSelect = /* #__PURE__ */factory(name, dependencies, _r
|
|
25
25
|
*
|
26
26
|
* Examples:
|
27
27
|
*
|
28
|
-
* math.partitionSelect([5, 10, 1], 2)
|
29
|
-
* math.partitionSelect(['C', 'B', 'A', 'D'], 1)
|
28
|
+
* math.partitionSelect([5, 10, 1], 2) // returns 10
|
29
|
+
* math.partitionSelect(['C', 'B', 'A', 'D'], 1, math.compareText) // returns 'B'
|
30
30
|
*
|
31
31
|
* function sortByLength (a, b) {
|
32
32
|
* return a.length - b.length
|
33
33
|
* }
|
34
34
|
* math.partitionSelect(['Langdon', 'Tom', 'Sara'], 2, sortByLength) // returns 'Langdon'
|
35
35
|
*
|
36
|
+
* // the input array is mutated
|
37
|
+
* arr = [5, 2, 1]
|
38
|
+
* math.partitionSelect(arr, 0) // returns 1, arr is now: [1, 2, 5]
|
39
|
+
* math.partitionSelect(arr, 1, 'desc') // returns 2, arr is now: [5, 2, 1]
|
40
|
+
*
|
36
41
|
* See also:
|
37
42
|
*
|
38
43
|
* sort
|
@@ -29,7 +29,7 @@ export var createSetIsSubset = /* #__PURE__ */factory(name, dependencies, _ref =
|
|
29
29
|
*
|
30
30
|
* @param {Array | Matrix} a1 A (multi)set
|
31
31
|
* @param {Array | Matrix} a2 A (multi)set
|
32
|
-
* @return {boolean}
|
32
|
+
* @return {boolean} Returns true when a1 is a subset of a2, returns false otherwise
|
33
33
|
*/
|
34
34
|
return typed(name, {
|
35
35
|
'Array | Matrix, Array | Matrix': function ArrayMatrixArrayMatrix(a1, a2) {
|
@@ -25,8 +25,9 @@ export var createSetSize = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
25
25
|
*
|
26
26
|
* setUnion, setIntersect, setDifference
|
27
27
|
*
|
28
|
-
* @param {Array | Matrix}
|
29
|
-
* @
|
28
|
+
* @param {Array | Matrix} a A multiset
|
29
|
+
* @param {boolean} [unique] If true, only the unique values are counted. False by default
|
30
|
+
* @return {number} The number of elements of the (multi)set
|
30
31
|
*/
|
31
32
|
return typed(name, {
|
32
33
|
'Array | Matrix': function ArrayMatrix(a) {
|
package/lib/esm/version.js
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "mathjs",
|
3
|
-
"version": "11.
|
3
|
+
"version": "11.7.0",
|
4
4
|
"description": "Math.js is an extensive math library for JavaScript and Node.js. It features a flexible expression parser with support for symbolic computation, comes with a large set of built-in functions and constants, and offers an integrated solution to work with different data types like numbers, big numbers, complex numbers, fractions, units, and matrices.",
|
5
5
|
"author": "Jos de Jong <wjosdejong@gmail.com> (https://github.com/josdejong)",
|
6
6
|
"homepage": "https://mathjs.org",
|
@@ -36,25 +36,25 @@
|
|
36
36
|
"typed-function": "^4.1.0"
|
37
37
|
},
|
38
38
|
"devDependencies": {
|
39
|
-
"@babel/core": "7.21.
|
39
|
+
"@babel/core": "7.21.3",
|
40
40
|
"@babel/plugin-transform-object-assign": "7.18.6",
|
41
41
|
"@babel/plugin-transform-runtime": "7.21.0",
|
42
42
|
"@babel/preset-env": "7.20.2",
|
43
43
|
"@babel/register": "7.21.0",
|
44
44
|
"@types/assert": "1.5.6",
|
45
45
|
"@types/mocha": "10.0.1",
|
46
|
-
"@typescript-eslint/eslint-plugin": "5.
|
47
|
-
"@typescript-eslint/parser": "5.
|
46
|
+
"@typescript-eslint/eslint-plugin": "5.55.0",
|
47
|
+
"@typescript-eslint/parser": "5.55.0",
|
48
48
|
"assert": "2.0.0",
|
49
49
|
"babel-loader": "9.1.2",
|
50
50
|
"benchmark": "2.1.4",
|
51
51
|
"c8": "7.13.0",
|
52
52
|
"codecov": "3.8.3",
|
53
|
-
"core-js": "3.
|
53
|
+
"core-js": "3.29.1",
|
54
54
|
"del": "6.1.1",
|
55
55
|
"dtslint": "4.2.1",
|
56
|
-
"eslint": "8.
|
57
|
-
"eslint-config-prettier": "8.
|
56
|
+
"eslint": "8.36.0",
|
57
|
+
"eslint-config-prettier": "8.7.0",
|
58
58
|
"eslint-config-standard": "17.0.0",
|
59
59
|
"eslint-plugin-import": "2.27.5",
|
60
60
|
"eslint-plugin-mocha": "10.1.0",
|
@@ -75,7 +75,7 @@
|
|
75
75
|
"karma-mocha": "2.0.1",
|
76
76
|
"karma-mocha-reporter": "2.2.5",
|
77
77
|
"karma-webpack": "5.0.0",
|
78
|
-
"mkdirp": "2.1.
|
78
|
+
"mkdirp": "2.1.5",
|
79
79
|
"mocha": "10.2.0",
|
80
80
|
"mocha-junit-reporter": "2.2.0",
|
81
81
|
"ndarray": "1.0.19",
|
@@ -90,7 +90,7 @@
|
|
90
90
|
"sylvester": "0.0.21",
|
91
91
|
"ts-node": "10.9.1",
|
92
92
|
"typescript": "4.9.5",
|
93
|
-
"webpack": "5.
|
93
|
+
"webpack": "5.76.1",
|
94
94
|
"zeros": "1.0.0"
|
95
95
|
},
|
96
96
|
"type": "module",
|