mathjs 11.3.2 → 11.4.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.
Files changed (57) hide show
  1. package/HISTORY.md +25 -0
  2. package/lib/browser/math.js +1 -1
  3. package/lib/browser/math.js.LICENSE.txt +2 -2
  4. package/lib/browser/math.js.map +1 -1
  5. package/lib/cjs/entry/dependenciesAny/dependenciesLyap.generated.js +26 -0
  6. package/lib/cjs/entry/dependenciesAny/dependenciesPolynomialRoot.generated.js +42 -0
  7. package/lib/cjs/entry/dependenciesAny/dependenciesSchur.generated.js +30 -0
  8. package/lib/cjs/entry/dependenciesAny/dependenciesSylvester.generated.js +46 -0
  9. package/lib/cjs/entry/dependenciesAny.generated.js +28 -0
  10. package/lib/cjs/entry/impureFunctionsAny.generated.js +21 -17
  11. package/lib/cjs/entry/pureFunctionsAny.generated.js +100 -48
  12. package/lib/cjs/expression/embeddedDocs/embeddedDocs.js +8 -0
  13. package/lib/cjs/expression/embeddedDocs/function/algebra/polynomialRoot.js +15 -0
  14. package/lib/cjs/expression/embeddedDocs/function/arithmetic/sqrtm.js +1 -1
  15. package/lib/cjs/expression/embeddedDocs/function/matrix/lyap.js +15 -0
  16. package/lib/cjs/expression/embeddedDocs/function/matrix/schur.js +15 -0
  17. package/lib/cjs/expression/embeddedDocs/function/matrix/sylvester.js +15 -0
  18. package/lib/cjs/factoriesAny.js +28 -0
  19. package/lib/cjs/function/algebra/decomposition/schur.js +75 -0
  20. package/lib/cjs/function/algebra/lyap.js +57 -0
  21. package/lib/cjs/function/algebra/polynomialRoot.js +139 -0
  22. package/lib/cjs/function/algebra/simplify/wildcards.js +38 -0
  23. package/lib/cjs/function/algebra/simplify.js +104 -44
  24. package/lib/cjs/function/algebra/simplifyConstant.js +29 -12
  25. package/lib/cjs/function/algebra/sylvester.js +127 -0
  26. package/lib/cjs/function/matrix/forEach.js +1 -1
  27. package/lib/cjs/function/matrix/sqrtm.js +1 -1
  28. package/lib/cjs/header.js +2 -2
  29. package/lib/cjs/type/matrix/SparseMatrix.js +4 -2
  30. package/lib/cjs/version.js +1 -1
  31. package/lib/esm/entry/dependenciesAny/dependenciesLyap.generated.js +18 -0
  32. package/lib/esm/entry/dependenciesAny/dependenciesPolynomialRoot.generated.js +34 -0
  33. package/lib/esm/entry/dependenciesAny/dependenciesSchur.generated.js +22 -0
  34. package/lib/esm/entry/dependenciesAny/dependenciesSylvester.generated.js +38 -0
  35. package/lib/esm/entry/dependenciesAny.generated.js +4 -0
  36. package/lib/esm/entry/impureFunctionsAny.generated.js +22 -18
  37. package/lib/esm/entry/pureFunctionsAny.generated.js +87 -39
  38. package/lib/esm/expression/embeddedDocs/embeddedDocs.js +8 -0
  39. package/lib/esm/expression/embeddedDocs/function/algebra/polynomialRoot.js +8 -0
  40. package/lib/esm/expression/embeddedDocs/function/arithmetic/sqrtm.js +1 -1
  41. package/lib/esm/expression/embeddedDocs/function/matrix/lyap.js +8 -0
  42. package/lib/esm/expression/embeddedDocs/function/matrix/schur.js +8 -0
  43. package/lib/esm/expression/embeddedDocs/function/matrix/sylvester.js +8 -0
  44. package/lib/esm/factoriesAny.js +4 -0
  45. package/lib/esm/function/algebra/decomposition/schur.js +70 -0
  46. package/lib/esm/function/algebra/lyap.js +52 -0
  47. package/lib/esm/function/algebra/polynomialRoot.js +122 -0
  48. package/lib/esm/function/algebra/simplify/wildcards.js +20 -0
  49. package/lib/esm/function/algebra/simplify.js +105 -45
  50. package/lib/esm/function/algebra/simplifyConstant.js +29 -12
  51. package/lib/esm/function/algebra/sylvester.js +118 -0
  52. package/lib/esm/function/matrix/forEach.js +1 -1
  53. package/lib/esm/function/matrix/sqrtm.js +1 -1
  54. package/lib/esm/type/matrix/SparseMatrix.js +4 -2
  55. package/lib/esm/version.js +1 -1
  56. package/package.json +13 -13
  57. package/types/index.d.ts +85 -7
@@ -1,4 +1,5 @@
1
- import { isConstantNode, isParenthesisNode } from '../../utils/is.js';
1
+ import { isParenthesisNode } from '../../utils/is.js';
2
+ import { isConstantNode, isVariableNode, isNumericNode, isConstantExpression } from './simplify/wildcards.js';
2
3
  import { factory } from '../../utils/factory.js';
3
4
  import { createUtil } from './simplify/util.js';
4
5
  import { hasOwnProperty } from '../../utils/object.js';
@@ -75,9 +76,15 @@ export var createSimplify = /* #__PURE__ */factory(name, dependencies, _ref => {
75
76
  * expression is that variables starting with the following characters are
76
77
  * interpreted as wildcards:
77
78
  *
78
- * - 'n' - matches any Node
79
- * - 'c' - matches any ConstantNode
80
- * - 'v' - matches any Node that is not a ConstantNode
79
+ * - 'n' - Matches any node [Node]
80
+ * - 'c' - Matches a constant literal (5 or 3.2) [ConstantNode]
81
+ * - 'cl' - Matches a constant literal; same as c [ConstantNode]
82
+ * - 'cd' - Matches a decimal literal (5 or -3.2) [ConstantNode or unaryMinus wrapping a ConstantNode]
83
+ * - 'ce' - Matches a constant expression (-5 or √3) [Expressions consisting of only ConstantNodes, functions, and operators]
84
+ * - 'v' - Matches a variable; anything not matched by c (-5 or x) [Node that is not a ConstantNode]
85
+ * - 'vl' - Matches a variable literal (x or y) [SymbolNode]
86
+ * - 'vd' - Matches a non-decimal expression; anything not matched by cd (x or √3) [Node that is not a ConstantNode or unaryMinus that is wrapping a ConstantNode]
87
+ * - 've' - Matches a variable expression; anything not matched by ce (x or 2x) [Expressions that contain a SymbolNode or other non-constant term]
81
88
  *
82
89
  * The default list of rules is exposed on the function as `simplify.rules`
83
90
  * and can be used as a basis to built a set of custom rules. Note that since
@@ -250,7 +257,7 @@ export var createSimplify = /* #__PURE__ */factory(name, dependencies, _ref => {
250
257
  }
251
258
  }
252
259
  }, {
253
- s: '-(c*v) -> v * (-c)',
260
+ s: '-(cl*v) -> v * (-cl)',
254
261
  // make non-constant terms positive
255
262
  assuming: {
256
263
  multiply: {
@@ -261,7 +268,7 @@ export var createSimplify = /* #__PURE__ */factory(name, dependencies, _ref => {
261
268
  }
262
269
  }
263
270
  }, {
264
- s: '-(c*v) -> (-c) * v',
271
+ s: '-(cl*v) -> (-cl) * v',
265
272
  // non-commutative version, part 1
266
273
  assuming: {
267
274
  multiply: {
@@ -272,7 +279,7 @@ export var createSimplify = /* #__PURE__ */factory(name, dependencies, _ref => {
272
279
  }
273
280
  }
274
281
  }, {
275
- s: '-(v*c) -> v * (-c)',
282
+ s: '-(v*cl) -> v * (-cl)',
276
283
  // non-commutative version, part 2
277
284
  assuming: {
278
285
  multiply: {
@@ -330,24 +337,24 @@ export var createSimplify = /* #__PURE__ */factory(name, dependencies, _ref => {
330
337
  },
331
338
  // collect like factors; into a sum, only do this for nonconstants
332
339
  {
333
- l: ' v * ( v * n1 + n2)',
334
- r: 'v^2 * n1 + v * n2'
340
+ l: ' vd * ( vd * n1 + n2)',
341
+ r: 'vd^2 * n1 + vd * n2'
335
342
  }, {
336
- s: ' v * (v^n4 * n1 + n2) -> v^(1+n4) * n1 + v * n2',
343
+ s: ' vd * (vd^n4 * n1 + n2) -> vd^(1+n4) * n1 + vd * n2',
337
344
  assuming: {
338
345
  divide: {
339
346
  total: true
340
347
  }
341
348
  } // v*1/v = v^(1+-1) needs 1/v
342
349
  }, {
343
- s: 'v^n3 * ( v * n1 + n2) -> v^(n3+1) * n1 + v^n3 * n2',
350
+ s: 'vd^n3 * ( vd * n1 + n2) -> vd^(n3+1) * n1 + vd^n3 * n2',
344
351
  assuming: {
345
352
  divide: {
346
353
  total: true
347
354
  }
348
355
  }
349
356
  }, {
350
- s: 'v^n3 * (v^n4 * n1 + n2) -> v^(n3+n4) * n1 + v^n3 * n2',
357
+ s: 'vd^n3 * (vd^n4 * n1 + n2) -> vd^(n3+n4) * n1 + vd^n3 * n2',
351
358
  assuming: {
352
359
  divide: {
353
360
  total: true
@@ -390,8 +397,8 @@ export var createSimplify = /* #__PURE__ */factory(name, dependencies, _ref => {
390
397
  l: 'n+-n',
391
398
  r: '0'
392
399
  }, {
393
- l: 'v*n + v',
394
- r: 'v*(n+1)'
400
+ l: 'vd*n + vd',
401
+ r: 'vd*(n+1)'
395
402
  },
396
403
  // NOTE: leftmost position is special:
397
404
  {
@@ -406,7 +413,7 @@ export var createSimplify = /* #__PURE__ */factory(name, dependencies, _ref => {
406
413
  l: 'n3^(-n4)*n1 + n3^n5 * n2',
407
414
  r: 'n3^(-n4)*(n1 + n3^(n4+n5)*n2)'
408
415
  }, {
409
- s: 'n*v + v -> (n+1)*v',
416
+ s: 'n*vd + vd -> (n+1)*vd',
410
417
  // noncommutative additional cases
411
418
  assuming: {
412
419
  multiply: {
@@ -435,10 +442,10 @@ export var createSimplify = /* #__PURE__ */factory(name, dependencies, _ref => {
435
442
  }
436
443
  }
437
444
  }, {
438
- l: 'n*c + c',
439
- r: '(n+1)*c'
445
+ l: 'n*cd + cd',
446
+ r: '(n+1)*cd'
440
447
  }, {
441
- s: 'c*n + c -> c*(n+1)',
448
+ s: 'cd*n + cd -> cd*(n+1)',
442
449
  assuming: {
443
450
  multiply: {
444
451
  commutative: false
@@ -469,7 +476,7 @@ export var createSimplify = /* #__PURE__ */factory(name, dependencies, _ref => {
469
476
  },
470
477
  // final ordering of constants
471
478
  {
472
- s: 'c+v -> v+c',
479
+ s: 'ce+ve -> ve+ce',
473
480
  assuming: {
474
481
  add: {
475
482
  commutative: true
@@ -481,7 +488,7 @@ export var createSimplify = /* #__PURE__ */factory(name, dependencies, _ref => {
481
488
  }
482
489
  }
483
490
  }, {
484
- s: 'v*c -> c*v',
491
+ s: 'vd*cd -> cd*vd',
485
492
  assuming: {
486
493
  multiply: {
487
494
  commutative: true
@@ -1047,9 +1054,8 @@ export var createSimplify = /* #__PURE__ */factory(name, dependencies, _ref => {
1047
1054
  }
1048
1055
  } else if (rule instanceof SymbolNode) {
1049
1056
  // If the rule is a SymbolNode, then it carries a special meaning
1050
- // according to the first character of the symbol node name.
1051
- // c.* matches a ConstantNode
1052
- // n.* matches any node
1057
+ // according to the first one or two characters of the symbol node name.
1058
+ // These meanings are expalined in the documentation for simplify()
1053
1059
  if (rule.name.length === 0) {
1054
1060
  throw new Error('Symbol in rule has 0 length...!?');
1055
1061
  }
@@ -1058,29 +1064,83 @@ export var createSimplify = /* #__PURE__ */factory(name, dependencies, _ref => {
1058
1064
  if (rule.name !== node.name) {
1059
1065
  return [];
1060
1066
  }
1061
- } else if (rule.name[0] === 'n' || rule.name.substring(0, 2) === '_p') {
1062
- // rule matches _anything_, so assign this node to the rule.name placeholder
1063
- // Assign node to the rule.name placeholder.
1064
- // Our parent will check for matches among placeholders.
1065
- res[0].placeholders[rule.name] = node;
1066
- } else if (rule.name[0] === 'v') {
1067
- // rule matches any variable thing (not a ConstantNode)
1068
- if (!isConstantNode(node)) {
1069
- res[0].placeholders[rule.name] = node;
1070
- } else {
1071
- // Mis-match: rule was expecting something other than a ConstantNode
1072
- return [];
1073
- }
1074
- } else if (rule.name[0] === 'c') {
1075
- // rule matches any ConstantNode
1076
- if (node instanceof ConstantNode) {
1077
- res[0].placeholders[rule.name] = node;
1078
- } else {
1079
- // Mis-match: rule was expecting a ConstantNode
1080
- return [];
1081
- }
1082
1067
  } else {
1083
- throw new Error('Invalid symbol in rule: ' + rule.name);
1068
+ // wildcards are composed of up to two alphabetic or underscore characters
1069
+ switch (rule.name[1] >= 'a' && rule.name[1] <= 'z' ? rule.name.substring(0, 2) : rule.name[0]) {
1070
+ case 'n':
1071
+ case '_p':
1072
+ // rule matches _anything_, so assign this node to the rule.name placeholder
1073
+ // Assign node to the rule.name placeholder.
1074
+ // Our parent will check for matches among placeholders.
1075
+ res[0].placeholders[rule.name] = node;
1076
+ break;
1077
+ case 'c':
1078
+ case 'cl':
1079
+ // rule matches a ConstantNode
1080
+ if (isConstantNode(node)) {
1081
+ res[0].placeholders[rule.name] = node;
1082
+ } else {
1083
+ // mis-match: rule does not encompass current node
1084
+ return [];
1085
+ }
1086
+ break;
1087
+ case 'v':
1088
+ // rule matches anything other than a ConstantNode
1089
+ if (!isConstantNode(node)) {
1090
+ res[0].placeholders[rule.name] = node;
1091
+ } else {
1092
+ // mis-match: rule does not encompass current node
1093
+ return [];
1094
+ }
1095
+ break;
1096
+ case 'vl':
1097
+ // rule matches VariableNode
1098
+ if (isVariableNode(node)) {
1099
+ res[0].placeholders[rule.name] = node;
1100
+ } else {
1101
+ // mis-match: rule does not encompass current node
1102
+ return [];
1103
+ }
1104
+ break;
1105
+ case 'cd':
1106
+ // rule matches a ConstantNode or unaryMinus-wrapped ConstantNode
1107
+ if (isNumericNode(node)) {
1108
+ res[0].placeholders[rule.name] = node;
1109
+ } else {
1110
+ // mis-match: rule does not encompass current node
1111
+ return [];
1112
+ }
1113
+ break;
1114
+ case 'vd':
1115
+ // rule matches anything other than a ConstantNode or unaryMinus-wrapped ConstantNode
1116
+ if (!isNumericNode(node)) {
1117
+ res[0].placeholders[rule.name] = node;
1118
+ } else {
1119
+ // mis-match: rule does not encompass current node
1120
+ return [];
1121
+ }
1122
+ break;
1123
+ case 'ce':
1124
+ // rule matches expressions that have a constant value
1125
+ if (isConstantExpression(node)) {
1126
+ res[0].placeholders[rule.name] = node;
1127
+ } else {
1128
+ // mis-match: rule does not encompass current node
1129
+ return [];
1130
+ }
1131
+ break;
1132
+ case 've':
1133
+ // rule matches expressions that do not have a constant value
1134
+ if (!isConstantExpression(node)) {
1135
+ res[0].placeholders[rule.name] = node;
1136
+ } else {
1137
+ // mis-match: rule does not encompass current node
1138
+ return [];
1139
+ }
1140
+ break;
1141
+ default:
1142
+ throw new Error('Invalid symbol in rule: ' + rule.name);
1143
+ }
1084
1144
  }
1085
1145
  } else if (rule instanceof ConstantNode) {
1086
1146
  // Literal constant must match exactly
@@ -286,20 +286,37 @@ export var createSimplifyConstant = /* #__PURE__ */factory(name, dependencies, _
286
286
  * @return - Either a Node representing a binary expression or Fraction
287
287
  */
288
288
  function foldOp(fn, args, makeNode, options) {
289
- return args.reduce(function (a, b) {
290
- if (!isNode(a) && !isNode(b)) {
289
+ var first = args.shift();
290
+
291
+ // In the following reduction, sofar always has one of the three following
292
+ // forms: [NODE], [CONSTANT], or [NODE, CONSTANT]
293
+ var reduction = args.reduce((sofar, next) => {
294
+ if (!isNode(next)) {
295
+ var last = sofar.pop();
296
+ if (isNode(last)) {
297
+ return [last, next];
298
+ }
299
+ // Two constants in a row, try to fold them into one
291
300
  try {
292
- return _eval(fn, [a, b], options);
293
- } catch (ignoreandcontinue) {}
294
- a = _toNode(a);
295
- b = _toNode(b);
296
- } else if (!isNode(a)) {
297
- a = _toNode(a);
298
- } else if (!isNode(b)) {
299
- b = _toNode(b);
301
+ sofar.push(_eval(fn, [last, next], options));
302
+ return sofar;
303
+ } catch (ignoreandcontinue) {
304
+ sofar.push(last);
305
+ // fall through to Node case
306
+ }
300
307
  }
301
- return makeNode([a, b]);
302
- });
308
+
309
+ // Encountered a Node, or failed folding --
310
+ // collapse everything so far into a single tree:
311
+ sofar.push(_ensureNode(sofar.pop()));
312
+ var newtree = sofar.length === 1 ? sofar[0] : makeNode(sofar);
313
+ return [makeNode([newtree, _ensureNode(next)])];
314
+ }, [first]);
315
+ if (reduction.length === 1) {
316
+ return reduction[0];
317
+ }
318
+ // Might end up with a tree and a constant at the end:
319
+ return makeNode([reduction[0], _toNode(reduction[1])]);
303
320
  }
304
321
 
305
322
  // destroys the original node and returns a folded one
@@ -0,0 +1,118 @@
1
+ import { factory } from '../../utils/factory.js';
2
+ var name = 'sylvester';
3
+ var dependencies = ['typed', 'schur', 'matrixFromColumns', 'matrix', 'multiply', 'range', 'concat', 'transpose', 'index', 'subset', 'add', 'subtract', 'identity', 'lusolve', 'abs'];
4
+ export var createSylvester = /* #__PURE__ */factory(name, dependencies, _ref => {
5
+ var {
6
+ typed,
7
+ schur,
8
+ matrixFromColumns,
9
+ matrix,
10
+ multiply,
11
+ range,
12
+ concat,
13
+ transpose,
14
+ index,
15
+ subset,
16
+ add,
17
+ subtract,
18
+ identity,
19
+ lusolve,
20
+ abs
21
+ } = _ref;
22
+ /**
23
+ *
24
+ * Solves the real-valued Sylvester equation AX+XB=C for X, where A, B and C are
25
+ * matrices of appropriate dimensions, being A and B squared. Notice that other
26
+ * equivalent definitions for the Sylvester equation exist and this function
27
+ * assumes the one presented in the original publication of the the Bartels-
28
+ * Stewart algorithm, which is implemented by this function.
29
+ * https://en.wikipedia.org/wiki/Sylvester_equation
30
+ *
31
+ * Syntax:
32
+ *
33
+ * math.sylvester(A, B, C)
34
+ *
35
+ * Examples:
36
+ *
37
+ * const A = [[-1, -2], [1, 1]]
38
+ * const B = [[2, -1], [1, -2]]
39
+ * const C = [[-3, 2], [3, 0]]
40
+ * math.sylvester(A, B, C) // returns DenseMatrix [[-0.25, 0.25], [1.5, -1.25]]
41
+ *
42
+ * See also:
43
+ *
44
+ * schur, lyap
45
+ *
46
+ * @param {Matrix | Array} A Matrix A
47
+ * @param {Matrix | Array} B Matrix B
48
+ * @param {Matrix | Array} C Matrix C
49
+ * @return {Matrix | Array} Matrix X, solving the Sylvester equation
50
+ */
51
+ return typed(name, {
52
+ 'Matrix, Matrix, Matrix': _sylvester,
53
+ 'Array, Matrix, Matrix': function ArrayMatrixMatrix(A, B, C) {
54
+ return _sylvester(matrix(A), B, C);
55
+ },
56
+ 'Array, Array, Matrix': function ArrayArrayMatrix(A, B, C) {
57
+ return _sylvester(matrix(A), matrix(B), C);
58
+ },
59
+ 'Array, Matrix, Array': function ArrayMatrixArray(A, B, C) {
60
+ return _sylvester(matrix(A), B, matrix(C));
61
+ },
62
+ 'Matrix, Array, Matrix': function MatrixArrayMatrix(A, B, C) {
63
+ return _sylvester(A, matrix(B), C);
64
+ },
65
+ 'Matrix, Array, Array': function MatrixArrayArray(A, B, C) {
66
+ return _sylvester(A, matrix(B), matrix(C));
67
+ },
68
+ 'Matrix, Matrix, Array': function MatrixMatrixArray(A, B, C) {
69
+ return _sylvester(A, B, matrix(C));
70
+ },
71
+ 'Array, Array, Array': function ArrayArrayArray(A, B, C) {
72
+ return _sylvester(matrix(A), matrix(B), matrix(C)).toArray();
73
+ }
74
+ });
75
+ function _sylvester(A, B, C) {
76
+ var n = B.size()[0];
77
+ var m = A.size()[0];
78
+ var sA = schur(A);
79
+ var F = sA.T;
80
+ var U = sA.U;
81
+ var sB = schur(multiply(-1, B));
82
+ var G = sB.T;
83
+ var V = sB.U;
84
+ var D = multiply(multiply(transpose(U), C), V);
85
+ var all = range(0, m);
86
+ var y = [];
87
+ var hc = (a, b) => concat(a, b, 1);
88
+ var vc = (a, b) => concat(a, b, 0);
89
+ for (var k = 0; k < n; k++) {
90
+ if (k < n - 1 && abs(subset(G, index(k + 1, k))) > 1e-5) {
91
+ var RHS = vc(subset(D, index(all, k)), subset(D, index(all, k + 1)));
92
+ for (var j = 0; j < k; j++) {
93
+ RHS = add(RHS, vc(multiply(y[j], subset(G, index(j, k))), multiply(y[j], subset(G, index(j, k + 1)))));
94
+ }
95
+ var gkk = multiply(identity(m), multiply(-1, subset(G, index(k, k))));
96
+ var gmk = multiply(identity(m), multiply(-1, subset(G, index(k + 1, k))));
97
+ var gkm = multiply(identity(m), multiply(-1, subset(G, index(k, k + 1))));
98
+ var gmm = multiply(identity(m), multiply(-1, subset(G, index(k + 1, k + 1))));
99
+ var LHS = vc(hc(add(F, gkk), gmk), hc(gkm, add(F, gmm)));
100
+ var yAux = lusolve(LHS, RHS);
101
+ y[k] = yAux.subset(index(range(0, m), 0));
102
+ y[k + 1] = yAux.subset(index(range(m, 2 * m), 0));
103
+ k++;
104
+ } else {
105
+ var _RHS = subset(D, index(all, k));
106
+ for (var _j = 0; _j < k; _j++) {
107
+ _RHS = add(_RHS, multiply(y[_j], subset(G, index(_j, k))));
108
+ }
109
+ var _gkk = subset(G, index(k, k));
110
+ var _LHS = subtract(F, multiply(_gkk, identity(m)));
111
+ y[k] = lusolve(_LHS, _RHS);
112
+ }
113
+ }
114
+ var Y = matrix(matrixFromColumns(...y));
115
+ var X = multiply(U, multiply(Y, transpose(V)));
116
+ return X;
117
+ }
118
+ });
@@ -33,7 +33,7 @@ export var createForEach = /* #__PURE__ */factory(name, dependencies, _ref => {
33
33
  return typed(name, {
34
34
  'Array, function': _forEach,
35
35
  'Matrix, function': function MatrixFunction(x, callback) {
36
- return x.forEach(callback);
36
+ x.forEach(callback);
37
37
  }
38
38
  });
39
39
  });
@@ -59,7 +59,7 @@ export var createSqrtm = /* #__PURE__ */factory(name, dependencies, _ref => {
59
59
  *
60
60
  * Examples:
61
61
  *
62
- * math.sqrtm([[1, 2], [3, 4]]) // returns [[-2, 1], [1.5, -0.5]]
62
+ * math.sqrtm([[33, 24], [48, 57]]) // returns [[5, 2], [4, 7]]
63
63
  *
64
64
  * See also:
65
65
  *
@@ -526,8 +526,10 @@ export var createSparseMatrixClass = /* #__PURE__ */factory(name, dependencies,
526
526
  _remove(k, j, this._values, this._index, this._ptr);
527
527
  }
528
528
  } else {
529
- // insert value @ (i, j)
530
- _insert(k, i, j, v, this._values, this._index, this._ptr);
529
+ if (!eq(v, zero)) {
530
+ // insert value @ (i, j)
531
+ _insert(k, i, j, v, this._values, this._index, this._ptr);
532
+ }
531
533
  }
532
534
  return this;
533
535
  };
@@ -1,3 +1,3 @@
1
- export var version = '11.3.2';
1
+ export var version = '11.4.0';
2
2
  // Note: This file is automatically generated when building math.js.
3
3
  // Changes made in this file will be overwritten.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mathjs",
3
- "version": "11.3.2",
3
+ "version": "11.4.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",
@@ -25,7 +25,7 @@
25
25
  "unit"
26
26
  ],
27
27
  "dependencies": {
28
- "@babel/runtime": "^7.19.4",
28
+ "@babel/runtime": "^7.20.1",
29
29
  "complex.js": "^2.1.1",
30
30
  "decimal.js": "^10.4.2",
31
31
  "escape-latex": "^1.2.0",
@@ -36,28 +36,28 @@
36
36
  "typed-function": "^4.1.0"
37
37
  },
38
38
  "devDependencies": {
39
- "@babel/core": "7.19.6",
39
+ "@babel/core": "7.20.2",
40
40
  "@babel/plugin-transform-object-assign": "7.18.6",
41
41
  "@babel/plugin-transform-runtime": "7.19.6",
42
- "@babel/preset-env": "7.19.4",
42
+ "@babel/preset-env": "7.20.2",
43
43
  "@babel/register": "7.18.9",
44
44
  "@types/assert": "1.5.6",
45
45
  "@types/mocha": "10.0.0",
46
- "@typescript-eslint/eslint-plugin": "5.41.0",
47
- "@typescript-eslint/parser": "5.41.0",
46
+ "@typescript-eslint/eslint-plugin": "5.43.0",
47
+ "@typescript-eslint/parser": "5.43.0",
48
48
  "assert": "2.0.0",
49
- "babel-loader": "8.2.5",
49
+ "babel-loader": "9.1.0",
50
50
  "benchmark": "2.1.4",
51
51
  "codecov": "3.8.3",
52
- "core-js": "3.26.0",
52
+ "core-js": "3.26.1",
53
53
  "del": "6.1.1",
54
54
  "dtslint": "4.2.1",
55
- "eslint": "8.26.0",
55
+ "eslint": "8.27.0",
56
56
  "eslint-config-prettier": "8.5.0",
57
57
  "eslint-config-standard": "17.0.0",
58
58
  "eslint-plugin-import": "2.26.0",
59
59
  "eslint-plugin-mocha": "10.1.0",
60
- "eslint-plugin-n": "15.3.0",
60
+ "eslint-plugin-n": "15.5.1",
61
61
  "eslint-plugin-prettier": "4.2.1",
62
62
  "eslint-plugin-promise": "6.1.1",
63
63
  "expect-type": "0.15.0",
@@ -78,7 +78,7 @@
78
78
  "math-expression-evaluator": "1.4.0",
79
79
  "mkdirp": "1.0.4",
80
80
  "mocha": "10.1.0",
81
- "mocha-junit-reporter": "2.1.0",
81
+ "mocha-junit-reporter": "2.2.0",
82
82
  "ndarray": "1.0.19",
83
83
  "ndarray-determinant": "1.0.0",
84
84
  "ndarray-gemm": "1.0.0",
@@ -91,8 +91,8 @@
91
91
  "process": "0.11.10",
92
92
  "sylvester": "0.0.21",
93
93
  "ts-node": "10.9.1",
94
- "typescript": "4.8.4",
95
- "webpack": "5.74.0",
94
+ "typescript": "4.9.3",
95
+ "webpack": "5.75.0",
96
96
  "zeros": "1.0.0"
97
97
  },
98
98
  "type": "module",