mathjs 10.5.0 → 10.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. package/HISTORY.md +12 -0
  2. package/docs/datatypes/matrices.md +17 -0
  3. package/docs/expressions/syntax.md +4 -1
  4. package/docs/reference/functions/fix.md +1 -0
  5. package/docs/reference/functions/floor.md +4 -0
  6. package/docs/reference/functions/resolve.md +2 -2
  7. package/docs/reference/functions/simplifyConstant.md +52 -0
  8. package/lib/browser/math.js +5 -5
  9. package/lib/browser/math.js.map +1 -1
  10. package/lib/cjs/entry/dependenciesAny/dependenciesCeil.generated.js +6 -0
  11. package/lib/cjs/entry/dependenciesAny/dependenciesFix.generated.js +9 -0
  12. package/lib/cjs/entry/dependenciesAny/dependenciesFloor.generated.js +6 -0
  13. package/lib/cjs/entry/dependenciesAny/dependenciesIndexNode.generated.js +0 -3
  14. package/lib/cjs/entry/dependenciesNumber/dependenciesCeil.generated.js +3 -0
  15. package/lib/cjs/entry/dependenciesNumber/dependenciesFix.generated.js +6 -0
  16. package/lib/cjs/entry/dependenciesNumber/dependenciesFloor.generated.js +3 -0
  17. package/lib/cjs/entry/dependenciesNumber/dependenciesIndexNode.generated.js +0 -3
  18. package/lib/cjs/entry/impureFunctionsAny.generated.js +0 -1
  19. package/lib/cjs/entry/impureFunctionsNumber.generated.js +6 -7
  20. package/lib/cjs/entry/pureFunctionsAny.generated.js +10 -3
  21. package/lib/cjs/entry/pureFunctionsNumber.generated.js +21 -15
  22. package/lib/cjs/expression/node/IndexNode.js +26 -61
  23. package/lib/cjs/factoriesNumber.js +29 -24
  24. package/lib/cjs/function/algebra/resolve.js +3 -3
  25. package/lib/cjs/function/arithmetic/ceil.js +75 -39
  26. package/lib/cjs/function/arithmetic/fix.js +54 -16
  27. package/lib/cjs/function/arithmetic/floor.js +79 -37
  28. package/lib/cjs/function/arithmetic/nthRoot.js +1 -3
  29. package/lib/cjs/function/arithmetic/round.js +27 -47
  30. package/lib/cjs/header.js +2 -2
  31. package/lib/cjs/plain/number/arithmetic.js +9 -27
  32. package/lib/cjs/type/matrix/function/sparse.js +6 -0
  33. package/lib/cjs/utils/lruQueue.js +1 -3
  34. package/lib/cjs/utils/object.js +3 -1
  35. package/lib/cjs/version.js +1 -1
  36. package/lib/esm/entry/dependenciesAny/dependenciesCeil.generated.js +4 -0
  37. package/lib/esm/entry/dependenciesAny/dependenciesFix.generated.js +6 -0
  38. package/lib/esm/entry/dependenciesAny/dependenciesFloor.generated.js +4 -0
  39. package/lib/esm/entry/dependenciesAny/dependenciesIndexNode.generated.js +0 -2
  40. package/lib/esm/entry/dependenciesNumber/dependenciesCeil.generated.js +2 -0
  41. package/lib/esm/entry/dependenciesNumber/dependenciesFix.generated.js +4 -0
  42. package/lib/esm/entry/dependenciesNumber/dependenciesFloor.generated.js +2 -0
  43. package/lib/esm/entry/dependenciesNumber/dependenciesIndexNode.generated.js +0 -2
  44. package/lib/esm/entry/impureFunctionsAny.generated.js +0 -1
  45. package/lib/esm/entry/impureFunctionsNumber.generated.js +7 -8
  46. package/lib/esm/entry/pureFunctionsAny.generated.js +10 -3
  47. package/lib/esm/entry/pureFunctionsNumber.generated.js +16 -10
  48. package/lib/esm/expression/node/BlockNode.js +3 -3
  49. package/lib/esm/expression/node/IndexNode.js +22 -59
  50. package/lib/esm/expression/parse.js +5 -5
  51. package/lib/esm/factoriesNumber.js +6 -6
  52. package/lib/esm/function/algebra/decomposition/qr.js +2 -2
  53. package/lib/esm/function/algebra/resolve.js +3 -3
  54. package/lib/esm/function/algebra/solver/utils/solveValidation.js +5 -5
  55. package/lib/esm/function/algebra/sparse/csChol.js +2 -2
  56. package/lib/esm/function/algebra/sparse/csLeaf.js +2 -2
  57. package/lib/esm/function/algebra/sparse/csLu.js +3 -3
  58. package/lib/esm/function/arithmetic/ceil.js +61 -24
  59. package/lib/esm/function/arithmetic/fix.js +51 -13
  60. package/lib/esm/function/arithmetic/floor.js +65 -23
  61. package/lib/esm/function/arithmetic/nthRoot.js +1 -3
  62. package/lib/esm/function/arithmetic/nthRoots.js +1 -1
  63. package/lib/esm/function/arithmetic/round.js +25 -43
  64. package/lib/esm/function/matrix/expm.js +2 -2
  65. package/lib/esm/function/probability/gamma.js +1 -1
  66. package/lib/esm/function/string/bin.js +1 -1
  67. package/lib/esm/function/string/hex.js +1 -1
  68. package/lib/esm/function/string/oct.js +1 -1
  69. package/lib/esm/plain/number/arithmetic.js +9 -17
  70. package/lib/esm/type/complex/Complex.js +2 -2
  71. package/lib/esm/type/matrix/DenseMatrix.js +2 -2
  72. package/lib/esm/type/matrix/FibonacciHeap.js +2 -2
  73. package/lib/esm/type/matrix/SparseMatrix.js +13 -13
  74. package/lib/esm/type/matrix/function/sparse.js +6 -0
  75. package/lib/esm/type/unit/Unit.js +7 -7
  76. package/lib/esm/utils/lruQueue.js +1 -2
  77. package/lib/esm/utils/number.js +3 -3
  78. package/lib/esm/utils/object.js +3 -1
  79. package/lib/esm/version.js +1 -1
  80. package/package.json +14 -3
  81. package/types/index.d.ts +1794 -1372
  82. package/types/index.ts +697 -266
@@ -6,13 +6,10 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.absNumber = absNumber;
7
7
  exports.addNumber = addNumber;
8
8
  exports.cbrtNumber = cbrtNumber;
9
- exports.ceilNumber = ceilNumber;
10
9
  exports.cubeNumber = cubeNumber;
11
10
  exports.divideNumber = divideNumber;
12
11
  exports.expNumber = expNumber;
13
12
  exports.expm1Number = expm1Number;
14
- exports.fixNumber = fixNumber;
15
- exports.floorNumber = floorNumber;
16
13
  exports.gcdNumber = gcdNumber;
17
14
  exports.lcmNumber = lcmNumber;
18
15
  exports.log10Number = log10Number;
@@ -86,12 +83,6 @@ function cbrtNumber(x) {
86
83
 
87
84
  cbrtNumber.signature = n1;
88
85
 
89
- function ceilNumber(x) {
90
- return Math.ceil(x);
91
- }
92
-
93
- ceilNumber.signature = n1;
94
-
95
86
  function cubeNumber(x) {
96
87
  return x * x * x;
97
88
  }
@@ -109,18 +100,6 @@ function expm1Number(x) {
109
100
  }
110
101
 
111
102
  expm1Number.signature = n1;
112
-
113
- function fixNumber(x) {
114
- return x > 0 ? Math.floor(x) : Math.ceil(x);
115
- }
116
-
117
- fixNumber.signature = n1;
118
-
119
- function floorNumber(x) {
120
- return Math.floor(x);
121
- }
122
-
123
- floorNumber.signature = n1;
124
103
  /**
125
104
  * Calculate gcd for numbers
126
105
  * @param {number} a
@@ -253,11 +232,12 @@ modNumber.signature = n2;
253
232
  * Calculate the nth root of a, solve x^root == a
254
233
  * http://rosettacode.org/wiki/Nth_root#JavaScript
255
234
  * @param {number} a
256
- * @param {number} root
235
+ * @param {number} [2] root
257
236
  * @private
258
237
  */
259
238
 
260
- function nthRootNumber(a, root) {
239
+ function nthRootNumber(a) {
240
+ var root = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
261
241
  var inv = root < 0;
262
242
 
263
243
  if (inv) {
@@ -308,8 +288,6 @@ function nthRootNumber(a, root) {
308
288
  */
309
289
  }
310
290
 
311
- nthRootNumber.signature = n2;
312
-
313
291
  function signNumber(x) {
314
292
  return (0, _number.sign)(x);
315
293
  }
@@ -405,16 +383,20 @@ powNumber.signature = n2;
405
383
 
406
384
  function roundNumber(value) {
407
385
  var decimals = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
386
+
387
+ if (!(0, _number.isInteger)(decimals) || decimals < 0 || decimals > 15) {
388
+ throw new Error('Number of decimals in function round must be an integer from 0 to 15 inclusive');
389
+ }
390
+
408
391
  return parseFloat((0, _number.toFixed)(value, decimals));
409
392
  }
410
-
411
- roundNumber.signature = n2;
412
393
  /**
413
394
  * Calculate the norm of a number, the absolute value.
414
395
  * @param {number} x
415
396
  * @return {number}
416
397
  */
417
398
 
399
+
418
400
  function normNumber(x) {
419
401
  return Math.abs(x);
420
402
  }
@@ -17,6 +17,9 @@ var createSparse = /* #__PURE__ */(0, _factory.factory)(name, dependencies, func
17
17
  * Create a Sparse Matrix. The function creates a new `math.Matrix` object from
18
18
  * an `Array`. A Matrix has utility functions to manipulate the data in the
19
19
  * matrix, like getting the size and getting or setting values in the matrix.
20
+ * Note that a Sparse Matrix is always 2-dimensional, so for example if
21
+ * you create one from a plain array of _n_ numbers, you get an _n_ by 1
22
+ * Sparse "column vector".
20
23
  *
21
24
  * Syntax:
22
25
  *
@@ -31,6 +34,9 @@ var createSparse = /* #__PURE__ */(0, _factory.factory)(name, dependencies, func
31
34
  * m.resize([3, 2], 5)
32
35
  * m.valueOf() // Array [[1, 2], [3, 4], [5, 5]]
33
36
  * m.get([1, 0]) // number 3
37
+ * let v = math.sparse([0, 0, 1])
38
+ * v.size() // Array [3, 1]
39
+ * v.get([2, 0]) // number 1
34
40
  *
35
41
  * See also:
36
42
  *
@@ -67,6 +67,4 @@ function lruQueue(limit) {
67
67
  map = Object.create(null);
68
68
  }
69
69
  };
70
- }
71
-
72
- ;
70
+ }
@@ -232,7 +232,9 @@ function canDefineProperty() {
232
232
  try {
233
233
  if (Object.defineProperty) {
234
234
  Object.defineProperty({}, 'x', {
235
- get: function get() {}
235
+ get: function get() {
236
+ return null;
237
+ }
236
238
  });
237
239
  return true;
238
240
  }
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.version = void 0;
7
- var version = '10.5.0'; // Note: This file is automatically generated when building math.js.
7
+ var version = '10.5.1'; // 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;
@@ -2,15 +2,19 @@
2
2
  * THIS FILE IS AUTO-GENERATED
3
3
  * DON'T MAKE CHANGES HERE
4
4
  */
5
+ import { DenseMatrixDependencies } from './dependenciesDenseMatrixClass.generated.js';
5
6
  import { equalScalarDependencies } from './dependenciesEqualScalar.generated.js';
6
7
  import { matrixDependencies } from './dependenciesMatrix.generated.js';
7
8
  import { roundDependencies } from './dependenciesRound.generated.js';
8
9
  import { typedDependencies } from './dependenciesTyped.generated.js';
10
+ import { zerosDependencies } from './dependenciesZeros.generated.js';
9
11
  import { createCeil } from '../../factoriesAny.js';
10
12
  export var ceilDependencies = {
13
+ DenseMatrixDependencies,
11
14
  equalScalarDependencies,
12
15
  matrixDependencies,
13
16
  roundDependencies,
14
17
  typedDependencies,
18
+ zerosDependencies,
15
19
  createCeil
16
20
  };
@@ -3,16 +3,22 @@
3
3
  * DON'T MAKE CHANGES HERE
4
4
  */
5
5
  import { ComplexDependencies } from './dependenciesComplexClass.generated.js';
6
+ import { DenseMatrixDependencies } from './dependenciesDenseMatrixClass.generated.js';
6
7
  import { ceilDependencies } from './dependenciesCeil.generated.js';
8
+ import { equalScalarDependencies } from './dependenciesEqualScalar.generated.js';
7
9
  import { floorDependencies } from './dependenciesFloor.generated.js';
8
10
  import { matrixDependencies } from './dependenciesMatrix.generated.js';
9
11
  import { typedDependencies } from './dependenciesTyped.generated.js';
12
+ import { zerosDependencies } from './dependenciesZeros.generated.js';
10
13
  import { createFix } from '../../factoriesAny.js';
11
14
  export var fixDependencies = {
12
15
  ComplexDependencies,
16
+ DenseMatrixDependencies,
13
17
  ceilDependencies,
18
+ equalScalarDependencies,
14
19
  floorDependencies,
15
20
  matrixDependencies,
16
21
  typedDependencies,
22
+ zerosDependencies,
17
23
  createFix
18
24
  };
@@ -2,15 +2,19 @@
2
2
  * THIS FILE IS AUTO-GENERATED
3
3
  * DON'T MAKE CHANGES HERE
4
4
  */
5
+ import { DenseMatrixDependencies } from './dependenciesDenseMatrixClass.generated.js';
5
6
  import { equalScalarDependencies } from './dependenciesEqualScalar.generated.js';
6
7
  import { matrixDependencies } from './dependenciesMatrix.generated.js';
7
8
  import { roundDependencies } from './dependenciesRound.generated.js';
8
9
  import { typedDependencies } from './dependenciesTyped.generated.js';
10
+ import { zerosDependencies } from './dependenciesZeros.generated.js';
9
11
  import { createFloor } from '../../factoriesAny.js';
10
12
  export var floorDependencies = {
13
+ DenseMatrixDependencies,
11
14
  equalScalarDependencies,
12
15
  matrixDependencies,
13
16
  roundDependencies,
14
17
  typedDependencies,
18
+ zerosDependencies,
15
19
  createFloor
16
20
  };
@@ -3,12 +3,10 @@
3
3
  * DON'T MAKE CHANGES HERE
4
4
  */
5
5
  import { NodeDependencies } from './dependenciesNode.generated.js';
6
- import { RangeDependencies } from './dependenciesRangeClass.generated.js';
7
6
  import { sizeDependencies } from './dependenciesSize.generated.js';
8
7
  import { createIndexNode } from '../../factoriesAny.js';
9
8
  export var IndexNodeDependencies = {
10
9
  NodeDependencies,
11
- RangeDependencies,
12
10
  sizeDependencies,
13
11
  createIndexNode
14
12
  };
@@ -2,9 +2,11 @@
2
2
  * THIS FILE IS AUTO-GENERATED
3
3
  * DON'T MAKE CHANGES HERE
4
4
  */
5
+ import { roundDependencies } from './dependenciesRound.generated.js';
5
6
  import { typedDependencies } from './dependenciesTyped.generated.js';
6
7
  import { createCeil } from '../../factoriesNumber.js';
7
8
  export var ceilDependencies = {
9
+ roundDependencies,
8
10
  typedDependencies,
9
11
  createCeil
10
12
  };
@@ -2,9 +2,13 @@
2
2
  * THIS FILE IS AUTO-GENERATED
3
3
  * DON'T MAKE CHANGES HERE
4
4
  */
5
+ import { ceilDependencies } from './dependenciesCeil.generated.js';
6
+ import { floorDependencies } from './dependenciesFloor.generated.js';
5
7
  import { typedDependencies } from './dependenciesTyped.generated.js';
6
8
  import { createFix } from '../../factoriesNumber.js';
7
9
  export var fixDependencies = {
10
+ ceilDependencies,
11
+ floorDependencies,
8
12
  typedDependencies,
9
13
  createFix
10
14
  };
@@ -2,9 +2,11 @@
2
2
  * THIS FILE IS AUTO-GENERATED
3
3
  * DON'T MAKE CHANGES HERE
4
4
  */
5
+ import { roundDependencies } from './dependenciesRound.generated.js';
5
6
  import { typedDependencies } from './dependenciesTyped.generated.js';
6
7
  import { createFloor } from '../../factoriesNumber.js';
7
8
  export var floorDependencies = {
9
+ roundDependencies,
8
10
  typedDependencies,
9
11
  createFloor
10
12
  };
@@ -3,12 +3,10 @@
3
3
  * DON'T MAKE CHANGES HERE
4
4
  */
5
5
  import { NodeDependencies } from './dependenciesNode.generated.js';
6
- import { RangeDependencies } from './dependenciesRangeClass.generated.js';
7
6
  import { sizeDependencies } from './dependenciesSize.generated.js';
8
7
  import { createIndexNode } from '../../factoriesNumber.js';
9
8
  export var IndexNodeDependencies = {
10
9
  NodeDependencies,
11
- RangeDependencies,
12
10
  sizeDependencies,
13
11
  createIndexNode
14
12
  };
@@ -70,7 +70,6 @@ export var AssignmentNode = createAssignmentNode({
70
70
  });
71
71
  export var IndexNode = createIndexNode({
72
72
  Node,
73
- Range,
74
73
  size
75
74
  });
76
75
  export var SymbolNode = createSymbolNode({
@@ -7,7 +7,7 @@ import _extends from "@babel/runtime/helpers/extends";
7
7
  import { config } from './configReadonly.js';
8
8
  import { createChainClass, createChain, createNode, createObjectNode, createRangeNode, createRelationalNode, createReviver, createSymbolNode, createAccessorNode, createAssignmentNode, createBlockNode, createConditionalNode, createFunctionNode, createIndexNode, createOperatorNode, createConstantNode, createFunctionAssignmentNode, createParenthesisNode, createArrayNode, createSimplifyCore, createParse, createResolve, createCompile, createEvaluate, createHelpClass, createParserClass, createSimplify, createDerivative, createRationalize, createHelp, createParser, createCumSumTransform, createApplyTransform, createFilterTransform, createForEachTransform, createMapTransform, createMeanTransform, createSubsetTransform, createVarianceTransform, createMaxTransform, createMinTransform, createRangeTransform, createStdTransform, createSumTransform } from '../factoriesNumber.js';
9
9
  import { e, _false, index, _Infinity, LN10, LOG10E, matrix, _NaN, _null, phi, Range, replacer, ResultSet, SQRT1_2, // eslint-disable-line camelcase
10
- subset, tau, typed, unaryPlus, version, xor, abs, acos, acot, acsc, add, and, asec, asin, atan, atanh, bitAnd, bitOr, boolean, cbrt, combinations, compare, compareText, cos, cot, csc, cube, divide, equalScalar, erf, exp, filter, fix, forEach, format, gamma, isInteger, isNegative, isPositive, isZero, LOG2E, largerEq, leftShift, log, log1p, map, mean, mod, multiply, not, number, or, pi, pow, random, rightLogShift, SQRT2, sech, sin, size, smallerEq, square, string, subtract, tanh, typeOf, unequal, xgcd, acoth, addScalar, asech, bitNot, ceil, combinationsWithRep, cosh, csch, divideScalar, equalText, expm1, isNumeric, LN2, lcm, log10, multiplyScalar, nthRoot, pickRandom, randomInt, rightArithShift, sec, sinh, sqrt, tan, unaryMinus, acosh, apply, asinh, bitXor, clone, cumsum, equal, factorial, hasNumericValue, isNaN, larger, log2, mode, norm, partitionSelect, print, quantileSeq, round, smaller, stirlingS2, _true, variance, acsch, atan2, catalan, composition, deepEqual, floor, hypot, lgamma, median, multinomial, permutations, range, sign, std, compareNatural, coth, gcd, isPrime, numeric, prod, sum, bellNumbers, mad, max, min } from './pureFunctionsNumber.generated.js';
10
+ subset, tau, typed, unaryPlus, version, xor, abs, acos, acot, acsc, add, and, asec, asin, atan, atanh, bitAnd, bitOr, boolean, cbrt, combinations, compare, compareText, cos, cot, csc, cube, divide, equalScalar, erf, exp, filter, forEach, format, gamma, isInteger, isNegative, isPositive, isZero, LOG2E, largerEq, leftShift, log, log1p, map, mean, mod, multiply, not, number, or, pi, pow, random, rightLogShift, SQRT2, sech, sin, size, smallerEq, square, string, subtract, tanh, typeOf, unequal, xgcd, acoth, addScalar, asech, bitNot, clone, compareNatural, cosh, csch, divideScalar, equalText, expm1, isNumeric, LN2, lcm, log10, multiplyScalar, nthRoot, pickRandom, randomInt, rightArithShift, sec, sinh, sqrt, tan, unaryMinus, acosh, apply, asinh, bitXor, combinationsWithRep, cumsum, equal, factorial, hasNumericValue, isNaN, larger, log2, mode, norm, partitionSelect, print, quantileSeq, round, smaller, stirlingS2, _true, variance, acsch, atan2, catalan, composition, deepEqual, floor, hypot, lgamma, median, multinomial, permutations, range, sign, std, ceil, coth, fix, isPrime, numeric, prod, sum, bellNumbers, gcd, mad, max, min } from './pureFunctionsNumber.generated.js';
11
11
  var math = {}; // NOT pure!
12
12
 
13
13
  var mathWithTransform = {}; // NOT pure!
@@ -63,7 +63,6 @@ export var FunctionNode = createFunctionNode({
63
63
  });
64
64
  export var IndexNode = createIndexNode({
65
65
  Node,
66
- Range,
67
66
  size
68
67
  });
69
68
  export var OperatorNode = createOperatorNode({
@@ -262,7 +261,6 @@ _extends(math, {
262
261
  erf,
263
262
  exp,
264
263
  filter,
265
- fix,
266
264
  forEach,
267
265
  format,
268
266
  gamma,
@@ -303,8 +301,8 @@ _extends(math, {
303
301
  addScalar,
304
302
  asech,
305
303
  bitNot,
306
- ceil,
307
- combinationsWithRep,
304
+ clone,
305
+ compareNatural,
308
306
  cosh,
309
307
  csch,
310
308
  divideScalar,
@@ -328,7 +326,7 @@ _extends(math, {
328
326
  apply,
329
327
  asinh,
330
328
  bitXor,
331
- clone,
329
+ combinationsWithRep,
332
330
  cumsum,
333
331
  equal,
334
332
  factorial,
@@ -361,15 +359,16 @@ _extends(math, {
361
359
  sign,
362
360
  std,
363
361
  'PI': pi,
364
- compareNatural,
362
+ ceil,
365
363
  coth,
366
- gcd,
364
+ fix,
367
365
  isPrime,
368
366
  numeric,
369
367
  prod,
370
368
  simplifyCore,
371
369
  sum,
372
370
  bellNumbers,
371
+ gcd,
373
372
  mad,
374
373
  max,
375
374
  parse,
@@ -753,11 +753,13 @@ export var equalText = /* #__PURE__ */createEqualText({
753
753
  typed
754
754
  });
755
755
  export var floor = /* #__PURE__ */createFloor({
756
+ DenseMatrix,
756
757
  config,
757
758
  equalScalar,
758
759
  matrix,
759
760
  round,
760
- typed
761
+ typed,
762
+ zeros
761
763
  });
762
764
  export var identity = /* #__PURE__ */createIdentity({
763
765
  BigNumber,
@@ -921,11 +923,13 @@ export var asin = /* #__PURE__ */createAsin({
921
923
  typed
922
924
  });
923
925
  export var ceil = /* #__PURE__ */createCeil({
926
+ DenseMatrix,
924
927
  config,
925
928
  equalScalar,
926
929
  matrix,
927
930
  round,
928
- typed
931
+ typed,
932
+ zeros
929
933
  });
930
934
  export var column = /* #__PURE__ */createColumn({
931
935
  Index,
@@ -979,10 +983,13 @@ export var FibonacciHeap = /* #__PURE__ */createFibonacciHeapClass({
979
983
  });
980
984
  export var fix = /* #__PURE__ */createFix({
981
985
  Complex,
986
+ DenseMatrix,
982
987
  ceil,
988
+ equalScalar,
983
989
  floor,
984
990
  matrix,
985
- typed
991
+ typed,
992
+ zeros
986
993
  });
987
994
  export var index = /* #__PURE__ */createIndex({
988
995
  Index,
@@ -4,7 +4,7 @@
4
4
  */
5
5
  import { config } from './configReadonly.js';
6
6
  import { createE, createFalse, createIndex, createInfinity, createLN10, createLOG10E, createMatrix, createNaN, createNull, createPhi, createRangeClass, createReplacer, createResultSet, createSQRT1_2, // eslint-disable-line camelcase
7
- createSubset, createTau, createTyped, createUnaryPlus, createVersion, createXor, createAbs, createAcos, createAcot, createAcsc, createAdd, createAnd, createAsec, createAsin, createAtan, createAtanh, createBitAnd, createBitOr, createBoolean, createCbrt, createCombinations, createCompare, createCompareText, createCos, createCot, createCsc, createCube, createDivide, createEqualScalar, createErf, createExp, createFilter, createFix, createForEach, createFormat, createGamma, createIsInteger, createIsNegative, createIsPositive, createIsZero, createLOG2E, createLargerEq, createLeftShift, createLog, createLog1p, createMap, createMean, createMod, createMultiply, createNot, createNumber, createOr, createPi, createPow, createRandom, createRightLogShift, createSQRT2, createSech, createSin, createSize, createSmallerEq, createSquare, createString, createSubtract, createTanh, createTypeOf, createUnequal, createXgcd, createAcoth, createAddScalar, createAsech, createBitNot, createCeil, createCombinationsWithRep, createCosh, createCsch, createDivideScalar, createEqualText, createExpm1, createIsNumeric, createLN2, createLcm, createLog10, createMultiplyScalar, createNthRoot, createPickRandom, createRandomInt, createRightArithShift, createSec, createSinh, createSqrt, createTan, createUnaryMinus, createAcosh, createApply, createAsinh, createBitXor, createClone, createCumSum, createEqual, createFactorial, createHasNumericValue, createIsNaN, createLarger, createLog2, createMode, createNorm, createPartitionSelect, createPrint, createQuantileSeq, createRound, createSmaller, createStirlingS2, createTrue, createVariance, createAcsch, createAtan2, createCatalan, createComposition, createDeepEqual, createFloor, createHypot, createLgamma, createMedian, createMultinomial, createPermutations, createRange, createSign, createStd, createCompareNatural, createCoth, createGcd, createIsPrime, createNumeric, createProd, createSum, createBellNumbers, createMad, createMax, createMin } from '../factoriesNumber.js';
7
+ createSubset, createTau, createTyped, createUnaryPlus, createVersion, createXor, createAbs, createAcos, createAcot, createAcsc, createAdd, createAnd, createAsec, createAsin, createAtan, createAtanh, createBitAnd, createBitOr, createBoolean, createCbrt, createCombinations, createCompare, createCompareText, createCos, createCot, createCsc, createCube, createDivide, createEqualScalar, createErf, createExp, createFilter, createForEach, createFormat, createGamma, createIsInteger, createIsNegative, createIsPositive, createIsZero, createLOG2E, createLargerEq, createLeftShift, createLog, createLog1p, createMap, createMean, createMod, createMultiply, createNot, createNumber, createOr, createPi, createPow, createRandom, createRightLogShift, createSQRT2, createSech, createSin, createSize, createSmallerEq, createSquare, createString, createSubtract, createTanh, createTypeOf, createUnequal, createXgcd, createAcoth, createAddScalar, createAsech, createBitNot, createClone, createCompareNatural, createCosh, createCsch, createDivideScalar, createEqualText, createExpm1, createIsNumeric, createLN2, createLcm, createLog10, createMultiplyScalar, createNthRoot, createPickRandom, createRandomInt, createRightArithShift, createSec, createSinh, createSqrt, createTan, createUnaryMinus, createAcosh, createApply, createAsinh, createBitXor, createCombinationsWithRep, createCumSum, createEqual, createFactorial, createHasNumericValue, createIsNaN, createLarger, createLog2, createMode, createNorm, createPartitionSelect, createPrint, createQuantileSeq, createRound, createSmaller, createStirlingS2, createTrue, createVariance, createAcsch, createAtan2, createCatalan, createComposition, createDeepEqual, createFloor, createHypot, createLgamma, createMedian, createMultinomial, createPermutations, createRange, createSign, createStd, createCeil, createCoth, createFix, createIsPrime, createNumeric, createProd, createSum, createBellNumbers, createGcd, createMad, createMax, createMin } from '../factoriesNumber.js';
8
8
  export var e = /* #__PURE__ */createE({
9
9
  config
10
10
  });
@@ -125,9 +125,6 @@ export var exp = /* #__PURE__ */createExp({
125
125
  export var filter = /* #__PURE__ */createFilter({
126
126
  typed
127
127
  });
128
- export var fix = /* #__PURE__ */createFix({
129
- typed
130
- });
131
128
  export var forEach = /* #__PURE__ */createForEach({
132
129
  typed
133
130
  });
@@ -253,10 +250,11 @@ export var asech = /* #__PURE__ */createAsech({
253
250
  export var bitNot = /* #__PURE__ */createBitNot({
254
251
  typed
255
252
  });
256
- export var ceil = /* #__PURE__ */createCeil({
253
+ export var clone = /* #__PURE__ */createClone({
257
254
  typed
258
255
  });
259
- export var combinationsWithRep = /* #__PURE__ */createCombinationsWithRep({
256
+ export var compareNatural = /* #__PURE__ */createCompareNatural({
257
+ compare,
260
258
  typed
261
259
  });
262
260
  export var cosh = /* #__PURE__ */createCosh({
@@ -333,7 +331,7 @@ export var asinh = /* #__PURE__ */createAsinh({
333
331
  export var bitXor = /* #__PURE__ */createBitXor({
334
332
  typed
335
333
  });
336
- export var clone = /* #__PURE__ */createClone({
334
+ export var combinationsWithRep = /* #__PURE__ */createCombinationsWithRep({
337
335
  typed
338
336
  });
339
337
  export var cumsum = /* #__PURE__ */createCumSum({
@@ -447,6 +445,8 @@ export var deepEqual = /* #__PURE__ */createDeepEqual({
447
445
  typed
448
446
  });
449
447
  export var floor = /* #__PURE__ */createFloor({
448
+ config,
449
+ round,
450
450
  typed
451
451
  });
452
452
  export var hypot = /* #__PURE__ */createHypot({
@@ -499,14 +499,17 @@ export var std = /* #__PURE__ */createStd({
499
499
  typed,
500
500
  variance
501
501
  });
502
- export var compareNatural = /* #__PURE__ */createCompareNatural({
503
- compare,
502
+ export var ceil = /* #__PURE__ */createCeil({
503
+ config,
504
+ round,
504
505
  typed
505
506
  });
506
507
  export var coth = /* #__PURE__ */createCoth({
507
508
  typed
508
509
  });
509
- export var gcd = /* #__PURE__ */createGcd({
510
+ export var fix = /* #__PURE__ */createFix({
511
+ ceil,
512
+ floor,
510
513
  typed
511
514
  });
512
515
  export var isPrime = /* #__PURE__ */createIsPrime({
@@ -534,6 +537,9 @@ export var bellNumbers = /* #__PURE__ */createBellNumbers({
534
537
  stirlingS2,
535
538
  typed
536
539
  });
540
+ export var gcd = /* #__PURE__ */createGcd({
541
+ typed
542
+ });
537
543
  export var mad = /* #__PURE__ */createMad({
538
544
  abs,
539
545
  map,
@@ -31,8 +31,8 @@ export var createBlockNode = /* #__PURE__ */factory(name, dependencies, _ref =>
31
31
  if (!isNode(node)) throw new TypeError('Property "node" must be a Node');
32
32
  if (typeof visible !== 'boolean') throw new TypeError('Property "visible" must be a boolean');
33
33
  return {
34
- node: node,
35
- visible: visible
34
+ node,
35
+ visible
36
36
  };
37
37
  });
38
38
  }
@@ -101,7 +101,7 @@ export var createBlockNode = /* #__PURE__ */factory(name, dependencies, _ref =>
101
101
  var node = this._ifNode(callback(block.node, 'blocks[' + i + '].node', this));
102
102
 
103
103
  blocks[i] = {
104
- node: node,
104
+ node,
105
105
  visible: block.visible
106
106
  };
107
107
  }
@@ -1,13 +1,12 @@
1
- import { isBigNumber, isConstantNode, isNode, isRangeNode, isSymbolNode } from '../../utils/is.js';
2
1
  import { map } from '../../utils/array.js';
3
- import { escape } from '../../utils/string.js';
4
- import { factory } from '../../utils/factory.js';
5
2
  import { getSafeProperty } from '../../utils/customs.js';
3
+ import { factory } from '../../utils/factory.js';
4
+ import { isArray, isConstantNode, isMatrix, isNode, isString, typeOf } from '../../utils/is.js';
5
+ import { escape } from '../../utils/string.js';
6
6
  var name = 'IndexNode';
7
- var dependencies = ['Range', 'Node', 'size'];
7
+ var dependencies = ['Node', 'size'];
8
8
  export var createIndexNode = /* #__PURE__ */factory(name, dependencies, _ref => {
9
9
  var {
10
- Range,
11
10
  Node,
12
11
  size
13
12
  } = _ref;
@@ -67,61 +66,30 @@ export var createIndexNode = /* #__PURE__ */factory(name, dependencies, _ref =>
67
66
  // TODO: Optimization: when the range values are ConstantNodes,
68
67
  // we can beforehand resolve the zero-based value
69
68
  // optimization for a simple object property
70
- var evalDimensions = map(this.dimensions, function (range, i) {
71
- if (isRangeNode(range)) {
72
- if (range.needsEnd()) {
73
- // create a range containing end (like '4:end')
74
- var childArgNames = Object.create(argNames);
75
- childArgNames.end = true;
76
-
77
- var evalStart = range.start._compile(math, childArgNames);
78
-
79
- var evalEnd = range.end._compile(math, childArgNames);
80
-
81
- var evalStep = range.step ? range.step._compile(math, childArgNames) : function () {
82
- return 1;
83
- };
84
- return function evalDimension(scope, args, context) {
85
- var s = size(context).valueOf();
86
- var childArgs = Object.create(args);
87
- childArgs.end = s[i];
88
- return createRange(evalStart(scope, childArgs, context), evalEnd(scope, childArgs, context), evalStep(scope, childArgs, context));
89
- };
90
- } else {
91
- // create range
92
- var _evalStart = range.start._compile(math, argNames);
93
-
94
- var _evalEnd = range.end._compile(math, argNames);
95
-
96
- var _evalStep = range.step ? range.step._compile(math, argNames) : function () {
97
- return 1;
98
- };
99
-
100
- return function evalDimension(scope, args, context) {
101
- return createRange(_evalStart(scope, args, context), _evalEnd(scope, args, context), _evalStep(scope, args, context));
102
- };
103
- }
104
- } else if (isSymbolNode(range) && range.name === 'end') {
105
- // SymbolNode 'end'
106
- var _childArgNames = Object.create(argNames);
107
-
108
- _childArgNames.end = true;
109
-
110
- var evalRange = range._compile(math, _childArgNames);
69
+ var evalDimensions = map(this.dimensions, function (dimension, i) {
70
+ var needsEnd = dimension.filter(node => node.isSymbolNode && node.name === 'end').length > 0;
71
+
72
+ if (needsEnd) {
73
+ // SymbolNode 'end' is used inside the index,
74
+ // like in `A[end]` or `A[end - 2]`
75
+ var childArgNames = Object.create(argNames);
76
+ childArgNames.end = true;
77
+
78
+ var _evalDimension = dimension._compile(math, childArgNames);
111
79
 
112
80
  return function evalDimension(scope, args, context) {
81
+ if (!isMatrix(context) && !isArray(context) && !isString(context)) {
82
+ throw new TypeError('Cannot resolve "end": ' + 'context must be a Matrix, Array, or string but is ' + typeOf(context));
83
+ }
84
+
113
85
  var s = size(context).valueOf();
114
86
  var childArgs = Object.create(args);
115
87
  childArgs.end = s[i];
116
- return evalRange(scope, childArgs, context);
88
+ return _evalDimension(scope, childArgs, context);
117
89
  };
118
90
  } else {
119
- // ConstantNode
120
- var _evalRange = range._compile(math, argNames);
121
-
122
- return function evalDimension(scope, args, context) {
123
- return _evalRange(scope, args, context);
124
- };
91
+ // SymbolNode `end` not used
92
+ return dimension._compile(math, argNames);
125
93
  }
126
94
  });
127
95
  var index = getSafeProperty(math, 'index');
@@ -257,12 +225,7 @@ export var createIndexNode = /* #__PURE__ */factory(name, dependencies, _ref =>
257
225
  return range.toTex(options);
258
226
  });
259
227
  return this.dotNotation ? '.' + this.getObjectProperty() + '' : '_{' + dimensions.join(',') + '}';
260
- }; // helper function to create a Range from start, step and end
261
-
262
-
263
- function createRange(start, end, step) {
264
- return new Range(isBigNumber(start) ? start.toNumber() : start, isBigNumber(end) ? end.toNumber() : end, isBigNumber(step) ? step.toNumber() : step);
265
- }
228
+ };
266
229
 
267
230
  return IndexNode;
268
231
  }, {
@@ -151,7 +151,7 @@ export var createParse = /* #__PURE__ */factory(name, dependencies, _ref => {
151
151
  true: true,
152
152
  false: false,
153
153
  null: null,
154
- undefined: undefined
154
+ undefined
155
155
  };
156
156
  var NUMERIC_CONSTANTS = ['NaN', 'Infinity'];
157
157
 
@@ -623,8 +623,8 @@ export var createParse = /* #__PURE__ */factory(name, dependencies, _ref => {
623
623
  if (blocks.length === 0 && node) {
624
624
  visible = state.token !== ';';
625
625
  blocks.push({
626
- node: node,
627
- visible: visible
626
+ node,
627
+ visible
628
628
  });
629
629
  }
630
630
 
@@ -635,8 +635,8 @@ export var createParse = /* #__PURE__ */factory(name, dependencies, _ref => {
635
635
  node.comment = state.comment;
636
636
  visible = state.token !== ';';
637
637
  blocks.push({
638
- node: node,
639
- visible: visible
638
+ node,
639
+ visible
640
640
  });
641
641
  }
642
642
  }