mathjs 9.4.3 → 9.4.4

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.
@@ -15,6 +15,8 @@ var _dependenciesDivideScalarGenerated = require("./dependenciesDivideScalar.gen
15
15
 
16
16
  var _dependenciesEqualScalarGenerated = require("./dependenciesEqualScalar.generated.js");
17
17
 
18
+ var _dependenciesFlattenGenerated = require("./dependenciesFlatten.generated.js");
19
+
18
20
  var _dependenciesMatrixGenerated = require("./dependenciesMatrix.generated.js");
19
21
 
20
22
  var _dependenciesMultiplyGenerated = require("./dependenciesMultiply.generated.js");
@@ -39,6 +41,7 @@ var intersectDependencies = {
39
41
  addScalarDependencies: _dependenciesAddScalarGenerated.addScalarDependencies,
40
42
  divideScalarDependencies: _dependenciesDivideScalarGenerated.divideScalarDependencies,
41
43
  equalScalarDependencies: _dependenciesEqualScalarGenerated.equalScalarDependencies,
44
+ flattenDependencies: _dependenciesFlattenGenerated.flattenDependencies,
42
45
  matrixDependencies: _dependenciesMatrixGenerated.matrixDependencies,
43
46
  multiplyDependencies: _dependenciesMultiplyGenerated.multiplyDependencies,
44
47
  multiplyScalarDependencies: _dependenciesMultiplyScalarGenerated.multiplyScalarDependencies,
@@ -1738,6 +1738,7 @@ var intersect = /* #__PURE__ */(0, _factoriesAny.createIntersect)({
1738
1738
  config: _configReadonly.config,
1739
1739
  divideScalar: divideScalar,
1740
1740
  equalScalar: equalScalar,
1741
+ flatten: flatten,
1741
1742
  matrix: matrix,
1742
1743
  multiply: multiply,
1743
1744
  multiplyScalar: multiplyScalar,
@@ -170,21 +170,21 @@ var createArrayNode = /* #__PURE__ */(0, _factory.factory)(name, dependencies, f
170
170
 
171
171
 
172
172
  ArrayNode.prototype._toTex = function (options) {
173
- var s = '\\begin{bmatrix}';
174
- this.items.forEach(function (node) {
175
- if (node.items) {
176
- s += node.items.map(function (childNode) {
177
- return childNode.toTex(options);
178
- }).join('&');
179
- } else {
180
- s += node.toTex(options);
181
- } // new line
182
-
183
-
184
- s += '\\\\';
185
- });
186
- s += '\\end{bmatrix}';
187
- return s;
173
+ function itemsToTex(items, nested) {
174
+ var mixedItems = items.some(_is.isArrayNode) && !items.every(_is.isArrayNode);
175
+ var itemsFormRow = nested || mixedItems;
176
+ var itemSep = itemsFormRow ? '&' : '\\\\';
177
+ var itemsTex = items.map(function (node) {
178
+ if (node.items) {
179
+ return itemsToTex(node.items, !nested);
180
+ } else {
181
+ return node.toTex(options);
182
+ }
183
+ }).join(itemSep);
184
+ return mixedItems || !itemsFormRow || itemsFormRow && !nested ? '\\begin{bmatrix}' + itemsTex + '\\end{bmatrix}' : itemsTex;
185
+ }
186
+
187
+ return itemsToTex(this.items, false);
188
188
  };
189
189
 
190
190
  return ArrayNode;
@@ -10,7 +10,7 @@ var _is = require("../../utils/is.js");
10
10
  var _factory = require("../../utils/factory.js");
11
11
 
12
12
  var name = 'intersect';
13
- var dependencies = ['typed', 'config', 'abs', 'add', 'addScalar', 'matrix', 'multiply', 'multiplyScalar', 'divideScalar', 'subtract', 'smaller', 'equalScalar'];
13
+ var dependencies = ['typed', 'config', 'abs', 'add', 'addScalar', 'matrix', 'multiply', 'multiplyScalar', 'divideScalar', 'subtract', 'smaller', 'equalScalar', 'flatten'];
14
14
  var createIntersect = /* #__PURE__ */(0, _factory.factory)(name, dependencies, function (_ref) {
15
15
  var typed = _ref.typed,
16
16
  config = _ref.config,
@@ -23,7 +23,8 @@ var createIntersect = /* #__PURE__ */(0, _factory.factory)(name, dependencies, f
23
23
  divideScalar = _ref.divideScalar,
24
24
  subtract = _ref.subtract,
25
25
  smaller = _ref.smaller,
26
- equalScalar = _ref.equalScalar;
26
+ equalScalar = _ref.equalScalar,
27
+ flatten = _ref.flatten;
27
28
 
28
29
  /**
29
30
  * Calculates the point of intersection of two lines in two or three dimensions
@@ -49,74 +50,106 @@ var createIntersect = /* #__PURE__ */(0, _factory.factory)(name, dependencies, f
49
50
  * @param {Array | Matrix} y Co-ordinates of first end-point of second line
50
51
  * OR Co-efficients of the plane's equation
51
52
  * @param {Array | Matrix} z Co-ordinates of second end-point of second line
52
- * OR null if the calculation is for line and plane
53
+ * OR undefined if the calculation is for line and plane
53
54
  * @return {Array} Returns the point of intersection of lines/lines-planes
54
55
  */
55
56
  return typed('intersect', {
56
- 'Array, Array, Array': function ArrayArrayArray(x, y, plane) {
57
- if (!_3d(x)) {
57
+ 'Array, Array, Array': _AAA,
58
+ 'Array, Array, Array, Array': _AAAA,
59
+ 'Matrix, Matrix, Matrix': function MatrixMatrixMatrix(x, y, plane) {
60
+ var arr = _AAA(x.valueOf(), y.valueOf(), plane.valueOf());
61
+
62
+ return arr === null ? null : matrix(arr);
63
+ },
64
+ 'Matrix, Matrix, Matrix, Matrix': function MatrixMatrixMatrixMatrix(w, x, y, z) {
65
+ // TODO: output matrix type should match input matrix type
66
+ var arr = _AAAA(w.valueOf(), x.valueOf(), y.valueOf(), z.valueOf());
67
+
68
+ return arr === null ? null : matrix(arr);
69
+ }
70
+ });
71
+
72
+ function _AAA(x, y, plane) {
73
+ x = _coerceArr(x);
74
+ y = _coerceArr(y);
75
+ plane = _coerceArr(plane);
76
+
77
+ if (!_3d(x)) {
78
+ throw new TypeError('Array with 3 numbers or BigNumbers expected for first argument');
79
+ }
80
+
81
+ if (!_3d(y)) {
82
+ throw new TypeError('Array with 3 numbers or BigNumbers expected for second argument');
83
+ }
84
+
85
+ if (!_4d(plane)) {
86
+ throw new TypeError('Array with 4 numbers expected as third argument');
87
+ }
88
+
89
+ return _intersectLinePlane(x[0], x[1], x[2], y[0], y[1], y[2], plane[0], plane[1], plane[2], plane[3]);
90
+ }
91
+
92
+ function _AAAA(w, x, y, z) {
93
+ w = _coerceArr(w);
94
+ x = _coerceArr(x);
95
+ y = _coerceArr(y);
96
+ z = _coerceArr(z);
97
+
98
+ if (w.length === 2) {
99
+ if (!_2d(w)) {
100
+ throw new TypeError('Array with 2 numbers or BigNumbers expected for first argument');
101
+ }
102
+
103
+ if (!_2d(x)) {
104
+ throw new TypeError('Array with 2 numbers or BigNumbers expected for second argument');
105
+ }
106
+
107
+ if (!_2d(y)) {
108
+ throw new TypeError('Array with 2 numbers or BigNumbers expected for third argument');
109
+ }
110
+
111
+ if (!_2d(z)) {
112
+ throw new TypeError('Array with 2 numbers or BigNumbers expected for fourth argument');
113
+ }
114
+
115
+ return _intersect2d(w, x, y, z);
116
+ } else if (w.length === 3) {
117
+ if (!_3d(w)) {
58
118
  throw new TypeError('Array with 3 numbers or BigNumbers expected for first argument');
59
119
  }
60
120
 
61
- if (!_3d(y)) {
121
+ if (!_3d(x)) {
62
122
  throw new TypeError('Array with 3 numbers or BigNumbers expected for second argument');
63
123
  }
64
124
 
65
- if (!_4d(plane)) {
66
- throw new TypeError('Array with 4 numbers expected as third argument');
125
+ if (!_3d(y)) {
126
+ throw new TypeError('Array with 3 numbers or BigNumbers expected for third argument');
67
127
  }
68
128
 
69
- return _intersectLinePlane(x[0], x[1], x[2], y[0], y[1], y[2], plane[0], plane[1], plane[2], plane[3]);
70
- },
71
- 'Array, Array, Array, Array': function ArrayArrayArrayArray(w, x, y, z) {
72
- if (w.length === 2) {
73
- if (!_2d(w)) {
74
- throw new TypeError('Array with 2 numbers or BigNumbers expected for first argument');
75
- }
76
-
77
- if (!_2d(x)) {
78
- throw new TypeError('Array with 2 numbers or BigNumbers expected for second argument');
79
- }
80
-
81
- if (!_2d(y)) {
82
- throw new TypeError('Array with 2 numbers or BigNumbers expected for third argument');
83
- }
84
-
85
- if (!_2d(z)) {
86
- throw new TypeError('Array with 2 numbers or BigNumbers expected for fourth argument');
87
- }
88
-
89
- return _intersect2d(w, x, y, z);
90
- } else if (w.length === 3) {
91
- if (!_3d(w)) {
92
- throw new TypeError('Array with 3 numbers or BigNumbers expected for first argument');
93
- }
94
-
95
- if (!_3d(x)) {
96
- throw new TypeError('Array with 3 numbers or BigNumbers expected for second argument');
97
- }
98
-
99
- if (!_3d(y)) {
100
- throw new TypeError('Array with 3 numbers or BigNumbers expected for third argument');
101
- }
102
-
103
- if (!_3d(z)) {
104
- throw new TypeError('Array with 3 numbers or BigNumbers expected for fourth argument');
105
- }
106
-
107
- return _intersect3d(w[0], w[1], w[2], x[0], x[1], x[2], y[0], y[1], y[2], z[0], z[1], z[2]);
108
- } else {
109
- throw new TypeError('Arrays with two or thee dimensional points expected');
129
+ if (!_3d(z)) {
130
+ throw new TypeError('Array with 3 numbers or BigNumbers expected for fourth argument');
110
131
  }
111
- },
112
- 'Matrix, Matrix, Matrix': function MatrixMatrixMatrix(x, y, plane) {
113
- return matrix(this(x.valueOf(), y.valueOf(), plane.valueOf()));
114
- },
115
- 'Matrix, Matrix, Matrix, Matrix': function MatrixMatrixMatrixMatrix(w, x, y, z) {
116
- // TODO: output matrix type should match input matrix type
117
- return matrix(this(w.valueOf(), x.valueOf(), y.valueOf(), z.valueOf()));
132
+
133
+ return _intersect3d(w[0], w[1], w[2], x[0], x[1], x[2], y[0], y[1], y[2], z[0], z[1], z[2]);
134
+ } else {
135
+ throw new TypeError('Arrays with two or thee dimensional points expected');
118
136
  }
119
- });
137
+ }
138
+ /** Coerce row and column 2-dim arrays to 1-dim array */
139
+
140
+
141
+ function _coerceArr(arr) {
142
+ // row matrix
143
+ if (arr.length === 1) return arr[0]; // column matrix
144
+
145
+ if (arr.length > 1 && Array.isArray(arr[0])) {
146
+ if (arr.every(function (el) {
147
+ return Array.isArray(el) && el.length === 1;
148
+ })) return flatten(arr);
149
+ }
150
+
151
+ return arr;
152
+ }
120
153
 
121
154
  function _isNumeric(a) {
122
155
  // intersect supports numbers and bignumbers
@@ -196,7 +229,9 @@ var createIntersect = /* #__PURE__ */(0, _factory.factory)(name, dependencies, f
196
229
  var y2y = multiplyScalar(y2, y);
197
230
  var z1z = multiplyScalar(z1, z);
198
231
  var z2z = multiplyScalar(z2, z);
199
- var t = divideScalar(subtract(subtract(subtract(c, x1x), y1y), z1z), subtract(subtract(subtract(addScalar(addScalar(x2x, y2y), z2z), x1x), y1y), z1z));
232
+ var numerator = subtract(subtract(subtract(c, x1x), y1y), z1z);
233
+ var denominator = subtract(subtract(subtract(addScalar(addScalar(x2x, y2y), z2z), x1x), y1y), z1z);
234
+ var t = divideScalar(numerator, denominator);
200
235
  var px = addScalar(x1, multiplyScalar(t, subtract(x2, x1)));
201
236
  var py = addScalar(y1, multiplyScalar(t, subtract(y2, y1)));
202
237
  var pz = addScalar(z1, multiplyScalar(t, subtract(z2, z1)));
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 9.4.3
10
- * @date 2021-06-23
9
+ * @version 9.4.4
10
+ * @date 2021-07-07
11
11
  *
12
12
  * @license
13
13
  * Copyright (C) 2013-2021 Jos de Jong <wjosdejong@gmail.com>
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.version = void 0;
7
- var version = '9.4.3'; // Note: This file is automatically generated when building math.js.
7
+ var version = '9.4.4'; // Note: This file is automatically generated when building math.js.
8
8
  // Changes made in this file will be overwritten.
9
9
 
10
10
  exports.version = version;
@@ -7,6 +7,7 @@ import { addDependencies } from './dependenciesAdd.generated.js';
7
7
  import { addScalarDependencies } from './dependenciesAddScalar.generated.js';
8
8
  import { divideScalarDependencies } from './dependenciesDivideScalar.generated.js';
9
9
  import { equalScalarDependencies } from './dependenciesEqualScalar.generated.js';
10
+ import { flattenDependencies } from './dependenciesFlatten.generated.js';
10
11
  import { matrixDependencies } from './dependenciesMatrix.generated.js';
11
12
  import { multiplyDependencies } from './dependenciesMultiply.generated.js';
12
13
  import { multiplyScalarDependencies } from './dependenciesMultiplyScalar.generated.js';
@@ -20,6 +21,7 @@ export var intersectDependencies = {
20
21
  addScalarDependencies,
21
22
  divideScalarDependencies,
22
23
  equalScalarDependencies,
24
+ flattenDependencies,
23
25
  matrixDependencies,
24
26
  multiplyDependencies,
25
27
  multiplyScalarDependencies,
@@ -1447,6 +1447,7 @@ export var intersect = /* #__PURE__ */createIntersect({
1447
1447
  config,
1448
1448
  divideScalar,
1449
1449
  equalScalar,
1450
+ flatten,
1450
1451
  matrix,
1451
1452
  multiply,
1452
1453
  multiplyScalar,
@@ -1,4 +1,4 @@
1
- import { isNode } from '../../utils/is.js';
1
+ import { isArrayNode, isNode } from '../../utils/is.js';
2
2
  import { map } from '../../utils/array.js';
3
3
  import { factory } from '../../utils/factory.js';
4
4
  var name = 'ArrayNode';
@@ -162,21 +162,21 @@ export var createArrayNode = /* #__PURE__ */factory(name, dependencies, _ref =>
162
162
 
163
163
 
164
164
  ArrayNode.prototype._toTex = function (options) {
165
- var s = '\\begin{bmatrix}';
166
- this.items.forEach(function (node) {
167
- if (node.items) {
168
- s += node.items.map(function (childNode) {
169
- return childNode.toTex(options);
170
- }).join('&');
171
- } else {
172
- s += node.toTex(options);
173
- } // new line
174
-
175
-
176
- s += '\\\\';
177
- });
178
- s += '\\end{bmatrix}';
179
- return s;
165
+ function itemsToTex(items, nested) {
166
+ var mixedItems = items.some(isArrayNode) && !items.every(isArrayNode);
167
+ var itemsFormRow = nested || mixedItems;
168
+ var itemSep = itemsFormRow ? '&' : '\\\\';
169
+ var itemsTex = items.map(function (node) {
170
+ if (node.items) {
171
+ return itemsToTex(node.items, !nested);
172
+ } else {
173
+ return node.toTex(options);
174
+ }
175
+ }).join(itemSep);
176
+ return mixedItems || !itemsFormRow || itemsFormRow && !nested ? '\\begin{bmatrix}' + itemsTex + '\\end{bmatrix}' : itemsTex;
177
+ }
178
+
179
+ return itemsToTex(this.items, false);
180
180
  };
181
181
 
182
182
  return ArrayNode;
@@ -1,7 +1,7 @@
1
1
  import { isBigNumber } from '../../utils/is.js';
2
2
  import { factory } from '../../utils/factory.js';
3
3
  var name = 'intersect';
4
- var dependencies = ['typed', 'config', 'abs', 'add', 'addScalar', 'matrix', 'multiply', 'multiplyScalar', 'divideScalar', 'subtract', 'smaller', 'equalScalar'];
4
+ var dependencies = ['typed', 'config', 'abs', 'add', 'addScalar', 'matrix', 'multiply', 'multiplyScalar', 'divideScalar', 'subtract', 'smaller', 'equalScalar', 'flatten'];
5
5
  export var createIntersect = /* #__PURE__ */factory(name, dependencies, _ref => {
6
6
  var {
7
7
  typed,
@@ -15,7 +15,8 @@ export var createIntersect = /* #__PURE__ */factory(name, dependencies, _ref =>
15
15
  divideScalar,
16
16
  subtract,
17
17
  smaller,
18
- equalScalar
18
+ equalScalar,
19
+ flatten
19
20
  } = _ref;
20
21
 
21
22
  /**
@@ -42,74 +43,104 @@ export var createIntersect = /* #__PURE__ */factory(name, dependencies, _ref =>
42
43
  * @param {Array | Matrix} y Co-ordinates of first end-point of second line
43
44
  * OR Co-efficients of the plane's equation
44
45
  * @param {Array | Matrix} z Co-ordinates of second end-point of second line
45
- * OR null if the calculation is for line and plane
46
+ * OR undefined if the calculation is for line and plane
46
47
  * @return {Array} Returns the point of intersection of lines/lines-planes
47
48
  */
48
49
  return typed('intersect', {
49
- 'Array, Array, Array': function ArrayArrayArray(x, y, plane) {
50
- if (!_3d(x)) {
50
+ 'Array, Array, Array': _AAA,
51
+ 'Array, Array, Array, Array': _AAAA,
52
+ 'Matrix, Matrix, Matrix': function MatrixMatrixMatrix(x, y, plane) {
53
+ var arr = _AAA(x.valueOf(), y.valueOf(), plane.valueOf());
54
+
55
+ return arr === null ? null : matrix(arr);
56
+ },
57
+ 'Matrix, Matrix, Matrix, Matrix': function MatrixMatrixMatrixMatrix(w, x, y, z) {
58
+ // TODO: output matrix type should match input matrix type
59
+ var arr = _AAAA(w.valueOf(), x.valueOf(), y.valueOf(), z.valueOf());
60
+
61
+ return arr === null ? null : matrix(arr);
62
+ }
63
+ });
64
+
65
+ function _AAA(x, y, plane) {
66
+ x = _coerceArr(x);
67
+ y = _coerceArr(y);
68
+ plane = _coerceArr(plane);
69
+
70
+ if (!_3d(x)) {
71
+ throw new TypeError('Array with 3 numbers or BigNumbers expected for first argument');
72
+ }
73
+
74
+ if (!_3d(y)) {
75
+ throw new TypeError('Array with 3 numbers or BigNumbers expected for second argument');
76
+ }
77
+
78
+ if (!_4d(plane)) {
79
+ throw new TypeError('Array with 4 numbers expected as third argument');
80
+ }
81
+
82
+ return _intersectLinePlane(x[0], x[1], x[2], y[0], y[1], y[2], plane[0], plane[1], plane[2], plane[3]);
83
+ }
84
+
85
+ function _AAAA(w, x, y, z) {
86
+ w = _coerceArr(w);
87
+ x = _coerceArr(x);
88
+ y = _coerceArr(y);
89
+ z = _coerceArr(z);
90
+
91
+ if (w.length === 2) {
92
+ if (!_2d(w)) {
93
+ throw new TypeError('Array with 2 numbers or BigNumbers expected for first argument');
94
+ }
95
+
96
+ if (!_2d(x)) {
97
+ throw new TypeError('Array with 2 numbers or BigNumbers expected for second argument');
98
+ }
99
+
100
+ if (!_2d(y)) {
101
+ throw new TypeError('Array with 2 numbers or BigNumbers expected for third argument');
102
+ }
103
+
104
+ if (!_2d(z)) {
105
+ throw new TypeError('Array with 2 numbers or BigNumbers expected for fourth argument');
106
+ }
107
+
108
+ return _intersect2d(w, x, y, z);
109
+ } else if (w.length === 3) {
110
+ if (!_3d(w)) {
51
111
  throw new TypeError('Array with 3 numbers or BigNumbers expected for first argument');
52
112
  }
53
113
 
54
- if (!_3d(y)) {
114
+ if (!_3d(x)) {
55
115
  throw new TypeError('Array with 3 numbers or BigNumbers expected for second argument');
56
116
  }
57
117
 
58
- if (!_4d(plane)) {
59
- throw new TypeError('Array with 4 numbers expected as third argument');
118
+ if (!_3d(y)) {
119
+ throw new TypeError('Array with 3 numbers or BigNumbers expected for third argument');
60
120
  }
61
121
 
62
- return _intersectLinePlane(x[0], x[1], x[2], y[0], y[1], y[2], plane[0], plane[1], plane[2], plane[3]);
63
- },
64
- 'Array, Array, Array, Array': function ArrayArrayArrayArray(w, x, y, z) {
65
- if (w.length === 2) {
66
- if (!_2d(w)) {
67
- throw new TypeError('Array with 2 numbers or BigNumbers expected for first argument');
68
- }
69
-
70
- if (!_2d(x)) {
71
- throw new TypeError('Array with 2 numbers or BigNumbers expected for second argument');
72
- }
73
-
74
- if (!_2d(y)) {
75
- throw new TypeError('Array with 2 numbers or BigNumbers expected for third argument');
76
- }
77
-
78
- if (!_2d(z)) {
79
- throw new TypeError('Array with 2 numbers or BigNumbers expected for fourth argument');
80
- }
81
-
82
- return _intersect2d(w, x, y, z);
83
- } else if (w.length === 3) {
84
- if (!_3d(w)) {
85
- throw new TypeError('Array with 3 numbers or BigNumbers expected for first argument');
86
- }
87
-
88
- if (!_3d(x)) {
89
- throw new TypeError('Array with 3 numbers or BigNumbers expected for second argument');
90
- }
91
-
92
- if (!_3d(y)) {
93
- throw new TypeError('Array with 3 numbers or BigNumbers expected for third argument');
94
- }
95
-
96
- if (!_3d(z)) {
97
- throw new TypeError('Array with 3 numbers or BigNumbers expected for fourth argument');
98
- }
99
-
100
- return _intersect3d(w[0], w[1], w[2], x[0], x[1], x[2], y[0], y[1], y[2], z[0], z[1], z[2]);
101
- } else {
102
- throw new TypeError('Arrays with two or thee dimensional points expected');
122
+ if (!_3d(z)) {
123
+ throw new TypeError('Array with 3 numbers or BigNumbers expected for fourth argument');
103
124
  }
104
- },
105
- 'Matrix, Matrix, Matrix': function MatrixMatrixMatrix(x, y, plane) {
106
- return matrix(this(x.valueOf(), y.valueOf(), plane.valueOf()));
107
- },
108
- 'Matrix, Matrix, Matrix, Matrix': function MatrixMatrixMatrixMatrix(w, x, y, z) {
109
- // TODO: output matrix type should match input matrix type
110
- return matrix(this(w.valueOf(), x.valueOf(), y.valueOf(), z.valueOf()));
125
+
126
+ return _intersect3d(w[0], w[1], w[2], x[0], x[1], x[2], y[0], y[1], y[2], z[0], z[1], z[2]);
127
+ } else {
128
+ throw new TypeError('Arrays with two or thee dimensional points expected');
111
129
  }
112
- });
130
+ }
131
+ /** Coerce row and column 2-dim arrays to 1-dim array */
132
+
133
+
134
+ function _coerceArr(arr) {
135
+ // row matrix
136
+ if (arr.length === 1) return arr[0]; // column matrix
137
+
138
+ if (arr.length > 1 && Array.isArray(arr[0])) {
139
+ if (arr.every(el => Array.isArray(el) && el.length === 1)) return flatten(arr);
140
+ }
141
+
142
+ return arr;
143
+ }
113
144
 
114
145
  function _isNumeric(a) {
115
146
  // intersect supports numbers and bignumbers
@@ -189,7 +220,9 @@ export var createIntersect = /* #__PURE__ */factory(name, dependencies, _ref =>
189
220
  var y2y = multiplyScalar(y2, y);
190
221
  var z1z = multiplyScalar(z1, z);
191
222
  var z2z = multiplyScalar(z2, z);
192
- var t = divideScalar(subtract(subtract(subtract(c, x1x), y1y), z1z), subtract(subtract(subtract(addScalar(addScalar(x2x, y2y), z2z), x1x), y1y), z1z));
223
+ var numerator = subtract(subtract(subtract(c, x1x), y1y), z1z);
224
+ var denominator = subtract(subtract(subtract(addScalar(addScalar(x2x, y2y), z2z), x1x), y1y), z1z);
225
+ var t = divideScalar(numerator, denominator);
193
226
  var px = addScalar(x1, multiplyScalar(t, subtract(x2, x1)));
194
227
  var py = addScalar(y1, multiplyScalar(t, subtract(y2, y1)));
195
228
  var pz = addScalar(z1, multiplyScalar(t, subtract(z2, z1)));
@@ -1,2 +1,2 @@
1
- export var version = '9.4.3'; // Note: This file is automatically generated when building math.js.
1
+ export var version = '9.4.4'; // Note: This file is automatically generated when building math.js.
2
2
  // Changes made in this file will be overwritten.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mathjs",
3
- "version": "9.4.3",
3
+ "version": "9.4.4",
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",
@@ -26,8 +26,8 @@
26
26
  ],
27
27
  "dependencies": {
28
28
  "@babel/runtime": "^7.14.6",
29
- "complex.js": "^2.0.13",
30
- "decimal.js": "^10.3.0",
29
+ "complex.js": "^2.0.15",
30
+ "decimal.js": "^10.3.1",
31
31
  "escape-latex": "^1.2.0",
32
32
  "fraction.js": "^4.1.1",
33
33
  "javascript-natural-sort": "^0.7.1",
@@ -44,8 +44,9 @@
44
44
  "babel-loader": "8.2.2",
45
45
  "benchmark": "2.1.4",
46
46
  "codecov": "3.8.2",
47
+ "core-js": "3.15.2",
47
48
  "del": "6.0.0",
48
- "dtslint": "4.1.0",
49
+ "dtslint": "4.1.1",
49
50
  "expr-eval": "2.0.2",
50
51
  "fancy-log": "1.3.3",
51
52
  "glob": "7.1.7",
@@ -60,7 +61,7 @@
60
61
  "karma-mocha": "2.0.1",
61
62
  "karma-mocha-reporter": "2.2.5",
62
63
  "karma-webpack": "4.0.2",
63
- "math-expression-evaluator": "1.3.7",
64
+ "math-expression-evaluator": "1.3.8",
64
65
  "mkdirp": "1.0.4",
65
66
  "mocha": "8.4.0",
66
67
  "ndarray": "1.0.19",
@@ -73,7 +74,7 @@
73
74
  "pad-right": "0.2.2",
74
75
  "standard": "16.0.3",
75
76
  "sylvester": "0.0.21",
76
- "typescript": "4.3.4",
77
+ "typescript": "4.3.5",
77
78
  "webpack": "4.46.0",
78
79
  "zeros": "1.0.0"
79
80
  },
@@ -147,7 +148,7 @@
147
148
  "mathjs": "./bin/cli.js"
148
149
  },
149
150
  "engines": {
150
- "node": ">= 10"
151
+ "node": ">= 12"
151
152
  },
152
153
  "bugs": {
153
154
  "url": "https://github.com/josdejong/mathjs/issues"