@cortex-js/compute-engine 0.26.3 → 0.27.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 (142) hide show
  1. package/dist/compute-engine.esm.js +8292 -7913
  2. package/dist/compute-engine.js +8292 -7913
  3. package/dist/compute-engine.min.esm.js +45 -41
  4. package/dist/compute-engine.min.js +45 -41
  5. package/dist/math-json.esm.js +2 -2
  6. package/dist/math-json.js +2 -2
  7. package/dist/math-json.min.esm.js +2 -2
  8. package/dist/math-json.min.js +2 -2
  9. package/dist/types/common/ansi-codes.d.ts +1 -1
  10. package/dist/types/common/buffer.d.ts +1 -1
  11. package/dist/types/common/grapheme-splitter.d.ts +1 -1
  12. package/dist/types/common/interruptible.d.ts +20 -0
  13. package/dist/types/common/one-of.d.ts +1 -1
  14. package/dist/types/common/signals.d.ts +1 -1
  15. package/dist/types/common/styled-text.d.ts +1 -1
  16. package/dist/types/common/suggest.d.ts +1 -1
  17. package/dist/types/common/syntax-highlighter.d.ts +1 -1
  18. package/dist/types/common/terminal.d.ts +1 -1
  19. package/dist/types/common/type/parse.d.ts +1 -1
  20. package/dist/types/common/type/primitive.d.ts +1 -1
  21. package/dist/types/common/type/serialize.d.ts +1 -1
  22. package/dist/types/common/type/subtype.d.ts +1 -1
  23. package/dist/types/common/type/types.d.ts +1 -1
  24. package/dist/types/common/type/utils.d.ts +1 -1
  25. package/dist/types/common/utils.d.ts +1 -1
  26. package/dist/types/compute-engine/assume.d.ts +1 -1
  27. package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +9 -4
  28. package/dist/types/compute-engine/boxed-expression/apply.d.ts +1 -1
  29. package/dist/types/compute-engine/boxed-expression/arithmetic-add.d.ts +1 -1
  30. package/dist/types/compute-engine/boxed-expression/arithmetic-divide.d.ts +1 -1
  31. package/dist/types/compute-engine/boxed-expression/arithmetic-multiply.d.ts +1 -1
  32. package/dist/types/compute-engine/boxed-expression/arithmetic-power.d.ts +1 -1
  33. package/dist/types/compute-engine/boxed-expression/ascii-math.d.ts +1 -1
  34. package/dist/types/compute-engine/boxed-expression/box.d.ts +1 -1
  35. package/dist/types/compute-engine/boxed-expression/boxed-function-definition.d.ts +5 -5
  36. package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +2 -2
  37. package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +2 -2
  38. package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +1 -1
  39. package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +1 -1
  40. package/dist/types/compute-engine/boxed-expression/boxed-symbol-definition.d.ts +1 -1
  41. package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +2 -2
  42. package/dist/types/compute-engine/boxed-expression/boxed-tensor.d.ts +2 -2
  43. package/dist/types/compute-engine/boxed-expression/cache.d.ts +1 -1
  44. package/dist/types/compute-engine/boxed-expression/canonical.d.ts +1 -1
  45. package/dist/types/compute-engine/boxed-expression/compare.d.ts +3 -3
  46. package/dist/types/compute-engine/boxed-expression/expand.d.ts +1 -1
  47. package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +1 -1
  48. package/dist/types/compute-engine/boxed-expression/factor.d.ts +1 -1
  49. package/dist/types/compute-engine/boxed-expression/flatten.d.ts +1 -1
  50. package/dist/types/compute-engine/boxed-expression/hold.d.ts +1 -1
  51. package/dist/types/compute-engine/boxed-expression/match.d.ts +1 -1
  52. package/dist/types/compute-engine/boxed-expression/negate.d.ts +1 -1
  53. package/dist/types/compute-engine/boxed-expression/numerics.d.ts +1 -1
  54. package/dist/types/compute-engine/boxed-expression/order.d.ts +1 -1
  55. package/dist/types/compute-engine/boxed-expression/polynomials.d.ts +1 -1
  56. package/dist/types/compute-engine/boxed-expression/product.d.ts +1 -1
  57. package/dist/types/compute-engine/boxed-expression/public.d.ts +48 -13
  58. package/dist/types/compute-engine/boxed-expression/rules.d.ts +1 -1
  59. package/dist/types/compute-engine/boxed-expression/serialize.d.ts +1 -1
  60. package/dist/types/compute-engine/boxed-expression/sgn.d.ts +1 -1
  61. package/dist/types/compute-engine/boxed-expression/simplify.d.ts +1 -1
  62. package/dist/types/compute-engine/boxed-expression/solve.d.ts +1 -1
  63. package/dist/types/compute-engine/boxed-expression/tensor-fields.d.ts +1 -1
  64. package/dist/types/compute-engine/boxed-expression/terms.d.ts +1 -1
  65. package/dist/types/compute-engine/boxed-expression/trigonometry.d.ts +7 -1
  66. package/dist/types/compute-engine/boxed-expression/utils.d.ts +1 -1
  67. package/dist/types/compute-engine/boxed-expression/validate.d.ts +2 -2
  68. package/dist/types/compute-engine/collection-utils.d.ts +3 -1
  69. package/dist/types/compute-engine/compile.d.ts +9 -8
  70. package/dist/types/compute-engine/compute-engine.d.ts +5 -5
  71. package/dist/types/compute-engine/cost-function.d.ts +1 -1
  72. package/dist/types/compute-engine/debug.d.ts +3 -0
  73. package/dist/types/compute-engine/function-utils.d.ts +1 -1
  74. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +1 -1
  75. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +1 -1
  76. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +1 -1
  77. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-complex.d.ts +1 -1
  78. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +1 -1
  79. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-linear-algebra.d.ts +1 -1
  80. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +1 -1
  81. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +1 -1
  82. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-relational-operators.d.ts +1 -1
  83. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +1 -1
  84. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-statistics.d.ts +1 -1
  85. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +1 -1
  86. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +1 -1
  87. package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +1 -1
  88. package/dist/types/compute-engine/latex-syntax/parse-identifier.d.ts +1 -1
  89. package/dist/types/compute-engine/latex-syntax/parse.d.ts +1 -1
  90. package/dist/types/compute-engine/latex-syntax/public.d.ts +1 -1
  91. package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +1 -1
  92. package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +2 -1
  93. package/dist/types/compute-engine/latex-syntax/serializer.d.ts +3 -3
  94. package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +2 -2
  95. package/dist/types/compute-engine/library/arithmetic.d.ts +1 -1
  96. package/dist/types/compute-engine/library/calculus.d.ts +1 -1
  97. package/dist/types/compute-engine/library/collections.d.ts +1 -1
  98. package/dist/types/compute-engine/library/complex.d.ts +1 -1
  99. package/dist/types/compute-engine/library/control-structures.d.ts +1 -1
  100. package/dist/types/compute-engine/library/core.d.ts +1 -1
  101. package/dist/types/compute-engine/library/invisible-operator.d.ts +1 -1
  102. package/dist/types/compute-engine/library/library.d.ts +1 -1
  103. package/dist/types/compute-engine/library/linear-algebra.d.ts +1 -1
  104. package/dist/types/compute-engine/library/logic.d.ts +1 -1
  105. package/dist/types/compute-engine/library/polynomials.d.ts +1 -1
  106. package/dist/types/compute-engine/library/random-expression.d.ts +1 -1
  107. package/dist/types/compute-engine/library/relational-operator.d.ts +1 -1
  108. package/dist/types/compute-engine/library/sets.d.ts +1 -1
  109. package/dist/types/compute-engine/library/statistics.d.ts +1 -1
  110. package/dist/types/compute-engine/library/trigonometry.d.ts +1 -1
  111. package/dist/types/compute-engine/library/utils.d.ts +1 -1
  112. package/dist/types/compute-engine/numeric-value/big-numeric-value.d.ts +1 -1
  113. package/dist/types/compute-engine/numeric-value/exact-numeric-value.d.ts +1 -1
  114. package/dist/types/compute-engine/numeric-value/machine-numeric-value.d.ts +1 -1
  115. package/dist/types/compute-engine/numeric-value/public.d.ts +1 -1
  116. package/dist/types/compute-engine/numerics/bigint.d.ts +1 -1
  117. package/dist/types/compute-engine/numerics/bignum.d.ts +1 -1
  118. package/dist/types/compute-engine/numerics/expression.d.ts +1 -1
  119. package/dist/types/compute-engine/numerics/interval.d.ts +1 -1
  120. package/dist/types/compute-engine/numerics/monte-carlo.d.ts +1 -1
  121. package/dist/types/compute-engine/numerics/numeric-bigint.d.ts +9 -1
  122. package/dist/types/compute-engine/numerics/numeric-bignum.d.ts +1 -2
  123. package/dist/types/compute-engine/numerics/numeric-complex.d.ts +1 -1
  124. package/dist/types/compute-engine/numerics/numeric.d.ts +2 -3
  125. package/dist/types/compute-engine/numerics/primes.d.ts +1 -1
  126. package/dist/types/compute-engine/numerics/rationals.d.ts +1 -1
  127. package/dist/types/compute-engine/numerics/richardson.d.ts +1 -1
  128. package/dist/types/compute-engine/numerics/special-functions.d.ts +1 -1
  129. package/dist/types/compute-engine/numerics/statistics.d.ts +24 -0
  130. package/dist/types/compute-engine/numerics/strings.d.ts +1 -1
  131. package/dist/types/compute-engine/private.d.ts +29 -0
  132. package/dist/types/compute-engine/public.d.ts +1 -1
  133. package/dist/types/compute-engine/symbolic/derivative.d.ts +1 -1
  134. package/dist/types/compute-engine/symbolic/distribute.d.ts +1 -1
  135. package/dist/types/compute-engine/symbolic/simplify-rules.d.ts +1 -1
  136. package/dist/types/compute-engine/tensor/tensors.d.ts +2 -2
  137. package/dist/types/compute-engine.d.ts +2 -2
  138. package/dist/types/math-json/identifiers.d.ts +1 -1
  139. package/dist/types/math-json/types.d.ts +1 -1
  140. package/dist/types/math-json/utils.d.ts +1 -1
  141. package/dist/types/math-json.d.ts +2 -2
  142. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- /* 0.26.3 */
1
+ /* 0.27.0 */
2
2
  import type { Expression, MathJsonNumber, MathJsonString, MathJsonSymbol, MathJsonFunction, MathJsonIdentifier } from '../../math-json';
3
3
  import type { SerializeLatexOptions, LatexDictionaryEntry, ParseLatexOptions } from '../latex-syntax/public';
4
4
  import type { IndexedLatexDictionary } from '../latex-syntax/dictionary/definitions';
@@ -8,6 +8,7 @@ import { BigNum, IBigNum } from '../numerics/bignum';
8
8
  import { Type, TypeString } from '../../common/type/types';
9
9
  import { AbstractTensor } from '../tensor/tensors';
10
10
  import { OneOf } from '../../common/one-of';
11
+ import { CompiledType, JSSource } from '../compile';
11
12
  /**
12
13
  * :::info[THEORY OF OPERATIONS]
13
14
  *
@@ -972,7 +973,7 @@ export interface BoxedExpression {
972
973
  * The result is in canonical form.
973
974
  *
974
975
  */
975
- evaluate(options?: EvaluateOptions): BoxedExpression;
976
+ evaluate(options?: Partial<EvaluateOptions>): BoxedExpression;
976
977
  /** Return a numeric approximation of the canonical form of this expression.
977
978
  *
978
979
  * Any necessary calculations, including on decimal numbers (non-integers),
@@ -998,13 +999,18 @@ export interface BoxedExpression {
998
999
  *
999
1000
  * ```javascript
1000
1001
  * const expr = ce.parse('x^2 + y^2');
1001
- * const f = expr.compile('javascript');
1002
+ * const f = expr.compile();
1002
1003
  * console.log(f({x: 2, y: 3}));
1003
1004
  * ```
1004
1005
  */
1005
- compile(to?: 'javascript', options?: {
1006
- optimize: ('simplify' | 'evaluate')[];
1007
- }): ((args: Record<string, any>) => any | undefined) | undefined;
1006
+ compile(options?: {
1007
+ to?: 'javascript';
1008
+ optimize?: ('simplify' | 'evaluate')[];
1009
+ functions?: Record<MathJsonIdentifier, JSSource | ((...any: any[]) => any)>;
1010
+ vars?: Record<MathJsonIdentifier, CompiledType>;
1011
+ imports?: unknown[];
1012
+ preamble?: string;
1013
+ }): ((args?: Record<string, CompiledType>) => CompiledType | undefined) | undefined;
1008
1014
  /**
1009
1015
  * If this is an equation, solve the equation for the variables in vars.
1010
1016
  * Otherwise, solve the equation `this = 0` for the variables in vars.
@@ -1219,6 +1225,9 @@ export interface BoxedBaseDefinition {
1219
1225
  * This field is usually undefined, but its value is set by `getDefinition()`
1220
1226
  */
1221
1227
  scope: RuntimeScope | undefined;
1228
+ /** If this is the definition of a collection, the set of primitive operations
1229
+ * that can be performed on this collection (counting the number of elements,
1230
+ * enumerating it, etc...). */
1222
1231
  collection?: Partial<CollectionHandlers>;
1223
1232
  /** When the environment changes, for example the numerical precision,
1224
1233
  * call `reset()` so that any cached values can be recalculated.
@@ -1329,7 +1338,14 @@ export type CollectionHandlers = {
1329
1338
  */
1330
1339
  export type FunctionDefinitionFlags = {
1331
1340
  /**
1332
- * If `true`, the arguments of the functions are held unevaluated.
1341
+ * If `true`, the arguments to this function are not automatically
1342
+ * evaluated. The default is `false` (the arguments are evaluated).
1343
+ *
1344
+ * This can be useful for example for functions that take symbolic
1345
+ * expressions as arguments, such as `D` or `Integrate`.
1346
+ *
1347
+ * This is also useful for functions that take an argument that is
1348
+ * potentially an infinite collection.
1333
1349
  *
1334
1350
  * It will be up to the `evaluate()` handler to evaluate the arguments as
1335
1351
  * needed. This is conveninent to pass symbolic expressions as arguments
@@ -1338,7 +1354,7 @@ export type FunctionDefinitionFlags = {
1338
1354
  * This also applies to the `canonical()` handler.
1339
1355
  *
1340
1356
  */
1341
- hold: boolean;
1357
+ lazy: boolean;
1342
1358
  /** If `true`, the function is applied element by element to lists, matrices
1343
1359
  * (`["List"]` or `["Tuple"]` expressions) and equations (relational
1344
1360
  * operators).
@@ -1413,12 +1429,29 @@ export type Hold = 'none' | 'all' | 'first' | 'rest' | 'last' | 'most';
1413
1429
  */
1414
1430
  export type BoxedFunctionDefinition = BoxedBaseDefinition & FunctionDefinitionFlags & {
1415
1431
  complexity: number;
1416
- hold: boolean;
1432
+ /** If true, the signature was inferred from usage and may be modified
1433
+ * as more information becomes available.
1434
+ */
1417
1435
  inferredSignature: boolean;
1436
+ /** The type of the arguments and return value of this function */
1418
1437
  signature: Type;
1438
+ /** If present, this handler can be used to more precisely determine the
1439
+ * return type based on the type of the arguments. The arguments themselves
1440
+ * should *not* be evaluated, only their types should be used.
1441
+ */
1419
1442
  type?: (ops: ReadonlyArray<BoxedExpression>, options: {
1420
1443
  engine: IComputeEngine;
1421
1444
  }) => Type | TypeString | undefined;
1445
+ /** If present, this handler can be used to determine the sign of the
1446
+ * return value of the function, based on the sign and type of its
1447
+ * arguments.
1448
+ *
1449
+ * The arguments themselves should *not* be evaluated, only their types and
1450
+ * sign should be used.
1451
+ *
1452
+ * This can be used in some case for example to determine when certain
1453
+ * simplifications are valid.
1454
+ */
1422
1455
  sgn?: (ops: ReadonlyArray<BoxedExpression>, options: {
1423
1456
  engine: IComputeEngine;
1424
1457
  }) => Sign | undefined;
@@ -1427,8 +1460,8 @@ export type BoxedFunctionDefinition = BoxedBaseDefinition & FunctionDefinitionFl
1427
1460
  canonical?: (ops: ReadonlyArray<BoxedExpression>, options: {
1428
1461
  engine: IComputeEngine;
1429
1462
  }) => BoxedExpression | null;
1430
- evaluate?: (ops: ReadonlyArray<BoxedExpression>, options: EvaluateOptions & {
1431
- engine: IComputeEngine;
1463
+ evaluate?: (ops: ReadonlyArray<BoxedExpression>, options: Partial<EvaluateOptions> & {
1464
+ engine?: IComputeEngine;
1432
1465
  }) => BoxedExpression | undefined;
1433
1466
  evalDimension?: (ops: ReadonlyArray<BoxedExpression>, options: {
1434
1467
  engine: IComputeEngine;
@@ -1658,7 +1691,7 @@ export type SimplifyOptions = {
1658
1691
  * @category Boxed Expression
1659
1692
  */
1660
1693
  export type EvaluateOptions = {
1661
- numericApproximation?: boolean;
1694
+ numericApproximation: boolean;
1662
1695
  };
1663
1696
  /**
1664
1697
  * Metadata that can be associated with a `BoxedExpression`
@@ -2123,7 +2156,7 @@ export type FunctionDefinition = BaseDefinition & Partial<FunctionDefinitionFlag
2123
2156
  */
2124
2157
  type?: (ops: ReadonlyArray<BoxedExpression>, options: {
2125
2158
  engine: IComputeEngine;
2126
- }) => Type;
2159
+ }) => Type | TypeString | undefined;
2127
2160
  /** Return the sign of the function expression.
2128
2161
  *
2129
2162
  * If the sign cannot be determined, return `undefined`.
@@ -2239,6 +2272,8 @@ export type FunctionDefinition = BaseDefinition & Partial<FunctionDefinitionFlag
2239
2272
  }) => BoxedExpression;
2240
2273
  /** Return a compiled (optimized) expression. */
2241
2274
  compile?: (expr: BoxedExpression) => CompiledExpression;
2275
+ eq?: (a: BoxedExpression, b: BoxedExpression) => boolean | undefined;
2276
+ neq?: (a: BoxedExpression, b: BoxedExpression) => boolean | undefined;
2242
2277
  collection?: Partial<CollectionHandlers>;
2243
2278
  };
2244
2279
  /**
@@ -1,4 +1,4 @@
1
- /* 0.26.3 */
1
+ /* 0.27.0 */
2
2
  export declare const ConditionParent: {
3
3
  boolean: string;
4
4
  string: string;
@@ -1,3 +1,3 @@
1
- /* 0.26.3 */
1
+ /* 0.27.0 */
2
2
  import type { BoxedExpression, IComputeEngine, JsonSerializationOptions } from '../public';
3
3
  export declare function serializeJson(ce: IComputeEngine, expr: BoxedExpression, options: Readonly<JsonSerializationOptions>): Expression;
@@ -1,4 +1,4 @@
1
- /* 0.26.3 */
1
+ /* 0.27.0 */
2
2
  export declare function sgn(expr: BoxedExpression): Sign | undefined;
3
3
  export declare function positiveSign(s: Sign | undefined): boolean | undefined;
4
4
  export declare function nonNegativeSign(s: Sign | undefined): boolean | undefined;
@@ -1,4 +1,4 @@
1
- /* 0.26.3 */
1
+ /* 0.27.0 */
2
2
  type InternalSimplifyOptions = SimplifyOptions & {
3
3
  useVariations: boolean;
4
4
  };
@@ -1,4 +1,4 @@
1
- /* 0.26.3 */
1
+ /* 0.27.0 */
2
2
  import { Rule } from '../public';
3
3
  export declare const UNIVARIATE_ROOTS: Rule[];
4
4
  /**
@@ -1,4 +1,4 @@
1
- /* 0.26.3 */
1
+ /* 0.27.0 */
2
2
  import type { BoxedExpression, IComputeEngine } from '../public';
3
3
  export type DataTypeMap = {
4
4
  float64: number;
@@ -1,4 +1,4 @@
1
- /* 0.26.3 */
1
+ /* 0.27.0 */
2
2
  export declare class Terms {
3
3
  private engine;
4
4
  private terms;
@@ -1,4 +1,4 @@
1
- /* 0.26.3 */
1
+ /* 0.27.0 */
2
2
  export declare function Fu(exp: BoxedExpression): RuleStep | undefined;
3
3
  /** Assuming x in an expression in radians, convert to current angular unit. */
4
4
  export declare function radiansToAngle(x: BoxedExpression | undefined): BoxedExpression | undefined;
@@ -7,4 +7,10 @@ export declare function processInverseFunction(ce: IComputeEngine, xs: ReadonlyA
7
7
  export declare function trigSign(operator: string, x: BoxedExpression): Sign | undefined;
8
8
  export declare function isConstructible(x: string | BoxedExpression): boolean;
9
9
  export declare function constructibleValues(operator: string, x: BoxedExpression | undefined): undefined | BoxedExpression;
10
+ /**
11
+ * Return the angle in the range [0, 2π) that is equivalent to the given angle.
12
+ *
13
+ * @param x
14
+ * @returns
15
+ */
10
16
  export declare function canonicalAngle(x: BoxedExpression | undefined): BoxedExpression | undefined;
@@ -1,4 +1,4 @@
1
- /* 0.26.3 */
1
+ /* 0.27.0 */
2
2
  import { Type } from '../../common/type/types';
3
3
  export declare function isBoxedExpression(x: unknown): x is BoxedExpression;
4
4
  /**
@@ -1,4 +1,4 @@
1
- /* 0.26.3 */
1
+ /* 0.27.0 */
2
2
  import type { IComputeEngine } from '../public';
3
3
  import { Type } from '../../common/type/types';
4
4
  /**
@@ -46,4 +46,4 @@ export declare function checkPure(ce: IComputeEngine, arg: BoxedExpression | Box
46
46
  * arguments.
47
47
  *
48
48
  */
49
- export declare function validateArguments(ce: IComputeEngine, ops: ReadonlyArray<BoxedExpression>, def: BoxedFunctionDefinition): ReadonlyArray<BoxedExpression> | null;
49
+ export declare function validateArguments(ce: IComputeEngine, ops: ReadonlyArray<BoxedExpression>, signature: Type, lazy?: boolean, threadable?: boolean): ReadonlyArray<BoxedExpression> | null;
@@ -1,4 +1,4 @@
1
- /* 0.26.3 */
1
+ /* 0.27.0 */
2
2
  /** If a collection has fewer than this many elements, eagerly evaluate it.
3
3
  *
4
4
  * For example, evaluate the Union of two sets with 10 elements each will
@@ -58,6 +58,7 @@ export declare function length(col: BoxedExpression): number | undefined;
58
58
  *
59
59
  */
60
60
  export declare function iterator(expr: BoxedExpression): Iterator<BoxedExpression> | undefined;
61
+ export declare function repeat(value: BoxedExpression, count?: number): Iterator<BoxedExpression>;
61
62
  /**
62
63
  *
63
64
  * @param expr
@@ -66,3 +67,4 @@ export declare function iterator(expr: BoxedExpression): Iterator<BoxedExpressio
66
67
  */
67
68
  export declare function at(expr: BoxedExpression, index: number): BoxedExpression | undefined;
68
69
  export declare function defaultCollectionHandlers(def: undefined | Partial<CollectionHandlers>): Partial<CollectionHandlers> | undefined;
70
+ export declare function zip(items: ReadonlyArray<BoxedExpression>): Iterator<BoxedExpression[]>;
@@ -1,30 +1,31 @@
1
- /* 0.26.3 */
1
+ /* 0.27.0 */
2
2
  import type { BoxedExpression } from './public';
3
3
  export type CompiledType = boolean | number | string | object;
4
- type JSSource = string;
4
+ export type JSSource = string;
5
5
  export type CompiledOperators = Record<MathJsonIdentifier, [
6
6
  op: string,
7
7
  prec: number
8
8
  ]>;
9
+ export type CompiledFunction = string | ((args: ReadonlyArray<BoxedExpression>, compile: (expr: BoxedExpression) => JSSource, target: CompileTarget) => JSSource);
9
10
  export type CompiledFunctions = {
10
- [id: MathJsonIdentifier]: string | ((args: ReadonlyArray<BoxedExpression>, compile: (expr: BoxedExpression) => JSSource, target: CompileTarget) => JSSource);
11
+ [id: MathJsonIdentifier]: CompiledFunction;
11
12
  };
12
13
  export type CompileTarget = {
13
14
  operators?: (op: MathJsonIdentifier) => [op: string, prec: number];
14
- functions?: (id: MathJsonIdentifier) => string | ((...args: CompiledType[]) => string);
15
+ functions?: (id: MathJsonIdentifier) => CompiledFunction | undefined;
15
16
  var: (id: MathJsonIdentifier) => string | undefined;
16
17
  string: (str: string) => string;
17
18
  number: (n: number) => string;
18
19
  ws: (s?: string) => string;
20
+ preamble: string;
19
21
  indent: number;
20
22
  };
21
23
  /** This is an extension of the Function class that allows us to pass
22
24
  * a custom scope for "global" functions. */
23
25
  export declare class ComputeEngineFunction extends Function {
24
26
  private sys;
25
- constructor(body: string);
27
+ constructor(body: string, preamble?: string);
26
28
  }
27
- export declare function compileToTarget(expr: BoxedExpression, target: CompileTarget): ((_: Record<string, CompiledType>) => CompiledType) | undefined;
28
- export declare function compileToJavascript(expr: BoxedExpression): ((_: Record<string, CompiledType>) => CompiledType) | undefined;
29
+ export declare function compileToTarget(expr: BoxedExpression, target: CompileTarget): (_?: Record<string, CompiledType>) => CompiledType;
30
+ export declare function compileToJavascript(expr: BoxedExpression, functions?: Record<MathJsonIdentifier, JSSource | Function>, vars?: Record<MathJsonIdentifier, JSSource>, imports?: unknown[], preamble?: string): (_?: Record<string, CompiledType>) => CompiledType;
29
31
  export declare function compile(expr: BoxedExpression | undefined, target: CompileTarget, prec?: number): JSSource;
30
- export {};
@@ -1,4 +1,4 @@
1
- /* 0.26.3 */
1
+ /* 0.27.0 */
2
2
  import { Decimal } from 'decimal.js';
3
3
  import { Expression, MathJsonIdentifier, MathJsonNumber } from '../math-json/types';
4
4
  import type { LibraryCategory, LatexDictionaryEntry, LatexString, ParseLatexOptions } from './latex-syntax/public';
@@ -488,8 +488,8 @@ export declare class ComputeEngine implements IComputeEngine {
488
488
  *
489
489
  * @internal
490
490
  */
491
- _assign(id: string, value: BoxedExpression | ((ops: ReadonlyArray<BoxedExpression>, options: EvaluateOptions & {
492
- engine: IComputeEngine;
491
+ _assign(id: string, value: BoxedExpression | ((ops: ReadonlyArray<BoxedExpression>, options: Partial<EvaluateOptions> & {
492
+ engine?: IComputeEngine;
493
493
  }) => BoxedExpression | undefined)): void;
494
494
  /**
495
495
  * Return false if the execution should stop.
@@ -526,9 +526,9 @@ export declare class ComputeEngine implements IComputeEngine {
526
526
  error(message: string | string[], where?: string): BoxedExpression;
527
527
  typeError(expected: Type, actual: undefined | Type, where?: string): BoxedExpression;
528
528
  /**
529
- * Add a`["Hold"]` wrapper to `expr.
529
+ * Add a `["Hold"]` wrapper to `expr`.
530
530
  */
531
- hold(expr: BoxedExpression): BoxedExpression;
531
+ hold(expr: SemiBoxedExpression): BoxedExpression;
532
532
  /** Shortcut for `this.box(["Tuple", ...])`
533
533
  *
534
534
  * The result is canonical.
@@ -1,4 +1,4 @@
1
- /* 0.26.3 */
1
+ /* 0.27.0 */
2
2
  /**
3
3
  * The default cost function, used to determine if a new expression is simpler
4
4
  * than the old one.
@@ -0,0 +1,3 @@
1
+ /* 0.27.0 */
2
+ /** Return a string representing the stack trace from context */
3
+ export declare function trace(_context: RuntimeScope): string;
@@ -1,4 +1,4 @@
1
- /* 0.26.3 */
1
+ /* 0.27.0 */
2
2
  /***
3
3
  * ### THEORY OF OPERATIONS
4
4
  *
@@ -1,2 +1,2 @@
1
- /* 0.26.3 */
1
+ /* 0.27.0 */
2
2
  export declare const DEFINITIONS_ALGEBRA: LatexDictionary;
@@ -1,2 +1,2 @@
1
- /* 0.26.3 */
1
+ /* 0.27.0 */
2
2
  export declare const DEFINITIONS_ARITHMETIC: LatexDictionary;
@@ -1,2 +1,2 @@
1
- /* 0.26.3 */
1
+ /* 0.27.0 */
2
2
  export declare const DEFINITIONS_CALCULUS: LatexDictionary;
@@ -1,2 +1,2 @@
1
- /* 0.26.3 */
1
+ /* 0.27.0 */
2
2
  export declare const DEFINITIONS_COMPLEX: LatexDictionary;
@@ -1,4 +1,4 @@
1
- /* 0.26.3 */
1
+ /* 0.27.0 */
2
2
  export declare const DEFINITIONS_CORE: LatexDictionary;
3
3
  export declare const DELIMITERS_SHORTHAND: {
4
4
  '(': string;
@@ -1,2 +1,2 @@
1
- /* 0.26.3 */
1
+ /* 0.27.0 */
2
2
  export declare const DEFINITIONS_LINEAR_ALGEBRA: LatexDictionary;
@@ -1,2 +1,2 @@
1
- /* 0.26.3 */
1
+ /* 0.27.0 */
2
2
  export declare const DEFINITIONS_LOGIC: LatexDictionary;
@@ -1,2 +1,2 @@
1
- /* 0.26.3 */
1
+ /* 0.27.0 */
2
2
  export declare const DEFINITIONS_OTHERS: LatexDictionary;
@@ -1,2 +1,2 @@
1
- /* 0.26.3 */
1
+ /* 0.27.0 */
2
2
  export declare const DEFINITIONS_INEQUALITIES: LatexDictionaryEntry[];
@@ -1,2 +1,2 @@
1
- /* 0.26.3 */
1
+ /* 0.27.0 */
2
2
  export declare const DEFINITIONS_SETS: LatexDictionary;
@@ -1,2 +1,2 @@
1
- /* 0.26.3 */
1
+ /* 0.27.0 */
2
2
  export declare const DEFINITIONS_STATISTICS: LatexDictionary;
@@ -1,3 +1,3 @@
1
- /* 0.26.3 */
1
+ /* 0.27.0 */
2
2
  export declare const SYMBOLS: [string, string, number][];
3
3
  export declare const DEFINITIONS_SYMBOLS: LatexDictionary;
@@ -1,2 +1,2 @@
1
- /* 0.26.3 */
1
+ /* 0.27.0 */
2
2
  export declare const DEFINITIONS_TRIGONOMETRY: LatexDictionary;
@@ -1,4 +1,4 @@
1
- /* 0.26.3 */
1
+ /* 0.27.0 */
2
2
  import { Delimiter, EnvironmentParseHandler, ExpressionParseHandler, InfixParseHandler, LatexDictionary, LatexDictionaryEntry, LatexString, LatexToken, LibraryCategory, MatchfixParseHandler, PostfixParseHandler, Precedence, SerializeHandler } from '../public';
3
3
  export type CommonEntry = {
4
4
  /** Note: a name is required if a serialize handler is provided */
@@ -1,4 +1,4 @@
1
- /* 0.26.3 */
1
+ /* 0.27.0 */
2
2
  import { Parser } from './public';
3
3
  /** For error handling, if we have a identifier prefix, assume
4
4
  * the identifier is invalid (it would have been captured by
@@ -1,4 +1,4 @@
1
- /* 0.26.3 */
1
+ /* 0.27.0 */
2
2
  import { ParseLatexOptions, LatexToken, Terminator, Parser, SymbolTable, SymbolType } from './public';
3
3
  import type { IndexedLatexDictionary, IndexedLatexDictionaryEntry, IndexedInfixEntry, IndexedPostfixEntry, IndexedPrefixEntry, IndexedSymbolEntry, IndexedExpressionEntry, IndexedFunctionEntry } from './dictionary/definitions';
4
4
  /**
@@ -1,4 +1,4 @@
1
- /* 0.26.3 */
1
+ /* 0.27.0 */
2
2
  import type { IndexedLatexDictionary, IndexedLatexDictionaryEntry } from './dictionary/definitions';
3
3
  export type SymbolType = 'symbol' | 'function' | 'unknown';
4
4
  export type SymbolTable = {
@@ -1,4 +1,4 @@
1
- /* 0.26.3 */
1
+ /* 0.27.0 */
2
2
  import { NumberSerializationFormat } from './public';
3
3
  /**
4
4
  * @param expr - A number, can be represented as a string
@@ -1,4 +1,4 @@
1
- /* 0.26.3 */
1
+ /* 0.27.0 */
2
2
  import { DelimiterScale } from './public';
3
3
  export declare function getApplyFunctionStyle(_expr: Expression, _level: number): DelimiterScale;
4
4
  export declare function getGroupStyle(_expr: Expression, _level: number): DelimiterScale;
@@ -7,3 +7,4 @@ export declare function getFractionStyle(expr: Expression, level: number): 'quot
7
7
  export declare function getLogicStyle(_expr: Expression, _level: number): 'word' | 'boolean' | 'uppercase-word' | 'punctuation';
8
8
  export declare function getPowerStyle(_expr: Expression, _level: number): 'root' | 'solidus' | 'quotient';
9
9
  export declare function getNumericSetStyle(_expr: Expression, _level: number): 'compact' | 'regular' | 'interval' | 'set-builder';
10
+ export declare function latexTemplate(s: string, lhs: string, rhs: string): string;
@@ -1,8 +1,8 @@
1
- /* 0.26.3 */
1
+ /* 0.27.0 */
2
2
  import { LatexString, SerializeLatexOptions, DelimiterScale } from './public';
3
3
  import type { IndexedLatexDictionary, IndexedLatexDictionaryEntry } from './dictionary/definitions';
4
4
  export declare class Serializer {
5
- options: SerializeLatexOptions;
5
+ options: Readonly<SerializeLatexOptions>;
6
6
  readonly dictionary: IndexedLatexDictionary;
7
7
  level: number;
8
8
  constructor(dictionary: IndexedLatexDictionary, options: SerializeLatexOptions);
@@ -34,4 +34,4 @@ export declare class Serializer {
34
34
  numericSetStyle(expr: Expression, level: number): 'compact' | 'regular' | 'interval' | 'set-builder';
35
35
  }
36
36
  export declare function appendLatex(src: string, s: string): string;
37
- export declare function serializeLatex(expr: Expression | null, dict: IndexedLatexDictionary, options: SerializeLatexOptions): string;
37
+ export declare function serializeLatex(expr: Expression | null, dict: IndexedLatexDictionary, options: Readonly<SerializeLatexOptions>): string;
@@ -1,4 +1,4 @@
1
- /* 0.26.3 */
1
+ /* 0.27.0 */
2
2
  * ## Reference
3
3
  * TeX source code:
4
4
  * {@link http://tug.org/texlive/devsrc/Build/source/texk/web2c/tex.web | Tex.web}
@@ -14,5 +14,5 @@ export type Token = string;
14
14
  export declare function tokenize(s: string, args?: string[]): Token[];
15
15
  export declare function countTokens(s: string): number;
16
16
  export declare function joinLatex(segments: Iterable<string>): string;
17
- export declare function supsub(c: '_' | '^', x: string): string;
17
+ export declare function supsub(c: '_' | '^', body: string, x: string): string;
18
18
  export declare function tokensToString(tokens: Token | Token[] | [Token[] | Token][]): string;
@@ -1,4 +1,4 @@
1
- /* 0.26.3 */
1
+ /* 0.27.0 */
2
2
  import { BoxedExpression } from '../boxed-expression/public';
3
3
  export type CanonicalArithmeticOperators = 'Add' | 'Negate' | 'Multiply' | 'Divide' | 'Power' | 'Sqrt' | 'Root' | 'Ln';
4
4
  export declare const ARITHMETIC_LIBRARY: IdentifierDefinitions[];
@@ -1,2 +1,2 @@
1
- /* 0.26.3 */
1
+ /* 0.27.0 */
2
2
  export declare const CALCULUS_LIBRARY: IdentifierDefinitions[];
@@ -1,4 +1,4 @@
1
- /* 0.26.3 */
1
+ /* 0.27.0 */
2
2
  export declare const DEFAULT_LINSPACE_COUNT = 50;
3
3
  export declare const COLLECTIONS_LIBRARY: IdentifierDefinitions;
4
4
  /**
@@ -1,2 +1,2 @@
1
- /* 0.26.3 */
1
+ /* 0.27.0 */
2
2
  export declare const COMPLEX_LIBRARY: IdentifierDefinitions[];
@@ -1,2 +1,2 @@
1
- /* 0.26.3 */
1
+ /* 0.27.0 */
2
2
  export declare const CONTROL_STRUCTURES_LIBRARY: IdentifierDefinitions[];
@@ -1,2 +1,2 @@
1
- /* 0.26.3 */
1
+ /* 0.27.0 */
2
2
  export declare const CORE_LIBRARY: IdentifierDefinitions[];
@@ -1,4 +1,4 @@
1
- /* 0.26.3 */
1
+ /* 0.27.0 */
2
2
  export declare function canonicalInvisibleOperator(ops: ReadonlyArray<BoxedExpression>, { engine: ce }: {
3
3
  engine: IComputeEngine;
4
4
  }): BoxedExpression | null;
@@ -1,4 +1,4 @@
1
- /* 0.26.3 */
1
+ /* 0.27.0 */
2
2
  import { IComputeEngine, IdentifierDefinitions } from '../public';
3
3
  export declare function getStandardLibrary(categories: LibraryCategory[] | LibraryCategory | 'all'): readonly IdentifierDefinitions[];
4
4
  export declare const LIBRARIES: {
@@ -1,2 +1,2 @@
1
- /* 0.26.3 */
1
+ /* 0.27.0 */
2
2
  export declare const LINEAR_ALGEBRA_LIBRARY: IdentifierDefinitions[];
@@ -1,4 +1,4 @@
1
- /* 0.26.3 */
1
+ /* 0.27.0 */
2
2
  export declare const LOGIC_LIBRARY: IdentifierDefinitions;
3
3
  export declare function simplifyLogicFunction(x: BoxedExpression): {
4
4
  value: BoxedExpression;
@@ -1,2 +1,2 @@
1
- /* 0.26.3 */
1
+ /* 0.27.0 */
2
2
  export declare const POLYNOMIALS_LIBRARY: IdentifierDefinitions[];
@@ -1,2 +1,2 @@
1
- /* 0.26.3 */
1
+ /* 0.27.0 */
2
2
  export declare function randomExpression(level?: number): Expression;
@@ -1,2 +1,2 @@
1
- /* 0.26.3 */
1
+ /* 0.27.0 */
2
2
  export declare const RELOP_LIBRARY: IdentifierDefinitions;
@@ -1,2 +1,2 @@
1
- /* 0.26.3 */
1
+ /* 0.27.0 */
2
2
  export declare const SETS_LIBRARY: IdentifierDefinitions;
@@ -1,2 +1,2 @@
1
- /* 0.26.3 */
1
+ /* 0.27.0 */
2
2
  export declare const STATISTICS_LIBRARY: IdentifierDefinitions[];
@@ -1,2 +1,2 @@
1
- /* 0.26.3 */
1
+ /* 0.27.0 */
2
2
  export declare const TRIGONOMETRY_LIBRARY: IdentifierDefinitions[];
@@ -1,4 +1,4 @@
1
- /* 0.26.3 */
1
+ /* 0.27.0 */
2
2
  export type IndexingSet = {
3
3
  index: string | undefined;
4
4
  lower: number;
@@ -1,4 +1,4 @@
1
- /* 0.26.3 */
1
+ /* 0.27.0 */
2
2
  import { NumericValue, NumericValueData } from './public';
3
3
  import { ExactNumericValue } from './exact-numeric-value';
4
4
  import { Expression } from '../../math-json/types';
@@ -1,4 +1,4 @@
1
- /* 0.26.3 */
1
+ /* 0.27.0 */
2
2
  import { SmallInteger } from '../numerics/numeric';
3
3
  import { Rational } from '../numerics/rationals';
4
4
  import { ExactNumericValueData, NumericValue, NumericValueFactory } from './public';
@@ -1,4 +1,4 @@
1
- /* 0.26.3 */
1
+ /* 0.27.0 */
2
2
  import { NumericValue, NumericValueData } from './public';
3
3
  import type { Expression } from '../../math-json/types';
4
4
  import { SmallInteger } from '../numerics/numeric';