mathjs 12.3.1 → 12.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.
- package/HISTORY.md +23 -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/entry/pureFunctionsAny.generated.js +1 -0
- package/lib/cjs/expression/node/OperatorNode.js +2 -1
- package/lib/cjs/expression/parse.js +8 -4
- package/lib/cjs/expression/transform/utils/compileInlineExpression.js +5 -4
- package/lib/cjs/function/arithmetic/multiply.js +30 -29
- package/lib/cjs/function/arithmetic/round.js +38 -7
- package/lib/cjs/function/matrix/dot.js +3 -3
- package/lib/cjs/header.js +2 -2
- package/lib/cjs/type/matrix/utils/matAlgo01xDSid.js +4 -4
- package/lib/cjs/type/matrix/utils/matAlgo02xDS0.js +4 -4
- package/lib/cjs/type/matrix/utils/matAlgo03xDSf.js +4 -4
- package/lib/cjs/type/matrix/utils/matAlgo04xSidSid.js +4 -4
- package/lib/cjs/type/matrix/utils/matAlgo05xSfSf.js +4 -4
- package/lib/cjs/type/matrix/utils/matAlgo06xS0S0.js +4 -4
- package/lib/cjs/type/matrix/utils/matAlgo07xSSf.js +4 -4
- package/lib/cjs/type/matrix/utils/matAlgo08xS0Sid.js +4 -4
- package/lib/cjs/type/matrix/utils/matAlgo09xS0Sf.js +4 -4
- package/lib/cjs/utils/map.js +176 -14
- package/lib/cjs/utils/scope.js +4 -10
- package/lib/cjs/version.js +1 -1
- package/lib/esm/entry/pureFunctionsAny.generated.js +1 -0
- package/lib/esm/expression/node/OperatorNode.js +2 -1
- package/lib/esm/expression/parse.js +8 -4
- package/lib/esm/expression/transform/utils/compileInlineExpression.js +5 -4
- package/lib/esm/function/arithmetic/multiply.js +30 -29
- package/lib/esm/function/arithmetic/round.js +38 -7
- package/lib/esm/function/matrix/dot.js +3 -3
- package/lib/esm/type/matrix/utils/matAlgo01xDSid.js +4 -4
- package/lib/esm/type/matrix/utils/matAlgo02xDS0.js +4 -4
- package/lib/esm/type/matrix/utils/matAlgo03xDSf.js +4 -4
- package/lib/esm/type/matrix/utils/matAlgo04xSidSid.js +4 -4
- package/lib/esm/type/matrix/utils/matAlgo05xSfSf.js +4 -4
- package/lib/esm/type/matrix/utils/matAlgo06xS0S0.js +4 -4
- package/lib/esm/type/matrix/utils/matAlgo07xSSf.js +4 -4
- package/lib/esm/type/matrix/utils/matAlgo08xS0Sid.js +4 -4
- package/lib/esm/type/matrix/utils/matAlgo09xS0Sf.js +4 -4
- package/lib/esm/utils/map.js +99 -1
- package/lib/esm/utils/scope.js +5 -11
- package/lib/esm/version.js +1 -1
- package/package.json +9 -9
- package/types/index.d.ts +5 -5
@@ -28,10 +28,10 @@ var createMatAlgo07xSSf = exports.createMatAlgo07xSSf = /* #__PURE__ */(0, _fact
|
|
28
28
|
return function matAlgo07xSSf(a, b, callback) {
|
29
29
|
// sparse matrix arrays
|
30
30
|
var asize = a._size;
|
31
|
-
var adt = a._datatype;
|
31
|
+
var adt = a._datatype || a._data === undefined ? a._datatype : a.getDataType();
|
32
32
|
// sparse matrix arrays
|
33
33
|
var bsize = b._size;
|
34
|
-
var bdt = b._datatype;
|
34
|
+
var bdt = b._datatype || b._data === undefined ? b._datatype : b.getDataType();
|
35
35
|
|
36
36
|
// validate dimensions
|
37
37
|
if (asize.length !== bsize.length) {
|
@@ -55,7 +55,7 @@ var createMatAlgo07xSSf = exports.createMatAlgo07xSSf = /* #__PURE__ */(0, _fact
|
|
55
55
|
var cf = callback;
|
56
56
|
|
57
57
|
// process data types
|
58
|
-
if (typeof adt === 'string' && adt === bdt) {
|
58
|
+
if (typeof adt === 'string' && adt === bdt && adt !== 'mixed') {
|
59
59
|
// datatype
|
60
60
|
dt = adt;
|
61
61
|
// convert 0 to the same datatype
|
@@ -103,7 +103,7 @@ var createMatAlgo07xSSf = exports.createMatAlgo07xSSf = /* #__PURE__ */(0, _fact
|
|
103
103
|
return new DenseMatrix({
|
104
104
|
data: cdata,
|
105
105
|
size: [rows, columns],
|
106
|
-
datatype: dt
|
106
|
+
datatype: adt === a._datatype && bdt === b._datatype ? dt : undefined
|
107
107
|
});
|
108
108
|
};
|
109
109
|
function _scatter(m, j, w, x, mark) {
|
@@ -35,13 +35,13 @@ var createMatAlgo08xS0Sid = exports.createMatAlgo08xS0Sid = /* #__PURE__ */(0, _
|
|
35
35
|
var aindex = a._index;
|
36
36
|
var aptr = a._ptr;
|
37
37
|
var asize = a._size;
|
38
|
-
var adt = a._datatype;
|
38
|
+
var adt = a._datatype || a._data === undefined ? a._datatype : a.getDataType();
|
39
39
|
// sparse matrix arrays
|
40
40
|
var bvalues = b._values;
|
41
41
|
var bindex = b._index;
|
42
42
|
var bptr = b._ptr;
|
43
43
|
var bsize = b._size;
|
44
|
-
var bdt = b._datatype;
|
44
|
+
var bdt = b._datatype || b._data === undefined ? b._datatype : b.getDataType();
|
45
45
|
|
46
46
|
// validate dimensions
|
47
47
|
if (asize.length !== bsize.length) {
|
@@ -72,7 +72,7 @@ var createMatAlgo08xS0Sid = exports.createMatAlgo08xS0Sid = /* #__PURE__ */(0, _
|
|
72
72
|
var cf = callback;
|
73
73
|
|
74
74
|
// process data types
|
75
|
-
if (typeof adt === 'string' && adt === bdt) {
|
75
|
+
if (typeof adt === 'string' && adt === bdt && adt !== 'mixed') {
|
76
76
|
// datatype
|
77
77
|
dt = adt;
|
78
78
|
// find signature that matches (dt, dt)
|
@@ -152,7 +152,7 @@ var createMatAlgo08xS0Sid = exports.createMatAlgo08xS0Sid = /* #__PURE__ */(0, _
|
|
152
152
|
index: cindex,
|
153
153
|
ptr: cptr,
|
154
154
|
size: [rows, columns],
|
155
|
-
datatype: dt
|
155
|
+
datatype: adt === a._datatype && bdt === b._datatype ? dt : undefined
|
156
156
|
});
|
157
157
|
};
|
158
158
|
});
|
@@ -35,13 +35,13 @@ var createMatAlgo09xS0Sf = exports.createMatAlgo09xS0Sf = /* #__PURE__ */(0, _fa
|
|
35
35
|
var aindex = a._index;
|
36
36
|
var aptr = a._ptr;
|
37
37
|
var asize = a._size;
|
38
|
-
var adt = a._datatype;
|
38
|
+
var adt = a._datatype || a._data === undefined ? a._datatype : a.getDataType();
|
39
39
|
// sparse matrix arrays
|
40
40
|
var bvalues = b._values;
|
41
41
|
var bindex = b._index;
|
42
42
|
var bptr = b._ptr;
|
43
43
|
var bsize = b._size;
|
44
|
-
var bdt = b._datatype;
|
44
|
+
var bdt = b._datatype || b._data === undefined ? b._datatype : b.getDataType();
|
45
45
|
|
46
46
|
// validate dimensions
|
47
47
|
if (asize.length !== bsize.length) {
|
@@ -67,7 +67,7 @@ var createMatAlgo09xS0Sf = exports.createMatAlgo09xS0Sf = /* #__PURE__ */(0, _fa
|
|
67
67
|
var cf = callback;
|
68
68
|
|
69
69
|
// process data types
|
70
|
-
if (typeof adt === 'string' && adt === bdt) {
|
70
|
+
if (typeof adt === 'string' && adt === bdt && adt !== 'mixed') {
|
71
71
|
// datatype
|
72
72
|
dt = adt;
|
73
73
|
// find signature that matches (dt, dt)
|
@@ -140,7 +140,7 @@ var createMatAlgo09xS0Sf = exports.createMatAlgo09xS0Sf = /* #__PURE__ */(0, _fa
|
|
140
140
|
index: cindex,
|
141
141
|
ptr: cptr,
|
142
142
|
size: [rows, columns],
|
143
|
-
datatype: dt
|
143
|
+
datatype: adt === a._datatype && bdt === b._datatype ? dt : undefined
|
144
144
|
});
|
145
145
|
};
|
146
146
|
});
|
package/lib/cjs/utils/map.js
CHANGED
@@ -4,12 +4,13 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
5
5
|
value: true
|
6
6
|
});
|
7
|
-
exports.ObjectWrappingMap = void 0;
|
7
|
+
exports.PartitionedMap = exports.ObjectWrappingMap = void 0;
|
8
8
|
exports.assign = assign;
|
9
9
|
exports.createEmptyMap = createEmptyMap;
|
10
10
|
exports.createMap = createMap;
|
11
11
|
exports.isMap = isMap;
|
12
12
|
exports.toObject = toObject;
|
13
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
13
14
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
14
15
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
15
16
|
var _customs = require("./customs.js");
|
@@ -29,11 +30,12 @@ var ObjectWrappingMap = exports.ObjectWrappingMap = /*#__PURE__*/function () {
|
|
29
30
|
function ObjectWrappingMap(object) {
|
30
31
|
(0, _classCallCheck2["default"])(this, ObjectWrappingMap);
|
31
32
|
this.wrappedObject = object;
|
33
|
+
this[Symbol.iterator] = this.entries;
|
32
34
|
}
|
33
35
|
(0, _createClass2["default"])(ObjectWrappingMap, [{
|
34
36
|
key: "keys",
|
35
37
|
value: function keys() {
|
36
|
-
return Object.keys(this.wrappedObject);
|
38
|
+
return Object.keys(this.wrappedObject).values();
|
37
39
|
}
|
38
40
|
}, {
|
39
41
|
key: "get",
|
@@ -51,9 +53,169 @@ var ObjectWrappingMap = exports.ObjectWrappingMap = /*#__PURE__*/function () {
|
|
51
53
|
value: function has(key) {
|
52
54
|
return (0, _customs.hasSafeProperty)(this.wrappedObject, key);
|
53
55
|
}
|
56
|
+
}, {
|
57
|
+
key: "entries",
|
58
|
+
value: function entries() {
|
59
|
+
var _this = this;
|
60
|
+
return mapIterator(this.keys(), function (key) {
|
61
|
+
return [key, _this.get(key)];
|
62
|
+
});
|
63
|
+
}
|
64
|
+
}, {
|
65
|
+
key: "forEach",
|
66
|
+
value: function forEach(callback) {
|
67
|
+
var _iterator = _createForOfIteratorHelper(this.keys()),
|
68
|
+
_step;
|
69
|
+
try {
|
70
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
71
|
+
var key = _step.value;
|
72
|
+
callback(this.get(key), key, this);
|
73
|
+
}
|
74
|
+
} catch (err) {
|
75
|
+
_iterator.e(err);
|
76
|
+
} finally {
|
77
|
+
_iterator.f();
|
78
|
+
}
|
79
|
+
}
|
80
|
+
}, {
|
81
|
+
key: "delete",
|
82
|
+
value: function _delete(key) {
|
83
|
+
delete this.wrappedObject[key];
|
84
|
+
}
|
85
|
+
}, {
|
86
|
+
key: "clear",
|
87
|
+
value: function clear() {
|
88
|
+
var _iterator2 = _createForOfIteratorHelper(this.keys()),
|
89
|
+
_step2;
|
90
|
+
try {
|
91
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
92
|
+
var key = _step2.value;
|
93
|
+
this["delete"](key);
|
94
|
+
}
|
95
|
+
} catch (err) {
|
96
|
+
_iterator2.e(err);
|
97
|
+
} finally {
|
98
|
+
_iterator2.f();
|
99
|
+
}
|
100
|
+
}
|
101
|
+
}, {
|
102
|
+
key: "size",
|
103
|
+
get: function get() {
|
104
|
+
return Object.keys(this.wrappedObject).length;
|
105
|
+
}
|
54
106
|
}]);
|
55
107
|
return ObjectWrappingMap;
|
56
108
|
}();
|
109
|
+
/**
|
110
|
+
* Create a map with two partitions: a and b.
|
111
|
+
* The set with bKeys determines which keys/values are read/written to map b,
|
112
|
+
* all other values are read/written to map a
|
113
|
+
*
|
114
|
+
* For example:
|
115
|
+
*
|
116
|
+
* const a = new Map()
|
117
|
+
* const b = new Map()
|
118
|
+
* const p = new PartitionedMap(a, b, new Set(['x', 'y']))
|
119
|
+
*
|
120
|
+
* In this case, values `x` and `y` are read/written to map `b`,
|
121
|
+
* all other values are read/written to map `a`.
|
122
|
+
*/
|
123
|
+
var PartitionedMap = exports.PartitionedMap = /*#__PURE__*/function () {
|
124
|
+
/**
|
125
|
+
* @param {Map} a
|
126
|
+
* @param {Map} b
|
127
|
+
* @param {Set} bKeys
|
128
|
+
*/
|
129
|
+
function PartitionedMap(a, b, bKeys) {
|
130
|
+
(0, _classCallCheck2["default"])(this, PartitionedMap);
|
131
|
+
this.a = a;
|
132
|
+
this.b = b;
|
133
|
+
this.bKeys = bKeys;
|
134
|
+
this[Symbol.iterator] = this.entries;
|
135
|
+
}
|
136
|
+
(0, _createClass2["default"])(PartitionedMap, [{
|
137
|
+
key: "get",
|
138
|
+
value: function get(key) {
|
139
|
+
return this.bKeys.has(key) ? this.b.get(key) : this.a.get(key);
|
140
|
+
}
|
141
|
+
}, {
|
142
|
+
key: "set",
|
143
|
+
value: function set(key, value) {
|
144
|
+
if (this.bKeys.has(key)) {
|
145
|
+
this.b.set(key, value);
|
146
|
+
} else {
|
147
|
+
this.a.set(key, value);
|
148
|
+
}
|
149
|
+
return this;
|
150
|
+
}
|
151
|
+
}, {
|
152
|
+
key: "has",
|
153
|
+
value: function has(key) {
|
154
|
+
return this.b.has(key) || this.a.has(key);
|
155
|
+
}
|
156
|
+
}, {
|
157
|
+
key: "keys",
|
158
|
+
value: function keys() {
|
159
|
+
return new Set([].concat((0, _toConsumableArray2["default"])(this.a.keys()), (0, _toConsumableArray2["default"])(this.b.keys())))[Symbol.iterator]();
|
160
|
+
}
|
161
|
+
}, {
|
162
|
+
key: "entries",
|
163
|
+
value: function entries() {
|
164
|
+
var _this2 = this;
|
165
|
+
return mapIterator(this.keys(), function (key) {
|
166
|
+
return [key, _this2.get(key)];
|
167
|
+
});
|
168
|
+
}
|
169
|
+
}, {
|
170
|
+
key: "forEach",
|
171
|
+
value: function forEach(callback) {
|
172
|
+
var _iterator3 = _createForOfIteratorHelper(this.keys()),
|
173
|
+
_step3;
|
174
|
+
try {
|
175
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
176
|
+
var key = _step3.value;
|
177
|
+
callback(this.get(key), key, this);
|
178
|
+
}
|
179
|
+
} catch (err) {
|
180
|
+
_iterator3.e(err);
|
181
|
+
} finally {
|
182
|
+
_iterator3.f();
|
183
|
+
}
|
184
|
+
}
|
185
|
+
}, {
|
186
|
+
key: "delete",
|
187
|
+
value: function _delete(key) {
|
188
|
+
return this.bKeys.has(key) ? this.b["delete"](key) : this.a["delete"](key);
|
189
|
+
}
|
190
|
+
}, {
|
191
|
+
key: "clear",
|
192
|
+
value: function clear() {
|
193
|
+
this.a.clear();
|
194
|
+
this.b.clear();
|
195
|
+
}
|
196
|
+
}, {
|
197
|
+
key: "size",
|
198
|
+
get: function get() {
|
199
|
+
return (0, _toConsumableArray2["default"])(this.keys()).length;
|
200
|
+
}
|
201
|
+
}]);
|
202
|
+
return PartitionedMap;
|
203
|
+
}();
|
204
|
+
/**
|
205
|
+
* Create a new iterator that maps over the provided iterator, applying a mapping function to each item
|
206
|
+
*/
|
207
|
+
function mapIterator(it, callback) {
|
208
|
+
return {
|
209
|
+
next: function next() {
|
210
|
+
var n = it.next();
|
211
|
+
return n.done ? n : {
|
212
|
+
value: callback(n.value),
|
213
|
+
done: false
|
214
|
+
};
|
215
|
+
}
|
216
|
+
};
|
217
|
+
}
|
218
|
+
|
57
219
|
/**
|
58
220
|
* Creates an empty map, or whatever your platform's polyfill is.
|
59
221
|
*
|
@@ -93,18 +255,18 @@ function toObject(map) {
|
|
93
255
|
return map.wrappedObject;
|
94
256
|
}
|
95
257
|
var object = {};
|
96
|
-
var
|
97
|
-
|
258
|
+
var _iterator4 = _createForOfIteratorHelper(map.keys()),
|
259
|
+
_step4;
|
98
260
|
try {
|
99
|
-
for (
|
100
|
-
var key =
|
261
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
262
|
+
var key = _step4.value;
|
101
263
|
var value = map.get(key);
|
102
264
|
(0, _customs.setSafeProperty)(object, key, value);
|
103
265
|
}
|
104
266
|
} catch (err) {
|
105
|
-
|
267
|
+
_iterator4.e(err);
|
106
268
|
} finally {
|
107
|
-
|
269
|
+
_iterator4.f();
|
108
270
|
}
|
109
271
|
return object;
|
110
272
|
}
|
@@ -143,17 +305,17 @@ function assign(map) {
|
|
143
305
|
continue;
|
144
306
|
}
|
145
307
|
if (isMap(args)) {
|
146
|
-
var
|
147
|
-
|
308
|
+
var _iterator5 = _createForOfIteratorHelper(args.keys()),
|
309
|
+
_step5;
|
148
310
|
try {
|
149
|
-
for (
|
150
|
-
var key =
|
311
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
312
|
+
var key = _step5.value;
|
151
313
|
map.set(key, args.get(key));
|
152
314
|
}
|
153
315
|
} catch (err) {
|
154
|
-
|
316
|
+
_iterator5.e(err);
|
155
317
|
} finally {
|
156
|
-
|
318
|
+
_iterator5.f();
|
157
319
|
}
|
158
320
|
} else if ((0, _is.isObject)(args)) {
|
159
321
|
for (var _i2 = 0, _Object$keys = Object.keys(args); _i2 < _Object$keys.length; _i2++) {
|
package/lib/cjs/utils/scope.js
CHANGED
@@ -15,15 +15,9 @@ var _map = require("./map.js");
|
|
15
15
|
* the remaining `args`.
|
16
16
|
*
|
17
17
|
* @param {Map} parentScope
|
18
|
-
* @param {
|
19
|
-
* @returns {
|
18
|
+
* @param {Object} args
|
19
|
+
* @returns {PartitionedMap}
|
20
20
|
*/
|
21
|
-
function createSubScope(parentScope) {
|
22
|
-
|
23
|
-
args[_key - 1] = arguments[_key];
|
24
|
-
}
|
25
|
-
if (typeof parentScope.createSubScope === 'function') {
|
26
|
-
return _map.assign.apply(void 0, [parentScope.createSubScope()].concat(args));
|
27
|
-
}
|
28
|
-
return _map.assign.apply(void 0, [(0, _map.createEmptyMap)(), parentScope].concat(args));
|
21
|
+
function createSubScope(parentScope, args) {
|
22
|
+
return new _map.PartitionedMap(parentScope, new _map.ObjectWrappingMap(args), new Set(Object.keys(args)));
|
29
23
|
}
|
package/lib/cjs/version.js
CHANGED
@@ -4,6 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.version = void 0;
|
7
|
-
var version = exports.version = '12.
|
7
|
+
var version = exports.version = '12.4.0';
|
8
8
|
// Note: This file is automatically generated when building math.js.
|
9
9
|
// Changes made in this file will be overwritten.
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
2
2
|
import { isNode, isConstantNode, isOperatorNode, isParenthesisNode } from '../../utils/is.js';
|
3
3
|
import { map } from '../../utils/array.js';
|
4
|
+
import { createSubScope } from '../../utils/scope.js';
|
4
5
|
import { escape } from '../../utils/string.js';
|
5
6
|
import { getSafeProperty, isSafeMethod } from '../../utils/customs.js';
|
6
7
|
import { getAssociativity, getPrecedence, isAssociativeWith, properties } from '../operators.js';
|
@@ -289,7 +290,7 @@ export var createOperatorNode = /* #__PURE__ */factory(name, dependencies, _ref
|
|
289
290
|
// "raw" evaluation
|
290
291
|
var rawArgs = this.args;
|
291
292
|
return function evalOperatorNode(scope, args, context) {
|
292
|
-
return fn(rawArgs, math, scope);
|
293
|
+
return fn(rawArgs, math, createSubScope(scope, args));
|
293
294
|
};
|
294
295
|
} else if (evalArgs.length === 1) {
|
295
296
|
var evalArg0 = evalArgs[0];
|
@@ -1409,8 +1409,10 @@ export var createParse = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
1409
1409
|
while (state.token === ';') {
|
1410
1410
|
// eslint-disable-line no-unmodified-loop-condition
|
1411
1411
|
getToken(state);
|
1412
|
-
|
1413
|
-
|
1412
|
+
if (state.token !== ']') {
|
1413
|
+
params[rows] = parseRow(state);
|
1414
|
+
rows++;
|
1415
|
+
}
|
1414
1416
|
}
|
1415
1417
|
if (state.token !== ']') {
|
1416
1418
|
throw createSyntaxError(state, 'End of matrix ] expected');
|
@@ -1458,8 +1460,10 @@ export var createParse = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
1458
1460
|
getToken(state);
|
1459
1461
|
|
1460
1462
|
// parse expression
|
1461
|
-
|
1462
|
-
|
1463
|
+
if (state.token !== ']' && state.token !== ';') {
|
1464
|
+
params[len] = parseAssignment(state);
|
1465
|
+
len++;
|
1466
|
+
}
|
1463
1467
|
}
|
1464
1468
|
return new ArrayNode(params);
|
1465
1469
|
}
|
@@ -1,11 +1,11 @@
|
|
1
1
|
import { isSymbolNode } from '../../../utils/is.js';
|
2
|
-
import {
|
2
|
+
import { PartitionedMap } from '../../../utils/map.js';
|
3
3
|
|
4
4
|
/**
|
5
5
|
* Compile an inline expression like "x > 0"
|
6
6
|
* @param {Node} expression
|
7
7
|
* @param {Object} math
|
8
|
-
* @param {
|
8
|
+
* @param {Map} scope
|
9
9
|
* @return {function} Returns a function with one argument which fills in the
|
10
10
|
* undefined variable (like "x") and evaluates the expression
|
11
11
|
*/
|
@@ -20,10 +20,11 @@ export function compileInlineExpression(expression, math, scope) {
|
|
20
20
|
|
21
21
|
// create a test function for this equation
|
22
22
|
var name = symbol.name; // variable name
|
23
|
-
var
|
23
|
+
var argsScope = new Map();
|
24
|
+
var subScope = new PartitionedMap(scope, argsScope, new Set([name]));
|
24
25
|
var eq = expression.compile();
|
25
26
|
return function inlineExpression(x) {
|
26
|
-
|
27
|
+
argsScope.set(name, x);
|
27
28
|
return eq.evaluate(subScope);
|
28
29
|
};
|
29
30
|
}
|