mathjs 13.2.2 → 14.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. package/HISTORY.md +26 -0
  2. package/lib/browser/math.js +1 -1
  3. package/lib/browser/math.js.LICENSE.txt +2 -10
  4. package/lib/browser/math.js.map +1 -1
  5. package/lib/cjs/core/function/import.js +4 -1
  6. package/lib/cjs/core/function/typed.js +1 -1
  7. package/lib/cjs/entry/dependenciesAny/dependenciesBitXor.generated.js +2 -0
  8. package/lib/cjs/entry/dependenciesAny/dependenciesDotDivide.generated.js +2 -0
  9. package/lib/cjs/entry/dependenciesAny/dependenciesDotPow.generated.js +2 -0
  10. package/lib/cjs/entry/dependenciesAny/dependenciesEqual.generated.js +2 -0
  11. package/lib/cjs/entry/dependenciesAny/dependenciesLarger.generated.js +2 -0
  12. package/lib/cjs/entry/dependenciesAny/dependenciesLargerEq.generated.js +2 -0
  13. package/lib/cjs/entry/dependenciesAny/dependenciesLog.generated.js +2 -0
  14. package/lib/cjs/entry/dependenciesAny/dependenciesSimplify.generated.js +2 -0
  15. package/lib/cjs/entry/dependenciesAny/dependenciesSmaller.generated.js +2 -0
  16. package/lib/cjs/entry/dependenciesAny/dependenciesSmallerEq.generated.js +2 -0
  17. package/lib/cjs/entry/dependenciesAny/dependenciesUnequal.generated.js +2 -0
  18. package/lib/cjs/entry/dependenciesAny/dependenciesXor.generated.js +2 -0
  19. package/lib/cjs/entry/dependenciesNumber/dependenciesSimplify.generated.js +2 -0
  20. package/lib/cjs/entry/impureFunctionsAny.generated.js +1 -0
  21. package/lib/cjs/entry/impureFunctionsNumber.generated.js +1 -0
  22. package/lib/cjs/entry/pureFunctionsAny.generated.js +11 -0
  23. package/lib/cjs/expression/embeddedDocs/function/arithmetic/ceil.js +2 -2
  24. package/lib/cjs/expression/embeddedDocs/function/arithmetic/fix.js +2 -2
  25. package/lib/cjs/expression/embeddedDocs/function/arithmetic/floor.js +2 -2
  26. package/lib/cjs/expression/parse.js +26 -36
  27. package/lib/cjs/function/algebra/simplify.js +4 -3
  28. package/lib/cjs/function/algebra/simplifyConstant.js +5 -11
  29. package/lib/cjs/function/arithmetic/ceil.js +21 -2
  30. package/lib/cjs/function/arithmetic/dotDivide.js +4 -3
  31. package/lib/cjs/function/arithmetic/dotPow.js +4 -3
  32. package/lib/cjs/function/arithmetic/fix.js +24 -5
  33. package/lib/cjs/function/arithmetic/floor.js +21 -2
  34. package/lib/cjs/function/arithmetic/log.js +12 -4
  35. package/lib/cjs/function/arithmetic/pow.js +2 -2
  36. package/lib/cjs/function/arithmetic/round.js +3 -5
  37. package/lib/cjs/function/arithmetic/sign.js +1 -1
  38. package/lib/cjs/function/bitwise/bitXor.js +4 -3
  39. package/lib/cjs/function/logical/xor.js +4 -3
  40. package/lib/cjs/function/matrix/filter.js +7 -0
  41. package/lib/cjs/function/matrix/forEach.js +7 -0
  42. package/lib/cjs/function/relational/equal.js +4 -3
  43. package/lib/cjs/function/relational/larger.js +4 -3
  44. package/lib/cjs/function/relational/largerEq.js +4 -3
  45. package/lib/cjs/function/relational/smaller.js +4 -3
  46. package/lib/cjs/function/relational/smallerEq.js +4 -3
  47. package/lib/cjs/function/relational/unequal.js +4 -3
  48. package/lib/cjs/function/utils/isInteger.js +1 -1
  49. package/lib/cjs/function/utils/isNegative.js +1 -1
  50. package/lib/cjs/function/utils/isPositive.js +1 -1
  51. package/lib/cjs/header.js +2 -2
  52. package/lib/cjs/type/bignumber/function/bignumber.js +2 -2
  53. package/lib/cjs/type/fraction/Fraction.js +4 -4
  54. package/lib/cjs/type/fraction/function/fraction.js +3 -0
  55. package/lib/cjs/type/matrix/utils/matAlgo07xSSf.js +39 -43
  56. package/lib/cjs/type/unit/Unit.js +1 -1
  57. package/lib/cjs/utils/object.js +4 -0
  58. package/lib/cjs/utils/string.js +2 -2
  59. package/lib/cjs/version.js +1 -1
  60. package/lib/esm/core/function/import.js +4 -1
  61. package/lib/esm/core/function/typed.js +1 -1
  62. package/lib/esm/entry/dependenciesAny/dependenciesBitXor.generated.js +2 -0
  63. package/lib/esm/entry/dependenciesAny/dependenciesDotDivide.generated.js +2 -0
  64. package/lib/esm/entry/dependenciesAny/dependenciesDotPow.generated.js +2 -0
  65. package/lib/esm/entry/dependenciesAny/dependenciesEqual.generated.js +2 -0
  66. package/lib/esm/entry/dependenciesAny/dependenciesLarger.generated.js +2 -0
  67. package/lib/esm/entry/dependenciesAny/dependenciesLargerEq.generated.js +2 -0
  68. package/lib/esm/entry/dependenciesAny/dependenciesLog.generated.js +2 -0
  69. package/lib/esm/entry/dependenciesAny/dependenciesSimplify.generated.js +2 -0
  70. package/lib/esm/entry/dependenciesAny/dependenciesSmaller.generated.js +2 -0
  71. package/lib/esm/entry/dependenciesAny/dependenciesSmallerEq.generated.js +2 -0
  72. package/lib/esm/entry/dependenciesAny/dependenciesUnequal.generated.js +2 -0
  73. package/lib/esm/entry/dependenciesAny/dependenciesXor.generated.js +2 -0
  74. package/lib/esm/entry/dependenciesNumber/dependenciesSimplify.generated.js +2 -0
  75. package/lib/esm/entry/impureFunctionsAny.generated.js +1 -0
  76. package/lib/esm/entry/impureFunctionsNumber.generated.js +1 -0
  77. package/lib/esm/entry/pureFunctionsAny.generated.js +11 -0
  78. package/lib/esm/expression/embeddedDocs/function/arithmetic/ceil.js +2 -2
  79. package/lib/esm/expression/embeddedDocs/function/arithmetic/fix.js +2 -2
  80. package/lib/esm/expression/embeddedDocs/function/arithmetic/floor.js +2 -2
  81. package/lib/esm/expression/parse.js +26 -36
  82. package/lib/esm/function/algebra/simplify.js +4 -3
  83. package/lib/esm/function/algebra/simplifyConstant.js +5 -11
  84. package/lib/esm/function/arithmetic/ceil.js +21 -2
  85. package/lib/esm/function/arithmetic/dotDivide.js +4 -3
  86. package/lib/esm/function/arithmetic/dotPow.js +4 -3
  87. package/lib/esm/function/arithmetic/fix.js +24 -5
  88. package/lib/esm/function/arithmetic/floor.js +21 -2
  89. package/lib/esm/function/arithmetic/log.js +12 -4
  90. package/lib/esm/function/arithmetic/pow.js +2 -2
  91. package/lib/esm/function/arithmetic/round.js +3 -5
  92. package/lib/esm/function/arithmetic/sign.js +1 -1
  93. package/lib/esm/function/bitwise/bitXor.js +4 -3
  94. package/lib/esm/function/logical/xor.js +4 -3
  95. package/lib/esm/function/matrix/filter.js +7 -0
  96. package/lib/esm/function/matrix/forEach.js +7 -0
  97. package/lib/esm/function/relational/equal.js +4 -3
  98. package/lib/esm/function/relational/larger.js +4 -3
  99. package/lib/esm/function/relational/largerEq.js +4 -3
  100. package/lib/esm/function/relational/smaller.js +4 -3
  101. package/lib/esm/function/relational/smallerEq.js +4 -3
  102. package/lib/esm/function/relational/unequal.js +4 -3
  103. package/lib/esm/function/utils/isInteger.js +1 -1
  104. package/lib/esm/function/utils/isNegative.js +1 -1
  105. package/lib/esm/function/utils/isPositive.js +1 -1
  106. package/lib/esm/type/bignumber/function/bignumber.js +2 -2
  107. package/lib/esm/type/fraction/Fraction.js +4 -4
  108. package/lib/esm/type/fraction/function/fraction.js +3 -0
  109. package/lib/esm/type/matrix/utils/matAlgo07xSSf.js +39 -43
  110. package/lib/esm/type/unit/Unit.js +1 -1
  111. package/lib/esm/utils/object.js +4 -0
  112. package/lib/esm/utils/string.js +2 -2
  113. package/lib/esm/version.js +1 -1
  114. package/package.json +3 -3
  115. package/types/index.d.ts +115 -25
@@ -11,7 +11,7 @@ var _matAlgo11xS0s = require("../../type/matrix/utils/matAlgo11xS0s.js");
11
11
  var _matAlgo12xSfs = require("../../type/matrix/utils/matAlgo12xSfs.js");
12
12
  var _matrixAlgorithmSuite = require("../../type/matrix/utils/matrixAlgorithmSuite.js");
13
13
  const name = 'dotPow';
14
- const dependencies = ['typed', 'equalScalar', 'matrix', 'pow', 'DenseMatrix', 'concat'];
14
+ const dependencies = ['typed', 'equalScalar', 'matrix', 'pow', 'DenseMatrix', 'concat', 'SparseMatrix'];
15
15
  const createDotPow = exports.createDotPow = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
16
16
  let {
17
17
  typed,
@@ -19,14 +19,15 @@ const createDotPow = exports.createDotPow = /* #__PURE__ */(0, _factory.factory)
19
19
  matrix,
20
20
  pow,
21
21
  DenseMatrix,
22
- concat
22
+ concat,
23
+ SparseMatrix
23
24
  } = _ref;
24
25
  const matAlgo03xDSf = (0, _matAlgo03xDSf.createMatAlgo03xDSf)({
25
26
  typed
26
27
  });
27
28
  const matAlgo07xSSf = (0, _matAlgo07xSSf.createMatAlgo07xSSf)({
28
29
  typed,
29
- DenseMatrix
30
+ SparseMatrix
30
31
  });
31
32
  const matAlgo11xS0s = (0, _matAlgo11xS0s.createMatAlgo11xS0s)({
32
33
  typed,
@@ -56,6 +56,8 @@ const createFix = exports.createFix = /* #__PURE__ */(0, _factory.factory)(name,
56
56
  *
57
57
  * math.fix(x)
58
58
  * math.fix(x,n)
59
+ * math.fix(unit, valuelessUnit)
60
+ * math.fix(unit, n, valuelessUnit)
59
61
  *
60
62
  * Examples:
61
63
  *
@@ -73,6 +75,12 @@ const createFix = exports.createFix = /* #__PURE__ */(0, _factory.factory)(name,
73
75
  * math.fix(c) // returns Complex 3 - 2i
74
76
  * math.fix(c, 1) // returns Complex 3.2 -2.7i
75
77
  *
78
+ * const unit = math.unit('3.241 cm')
79
+ * const cm = math.unit('cm')
80
+ * const mm = math.unit('mm')
81
+ * math.fix(unit, 1, cm) // returns Unit 3.2 cm
82
+ * math.fix(unit, 1, mm) // returns Unit 32.4 mm
83
+ *
76
84
  * math.fix([3.2, 3.8, -4.7]) // returns Array [3, 3, -4]
77
85
  * math.fix([3.2, 3.8, -4.7], 1) // returns Array [3.2, 3.8, -4.7]
78
86
  *
@@ -80,9 +88,10 @@ const createFix = exports.createFix = /* #__PURE__ */(0, _factory.factory)(name,
80
88
  *
81
89
  * ceil, floor, round
82
90
  *
83
- * @param {number | BigNumber | Fraction | Complex | Array | Matrix} x Number to be rounded
84
- * @param {number | BigNumber | Array} [n=0] Number of decimals
85
- * @return {number | BigNumber | Fraction | Complex | Array | Matrix} Rounded value
91
+ * @param {number | BigNumber | Fraction | Complex | Unit | Array | Matrix} x Value to be rounded
92
+ * @param {number | BigNumber | Array} [n=0] Number of decimals
93
+ * @param {Unit} [valuelessUnit] A valueless unit
94
+ * @return {number | BigNumber | Fraction | Complex | Unit | Array | Matrix} Rounded value
86
95
  */
87
96
  return typed('fix', {
88
97
  number: fixNumber.signatures.number,
@@ -104,11 +113,21 @@ const createFix = exports.createFix = /* #__PURE__ */(0, _factory.factory)(name,
104
113
  return x.isNegative() ? ceil(x, n) : floor(x, n);
105
114
  },
106
115
  Fraction: function (x) {
107
- return x.s < 0 ? x.ceil() : x.floor();
116
+ return x.s < 0n ? x.ceil() : x.floor();
108
117
  },
109
118
  'Fraction, number | BigNumber': function (x, n) {
110
- return x.s < 0 ? ceil(x, n) : floor(x, n);
119
+ return x.s < 0n ? ceil(x, n) : floor(x, n);
111
120
  },
121
+ 'Unit, number, Unit': typed.referToSelf(self => function (x, n, unit) {
122
+ const valueless = x.toNumeric(unit);
123
+ return unit.multiply(self(valueless, n));
124
+ }),
125
+ 'Unit, BigNumber, Unit': typed.referToSelf(self => (x, n, unit) => self(x, n.toNumber(), unit)),
126
+ 'Array | Matrix, number | BigNumber, Unit': typed.referToSelf(self => (x, n, unit) => {
127
+ // deep map collection, skip zeros since fix(0) = 0
128
+ return (0, _collection.deepMap)(x, value => self(value, n, unit), true);
129
+ }),
130
+ 'Array | Matrix | Unit, Unit': typed.referToSelf(self => (x, unit) => self(x, 0, unit)),
112
131
  'Array | Matrix': typed.referToSelf(self => x => {
113
132
  // deep map collection, skip zeros since fix(0) = 0
114
133
  return (0, _collection.deepMap)(x, self, true);
@@ -75,6 +75,8 @@ const createFloor = exports.createFloor = /* #__PURE__ */(0, _factory.factory)(n
75
75
  *
76
76
  * math.floor(x)
77
77
  * math.floor(x, n)
78
+ * math.floor(unit, valuelessUnit)
79
+ * math.floor(unit, n, valuelessUnit)
78
80
  *
79
81
  * Examples:
80
82
  *
@@ -92,6 +94,12 @@ const createFloor = exports.createFloor = /* #__PURE__ */(0, _factory.factory)(n
92
94
  * math.floor(c) // returns Complex 3 - 3i
93
95
  * math.floor(c, 1) // returns Complex 3.2 -2.8i
94
96
  *
97
+ * const unit = math.unit('3.241 cm')
98
+ * const cm = math.unit('cm')
99
+ * const mm = math.unit('mm')
100
+ * math.floor(unit, 1, cm) // returns Unit 3.2 cm
101
+ * math.floor(unit, 1, mm) // returns Unit 32.4 mm
102
+ *
95
103
  * math.floor([3.2, 3.8, -4.7]) // returns Array [3, 3, -5]
96
104
  * math.floor([3.21, 3.82, -4.71], 1) // returns Array [3.2, 3.8, -4.8]
97
105
  *
@@ -103,9 +111,10 @@ const createFloor = exports.createFloor = /* #__PURE__ */(0, _factory.factory)(n
103
111
  *
104
112
  * ceil, fix, round
105
113
  *
106
- * @param {number | BigNumber | Fraction | Complex | Array | Matrix} x Number to be rounded
114
+ * @param {number | BigNumber | Fraction | Complex | Unit | Array | Matrix} x Value to be rounded
107
115
  * @param {number | BigNumber | Array} [n=0] Number of decimals
108
- * @return {number | BigNumber | Fraction | Complex | Array | Matrix} Rounded value
116
+ * @param {Unit} [valuelessUnit] A valueless unit
117
+ * @return {number | BigNumber | Fraction | Complex | Unit | Array | Matrix} Rounded value
109
118
  */
110
119
  return typed('floor', {
111
120
  number: floorNumber.signatures.number,
@@ -142,6 +151,16 @@ const createFloor = exports.createFloor = /* #__PURE__ */(0, _factory.factory)(n
142
151
  'Fraction, BigNumber': function (x, n) {
143
152
  return x.floor(n.toNumber());
144
153
  },
154
+ 'Unit, number, Unit': typed.referToSelf(self => function (x, n, unit) {
155
+ const valueless = x.toNumeric(unit);
156
+ return unit.multiply(self(valueless, n));
157
+ }),
158
+ 'Unit, BigNumber, Unit': typed.referToSelf(self => (x, n, unit) => self(x, n.toNumber(), unit)),
159
+ 'Array | Matrix, number | BigNumber, Unit': typed.referToSelf(self => (x, n, unit) => {
160
+ // deep map collection, skip zeros since floor(0) = 0
161
+ return (0, _collection.deepMap)(x, value => self(value, n, unit), true);
162
+ }),
163
+ 'Array | Matrix | Unit, Unit': typed.referToSelf(self => (x, unit) => self(x, 0, unit)),
145
164
  'Array | Matrix': typed.referToSelf(self => x => {
146
165
  // deep map collection, skip zeros since floor(0) = 0
147
166
  return (0, _collection.deepMap)(x, self, true);
@@ -7,10 +7,11 @@ exports.createLog = void 0;
7
7
  var _factory = require("../../utils/factory.js");
8
8
  var _index = require("../../plain/number/index.js");
9
9
  const name = 'log';
10
- const dependencies = ['config', 'typed', 'divideScalar', 'Complex'];
10
+ const dependencies = ['config', 'typed', 'typeOf', 'divideScalar', 'Complex'];
11
11
  const createLog = exports.createLog = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
12
12
  let {
13
13
  typed,
14
+ typeOf,
14
15
  config,
15
16
  divideScalar,
16
17
  Complex
@@ -42,12 +43,12 @@ const createLog = exports.createLog = /* #__PURE__ */(0, _factory.factory)(name,
42
43
  *
43
44
  * exp, log2, log10, log1p
44
45
  *
45
- * @param {number | BigNumber | Complex} x
46
+ * @param {number | BigNumber | Fraction | Complex} x
46
47
  * Value for which to calculate the logarithm.
47
- * @param {number | BigNumber | Complex} [base=e]
48
+ * @param {number | BigNumber | Fraction | Complex} [base=e]
48
49
  * Optional base for the logarithm. If not provided, the natural
49
50
  * logarithm of `x` is calculated.
50
- * @return {number | BigNumber | Complex}
51
+ * @return {number | BigNumber | Fraction | Complex}
51
52
  * Returns the logarithm of `x`
52
53
  */
53
54
  return typed(name, {
@@ -72,6 +73,13 @@ const createLog = exports.createLog = /* #__PURE__ */(0, _factory.factory)(name,
72
73
  },
73
74
  'any, any': typed.referToSelf(self => (x, base) => {
74
75
  // calculate logarithm for a specified base, log(x, base)
76
+
77
+ if (typeOf(x) === 'Fraction' && typeOf(base) === 'Fraction') {
78
+ const result = x.log(base);
79
+ if (result !== null) {
80
+ return result;
81
+ }
82
+ }
75
83
  return divideScalar(self(x), self(base));
76
84
  })
77
85
  });
@@ -113,8 +113,8 @@ const createPow = exports.createPow = /* #__PURE__ */(0, _factory.factory)(name,
113
113
  const yFrac = fraction(y);
114
114
  const yNum = number(yFrac);
115
115
  if (y === yNum || Math.abs((y - yNum) / y) < 1e-14) {
116
- if (yFrac.d % 2 === 1) {
117
- return (yFrac.n % 2 === 0 ? 1 : -1) * Math.pow(-x, y);
116
+ if (yFrac.d % 2n === 1n) {
117
+ return (yFrac.n % 2n === 0n ? 1 : -1) * Math.pow(-x, y);
118
118
  }
119
119
  }
120
120
  } catch (ex) {
@@ -82,7 +82,7 @@ const createRound = exports.createRound = /* #__PURE__ */(0, _factory.factory)(n
82
82
  * @param {number | BigNumber | Fraction | Complex | Unit | Array | Matrix} x Value to be rounded
83
83
  * @param {number | BigNumber | Array} [n=0] Number of decimals
84
84
  * @param {Unit} [valuelessUnit] A valueless unit
85
- * @return {number | BigNumber | Fraction | Complex | Array | Matrix} Rounded value
85
+ * @return {number | BigNumber | Fraction | Complex | Unit | Array | Matrix} Rounded value
86
86
  */
87
87
  return typed(name, {
88
88
  number: function (x) {
@@ -163,13 +163,11 @@ const createRound = exports.createRound = /* #__PURE__ */(0, _factory.factory)(n
163
163
  return unit.multiply(self(valueless, n));
164
164
  }),
165
165
  'Unit, BigNumber, Unit': typed.referToSelf(self => (x, n, unit) => self(x, n.toNumber(), unit)),
166
- 'Unit, Unit': typed.referToSelf(self => (x, unit) => self(x, 0, unit)),
167
- 'Array | Matrix, number, Unit': typed.referToSelf(self => (x, n, unit) => {
166
+ 'Array | Matrix, number | BigNumber, Unit': typed.referToSelf(self => (x, n, unit) => {
168
167
  // deep map collection, skip zeros since round(0) = 0
169
168
  return (0, _collection.deepMap)(x, value => self(value, n, unit), true);
170
169
  }),
171
- 'Array | Matrix, BigNumber, Unit': typed.referToSelf(self => (x, n, unit) => self(x, n.toNumber(), unit)),
172
- 'Array | Matrix, Unit': typed.referToSelf(self => (x, unit) => self(x, 0, unit)),
170
+ 'Array | Matrix | Unit, Unit': typed.referToSelf(self => (x, unit) => self(x, 0, unit)),
173
171
  'Array | Matrix': typed.referToSelf(self => x => {
174
172
  // deep map collection, skip zeros since round(0) = 0
175
173
  return (0, _collection.deepMap)(x, self, true);
@@ -58,7 +58,7 @@ const createSign = exports.createSign = /* #__PURE__ */(0, _factory.factory)(nam
58
58
  return x > 0n ? 1n : x < 0n ? -1n : 0n;
59
59
  },
60
60
  Fraction: function (x) {
61
- return new Fraction(x.s, 1);
61
+ return new Fraction(x.s);
62
62
  },
63
63
  // deep map collection, skip zeros since sign(0) = 0
64
64
  'Array | Matrix': typed.referToSelf(self => x => (0, _collection.deepMap)(x, self, true)),
@@ -12,20 +12,21 @@ var _factory = require("../../utils/factory.js");
12
12
  var _matrixAlgorithmSuite = require("../../type/matrix/utils/matrixAlgorithmSuite.js");
13
13
  var _index = require("../../plain/number/index.js");
14
14
  const name = 'bitXor';
15
- const dependencies = ['typed', 'matrix', 'DenseMatrix', 'concat'];
15
+ const dependencies = ['typed', 'matrix', 'DenseMatrix', 'concat', 'SparseMatrix'];
16
16
  const createBitXor = exports.createBitXor = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
17
17
  let {
18
18
  typed,
19
19
  matrix,
20
20
  DenseMatrix,
21
- concat
21
+ concat,
22
+ SparseMatrix
22
23
  } = _ref;
23
24
  const matAlgo03xDSf = (0, _matAlgo03xDSf.createMatAlgo03xDSf)({
24
25
  typed
25
26
  });
26
27
  const matAlgo07xSSf = (0, _matAlgo07xSSf.createMatAlgo07xSSf)({
27
28
  typed,
28
- DenseMatrix
29
+ SparseMatrix
29
30
  });
30
31
  const matAlgo12xSfs = (0, _matAlgo12xSfs.createMatAlgo12xSfs)({
31
32
  typed,
@@ -11,20 +11,21 @@ var _factory = require("../../utils/factory.js");
11
11
  var _matrixAlgorithmSuite = require("../../type/matrix/utils/matrixAlgorithmSuite.js");
12
12
  var _index = require("../../plain/number/index.js");
13
13
  const name = 'xor';
14
- const dependencies = ['typed', 'matrix', 'DenseMatrix', 'concat'];
14
+ const dependencies = ['typed', 'matrix', 'DenseMatrix', 'concat', 'SparseMatrix'];
15
15
  const createXor = exports.createXor = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
16
16
  let {
17
17
  typed,
18
18
  matrix,
19
19
  DenseMatrix,
20
- concat
20
+ concat,
21
+ SparseMatrix
21
22
  } = _ref;
22
23
  const matAlgo03xDSf = (0, _matAlgo03xDSf.createMatAlgo03xDSf)({
23
24
  typed
24
25
  });
25
26
  const matAlgo07xSSf = (0, _matAlgo07xSSf.createMatAlgo07xSSf)({
26
27
  typed,
27
- DenseMatrix
28
+ SparseMatrix
28
29
  });
29
30
  const matAlgo12xSfs = (0, _matAlgo12xSfs.createMatAlgo12xSfs)({
30
31
  typed,
@@ -16,6 +16,13 @@ const createFilter = exports.createFilter = /* #__PURE__ */(0, _factory.factory)
16
16
  /**
17
17
  * Filter the items in an array or one dimensional matrix.
18
18
  *
19
+ * The callback is invoked with three arguments: the current value,
20
+ * the current index, and the matrix operated upon.
21
+ * Note that because the matrix/array might be
22
+ * multidimensional, the "index" argument is always an array of numbers giving
23
+ * the index in each dimension. This is true even for vectors: the "index"
24
+ * argument is an array of length 1, rather than simply a number.
25
+ *
19
26
  * Syntax:
20
27
  *
21
28
  * math.filter(x, test)
@@ -16,6 +16,13 @@ const createForEach = exports.createForEach = /* #__PURE__ */(0, _factory.factor
16
16
  /**
17
17
  * Iterate over all elements of a matrix/array, and executes the given callback function.
18
18
  *
19
+ * The callback is invoked with three arguments: the current value,
20
+ * the current index, and the matrix operated upon.
21
+ * Note that because the matrix/array might be
22
+ * multidimensional, the "index" argument is always an array of numbers giving
23
+ * the index in each dimension. This is true even for vectors: the "index"
24
+ * argument is an array of length 1, rather than simply a number.
25
+ *
19
26
  * Syntax:
20
27
  *
21
28
  * math.forEach(x, callback)
@@ -10,21 +10,22 @@ var _matAlgo07xSSf = require("../../type/matrix/utils/matAlgo07xSSf.js");
10
10
  var _matAlgo12xSfs = require("../../type/matrix/utils/matAlgo12xSfs.js");
11
11
  var _matrixAlgorithmSuite = require("../../type/matrix/utils/matrixAlgorithmSuite.js");
12
12
  const name = 'equal';
13
- const dependencies = ['typed', 'matrix', 'equalScalar', 'DenseMatrix', 'concat'];
13
+ const dependencies = ['typed', 'matrix', 'equalScalar', 'DenseMatrix', 'concat', 'SparseMatrix'];
14
14
  const createEqual = exports.createEqual = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
15
15
  let {
16
16
  typed,
17
17
  matrix,
18
18
  equalScalar,
19
19
  DenseMatrix,
20
- concat
20
+ concat,
21
+ SparseMatrix
21
22
  } = _ref;
22
23
  const matAlgo03xDSf = (0, _matAlgo03xDSf.createMatAlgo03xDSf)({
23
24
  typed
24
25
  });
25
26
  const matAlgo07xSSf = (0, _matAlgo07xSSf.createMatAlgo07xSSf)({
26
27
  typed,
27
- DenseMatrix
28
+ SparseMatrix
28
29
  });
29
30
  const matAlgo12xSfs = (0, _matAlgo12xSfs.createMatAlgo12xSfs)({
30
31
  typed,
@@ -13,21 +13,22 @@ var _matAlgo12xSfs = require("../../type/matrix/utils/matAlgo12xSfs.js");
13
13
  var _matrixAlgorithmSuite = require("../../type/matrix/utils/matrixAlgorithmSuite.js");
14
14
  var _compareUnits = require("./compareUnits.js");
15
15
  const name = 'larger';
16
- const dependencies = ['typed', 'config', 'matrix', 'DenseMatrix', 'concat'];
16
+ const dependencies = ['typed', 'config', 'matrix', 'DenseMatrix', 'concat', 'SparseMatrix'];
17
17
  const createLarger = exports.createLarger = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
18
18
  let {
19
19
  typed,
20
20
  config,
21
21
  matrix,
22
22
  DenseMatrix,
23
- concat
23
+ concat,
24
+ SparseMatrix
24
25
  } = _ref;
25
26
  const matAlgo03xDSf = (0, _matAlgo03xDSf.createMatAlgo03xDSf)({
26
27
  typed
27
28
  });
28
29
  const matAlgo07xSSf = (0, _matAlgo07xSSf.createMatAlgo07xSSf)({
29
30
  typed,
30
- DenseMatrix
31
+ SparseMatrix
31
32
  });
32
33
  const matAlgo12xSfs = (0, _matAlgo12xSfs.createMatAlgo12xSfs)({
33
34
  typed,
@@ -13,21 +13,22 @@ var _matAlgo12xSfs = require("../../type/matrix/utils/matAlgo12xSfs.js");
13
13
  var _matrixAlgorithmSuite = require("../../type/matrix/utils/matrixAlgorithmSuite.js");
14
14
  var _compareUnits = require("./compareUnits.js");
15
15
  const name = 'largerEq';
16
- const dependencies = ['typed', 'config', 'matrix', 'DenseMatrix', 'concat'];
16
+ const dependencies = ['typed', 'config', 'matrix', 'DenseMatrix', 'concat', 'SparseMatrix'];
17
17
  const createLargerEq = exports.createLargerEq = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
18
18
  let {
19
19
  typed,
20
20
  config,
21
21
  matrix,
22
22
  DenseMatrix,
23
- concat
23
+ concat,
24
+ SparseMatrix
24
25
  } = _ref;
25
26
  const matAlgo03xDSf = (0, _matAlgo03xDSf.createMatAlgo03xDSf)({
26
27
  typed
27
28
  });
28
29
  const matAlgo07xSSf = (0, _matAlgo07xSSf.createMatAlgo07xSSf)({
29
30
  typed,
30
- DenseMatrix
31
+ SparseMatrix
31
32
  });
32
33
  const matAlgo12xSfs = (0, _matAlgo12xSfs.createMatAlgo12xSfs)({
33
34
  typed,
@@ -13,21 +13,22 @@ var _matAlgo12xSfs = require("../../type/matrix/utils/matAlgo12xSfs.js");
13
13
  var _matrixAlgorithmSuite = require("../../type/matrix/utils/matrixAlgorithmSuite.js");
14
14
  var _compareUnits = require("./compareUnits.js");
15
15
  const name = 'smaller';
16
- const dependencies = ['typed', 'config', 'matrix', 'DenseMatrix', 'concat'];
16
+ const dependencies = ['typed', 'config', 'matrix', 'DenseMatrix', 'concat', 'SparseMatrix'];
17
17
  const createSmaller = exports.createSmaller = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
18
18
  let {
19
19
  typed,
20
20
  config,
21
21
  matrix,
22
22
  DenseMatrix,
23
- concat
23
+ concat,
24
+ SparseMatrix
24
25
  } = _ref;
25
26
  const matAlgo03xDSf = (0, _matAlgo03xDSf.createMatAlgo03xDSf)({
26
27
  typed
27
28
  });
28
29
  const matAlgo07xSSf = (0, _matAlgo07xSSf.createMatAlgo07xSSf)({
29
30
  typed,
30
- DenseMatrix
31
+ SparseMatrix
31
32
  });
32
33
  const matAlgo12xSfs = (0, _matAlgo12xSfs.createMatAlgo12xSfs)({
33
34
  typed,
@@ -13,21 +13,22 @@ var _matAlgo12xSfs = require("../../type/matrix/utils/matAlgo12xSfs.js");
13
13
  var _matrixAlgorithmSuite = require("../../type/matrix/utils/matrixAlgorithmSuite.js");
14
14
  var _compareUnits = require("./compareUnits.js");
15
15
  const name = 'smallerEq';
16
- const dependencies = ['typed', 'config', 'matrix', 'DenseMatrix', 'concat'];
16
+ const dependencies = ['typed', 'config', 'matrix', 'DenseMatrix', 'concat', 'SparseMatrix'];
17
17
  const createSmallerEq = exports.createSmallerEq = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
18
18
  let {
19
19
  typed,
20
20
  config,
21
21
  matrix,
22
22
  DenseMatrix,
23
- concat
23
+ concat,
24
+ SparseMatrix
24
25
  } = _ref;
25
26
  const matAlgo03xDSf = (0, _matAlgo03xDSf.createMatAlgo03xDSf)({
26
27
  typed
27
28
  });
28
29
  const matAlgo07xSSf = (0, _matAlgo07xSSf.createMatAlgo07xSSf)({
29
30
  typed,
30
- DenseMatrix
31
+ SparseMatrix
31
32
  });
32
33
  const matAlgo12xSfs = (0, _matAlgo12xSfs.createMatAlgo12xSfs)({
33
34
  typed,
@@ -10,7 +10,7 @@ var _matAlgo07xSSf = require("../../type/matrix/utils/matAlgo07xSSf.js");
10
10
  var _matAlgo12xSfs = require("../../type/matrix/utils/matAlgo12xSfs.js");
11
11
  var _matrixAlgorithmSuite = require("../../type/matrix/utils/matrixAlgorithmSuite.js");
12
12
  const name = 'unequal';
13
- const dependencies = ['typed', 'config', 'equalScalar', 'matrix', 'DenseMatrix', 'concat'];
13
+ const dependencies = ['typed', 'config', 'equalScalar', 'matrix', 'DenseMatrix', 'concat', 'SparseMatrix'];
14
14
  const createUnequal = exports.createUnequal = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
15
15
  let {
16
16
  typed,
@@ -18,14 +18,15 @@ const createUnequal = exports.createUnequal = /* #__PURE__ */(0, _factory.factor
18
18
  equalScalar,
19
19
  matrix,
20
20
  DenseMatrix,
21
- concat
21
+ concat,
22
+ SparseMatrix
22
23
  } = _ref;
23
24
  const matAlgo03xDSf = (0, _matAlgo03xDSf.createMatAlgo03xDSf)({
24
25
  typed
25
26
  });
26
27
  const matAlgo07xSSf = (0, _matAlgo07xSSf.createMatAlgo07xSSf)({
27
28
  typed,
28
- DenseMatrix
29
+ SparseMatrix
29
30
  });
30
31
  const matAlgo12xSfs = (0, _matAlgo12xSfs.createMatAlgo12xSfs)({
31
32
  typed,
@@ -53,7 +53,7 @@ const createIsInteger = exports.createIsInteger = /* #__PURE__ */(0, _factory.fa
53
53
  return true;
54
54
  },
55
55
  Fraction: function (x) {
56
- return x.d === 1 && isFinite(x.n);
56
+ return x.d === 1n;
57
57
  },
58
58
  'Array | Matrix': typed.referToSelf(self => x => (0, _collection.deepMap)(x, self))
59
59
  });
@@ -49,7 +49,7 @@ const createIsNegative = exports.createIsNegative = /* #__PURE__ */(0, _factory.
49
49
  number: x => (0, _number.nearlyEqual)(x, 0, config.relTol, config.absTol) ? false : (0, _index.isNegativeNumber)(x),
50
50
  BigNumber: x => (0, _nearlyEqual.nearlyEqual)(x, new x.constructor(0), config.relTol, config.absTol) ? false : x.isNeg() && !x.isZero() && !x.isNaN(),
51
51
  bigint: x => x < 0n,
52
- Fraction: x => x.s < 0,
52
+ Fraction: x => x.s < 0n,
53
53
  // It's enough to decide on the sign
54
54
 
55
55
  Unit: typed.referToSelf(self => x => typed.find(self, x.valueType())(x.value)),
@@ -51,7 +51,7 @@ const createIsPositive = exports.createIsPositive = /* #__PURE__ */(0, _factory.
51
51
  number: x => (0, _number.nearlyEqual)(x, 0, config.relTol, config.absTol) ? false : (0, _index.isPositiveNumber)(x),
52
52
  BigNumber: x => (0, _nearlyEqual.nearlyEqual)(x, new x.constructor(0), config.relTol, config.absTol) ? false : !x.isNeg() && !x.isZero() && !x.isNaN(),
53
53
  bigint: x => x > 0n,
54
- Fraction: x => x.s > 0 && x.n > 0,
54
+ Fraction: x => x.s > 0n && x.n > 0n,
55
55
  Unit: typed.referToSelf(self => x => typed.find(self, x.valueType())(x.value)),
56
56
  'Array | Matrix': typed.referToSelf(self => x => (0, _collection.deepMap)(x, self))
57
57
  });
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 13.2.2
10
- * @date 2024-11-13
9
+ * @version 14.0.0
10
+ * @date 2024-11-20
11
11
  *
12
12
  * @license
13
13
  * Copyright (C) 2013-2024 Jos de Jong <wjosdejong@gmail.com>
@@ -78,9 +78,9 @@ const createBignumber = exports.createBignumber = /* #__PURE__ */(0, _factory.fa
78
78
  return clone;
79
79
  }),
80
80
  Fraction: function (x) {
81
- return new BigNumber(x.n).div(x.d).times(x.s);
81
+ return new BigNumber(String(x.n)).div(String(x.d)).times(String(x.s));
82
82
  },
83
- null: function (x) {
83
+ null: function (_x) {
84
84
  return new BigNumber(0);
85
85
  },
86
86
  'Array | Matrix': typed.referToSelf(self => x => (0, _collection.deepMap)(x, self))
@@ -23,20 +23,20 @@ const createFractionClass = exports.createFractionClass = /* #__PURE__ */(0, _fa
23
23
  /**
24
24
  * Get a JSON representation of a Fraction containing type information
25
25
  * @returns {Object} Returns a JSON object structured as:
26
- * `{"mathjs": "Fraction", "n": 3, "d": 8}`
26
+ * `{"mathjs": "Fraction", "n": "3", "d": "8"}`
27
27
  */
28
28
  _fraction.default.prototype.toJSON = function () {
29
29
  return {
30
30
  mathjs: 'Fraction',
31
- n: this.s * this.n,
32
- d: this.d
31
+ n: String(this.s * this.n),
32
+ d: String(this.d)
33
33
  };
34
34
  };
35
35
 
36
36
  /**
37
37
  * Instantiate a Fraction from a JSON object
38
38
  * @param {Object} json a JSON object structured as:
39
- * `{"mathjs": "Fraction", "n": 3, "d": 8}`
39
+ * `{"mathjs": "Fraction", "n": "3", "d": "8"}`
40
40
  * @return {BigNumber}
41
41
  */
42
42
  _fraction.default.fromJSON = function (json) {
@@ -63,6 +63,9 @@ const createFraction = exports.createFraction = /* #__PURE__ */(0, _factory.fact
63
63
  'number, number': function (numerator, denominator) {
64
64
  return new Fraction(numerator, denominator);
65
65
  },
66
+ 'bigint, bigint': function (numerator, denominator) {
67
+ return new Fraction(numerator, denominator);
68
+ },
66
69
  null: function (x) {
67
70
  return new Fraction(0);
68
71
  },