@cortex-js/compute-engine 0.26.4 → 0.28.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 (145) hide show
  1. package/dist/compute-engine.esm.js +9785 -8316
  2. package/dist/compute-engine.js +9785 -8316
  3. package/dist/compute-engine.min.esm.js +57 -50
  4. package/dist/compute-engine.min.js +57 -50
  5. package/dist/math-json.esm.js +287 -7
  6. package/dist/math-json.js +287 -7
  7. package/dist/math-json.min.esm.js +287 -7
  8. package/dist/math-json.min.js +4 -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/fuzzy-string-match.d.ts +2 -0
  12. package/dist/types/common/grapheme-splitter.d.ts +1 -1
  13. package/dist/types/common/interruptible.d.ts +20 -0
  14. package/dist/types/common/json5.d.ts +3 -0
  15. package/dist/types/common/one-of.d.ts +1 -1
  16. package/dist/types/common/signals.d.ts +1 -1
  17. package/dist/types/common/styled-text.d.ts +1 -1
  18. package/dist/types/common/syntax-highlighter.d.ts +1 -1
  19. package/dist/types/common/terminal.d.ts +1 -1
  20. package/dist/types/common/type/boxed-type.d.ts +13 -0
  21. package/dist/types/common/type/parse.d.ts +1 -1
  22. package/dist/types/common/type/primitive.d.ts +2 -1
  23. package/dist/types/common/type/serialize.d.ts +1 -1
  24. package/dist/types/common/type/subtype.d.ts +1 -1
  25. package/dist/types/common/type/types.d.ts +39 -49
  26. package/dist/types/common/type/utils.d.ts +3 -7
  27. package/dist/types/common/utils.d.ts +1 -1
  28. package/dist/types/compute-engine/assume.d.ts +1 -1
  29. package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +16 -9
  30. package/dist/types/compute-engine/boxed-expression/apply.d.ts +1 -1
  31. package/dist/types/compute-engine/boxed-expression/arithmetic-add.d.ts +3 -2
  32. package/dist/types/compute-engine/boxed-expression/arithmetic-divide.d.ts +1 -1
  33. package/dist/types/compute-engine/boxed-expression/arithmetic-multiply.d.ts +1 -1
  34. package/dist/types/compute-engine/boxed-expression/arithmetic-power.d.ts +1 -1
  35. package/dist/types/compute-engine/boxed-expression/ascii-math.d.ts +1 -1
  36. package/dist/types/compute-engine/boxed-expression/box.d.ts +1 -1
  37. package/dist/types/compute-engine/boxed-expression/boxed-function-definition.d.ts +13 -6
  38. package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +12 -8
  39. package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +4 -4
  40. package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +1 -1
  41. package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +3 -3
  42. package/dist/types/compute-engine/boxed-expression/boxed-symbol-definition.d.ts +5 -4
  43. package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +7 -6
  44. package/dist/types/compute-engine/boxed-expression/boxed-tensor.d.ts +4 -4
  45. package/dist/types/compute-engine/boxed-expression/cache.d.ts +2 -1
  46. package/dist/types/compute-engine/boxed-expression/canonical.d.ts +1 -1
  47. package/dist/types/compute-engine/boxed-expression/compare.d.ts +3 -3
  48. package/dist/types/compute-engine/boxed-expression/expand.d.ts +1 -1
  49. package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +1 -1
  50. package/dist/types/compute-engine/boxed-expression/factor.d.ts +1 -1
  51. package/dist/types/compute-engine/boxed-expression/flatten.d.ts +1 -1
  52. package/dist/types/compute-engine/boxed-expression/hold.d.ts +3 -2
  53. package/dist/types/compute-engine/boxed-expression/match.d.ts +1 -1
  54. package/dist/types/compute-engine/boxed-expression/negate.d.ts +1 -1
  55. package/dist/types/compute-engine/boxed-expression/numerics.d.ts +1 -1
  56. package/dist/types/compute-engine/boxed-expression/order.d.ts +1 -1
  57. package/dist/types/compute-engine/boxed-expression/polynomials.d.ts +1 -1
  58. package/dist/types/compute-engine/boxed-expression/product.d.ts +1 -1
  59. package/dist/types/compute-engine/boxed-expression/public.d.ts +109 -64
  60. package/dist/types/compute-engine/boxed-expression/rules.d.ts +1 -1
  61. package/dist/types/compute-engine/boxed-expression/serialize.d.ts +1 -1
  62. package/dist/types/compute-engine/boxed-expression/sgn.d.ts +1 -1
  63. package/dist/types/compute-engine/boxed-expression/simplify.d.ts +1 -1
  64. package/dist/types/compute-engine/boxed-expression/solve.d.ts +1 -1
  65. package/dist/types/compute-engine/boxed-expression/tensor-fields.d.ts +1 -1
  66. package/dist/types/compute-engine/boxed-expression/terms.d.ts +1 -1
  67. package/dist/types/compute-engine/boxed-expression/trigonometry.d.ts +7 -1
  68. package/dist/types/compute-engine/boxed-expression/utils.d.ts +1 -1
  69. package/dist/types/compute-engine/boxed-expression/validate.d.ts +3 -3
  70. package/dist/types/compute-engine/collection-utils.d.ts +3 -1
  71. package/dist/types/compute-engine/compile.d.ts +9 -8
  72. package/dist/types/compute-engine/compute-engine.d.ts +29 -16
  73. package/dist/types/compute-engine/cost-function.d.ts +1 -1
  74. package/dist/types/compute-engine/debug.d.ts +3 -0
  75. package/dist/types/compute-engine/function-utils.d.ts +1 -1
  76. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +1 -1
  77. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +1 -1
  78. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +1 -1
  79. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-complex.d.ts +1 -1
  80. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +1 -1
  81. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-linear-algebra.d.ts +1 -1
  82. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +1 -1
  83. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +1 -1
  84. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-relational-operators.d.ts +1 -1
  85. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +1 -1
  86. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-statistics.d.ts +1 -1
  87. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +1 -1
  88. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +1 -1
  89. package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +1 -1
  90. package/dist/types/compute-engine/latex-syntax/parse-identifier.d.ts +1 -1
  91. package/dist/types/compute-engine/latex-syntax/parse.d.ts +1 -1
  92. package/dist/types/compute-engine/latex-syntax/public.d.ts +11 -6
  93. package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +1 -1
  94. package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +2 -1
  95. package/dist/types/compute-engine/latex-syntax/serializer.d.ts +3 -3
  96. package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +2 -2
  97. package/dist/types/compute-engine/library/arithmetic.d.ts +1 -1
  98. package/dist/types/compute-engine/library/calculus.d.ts +1 -1
  99. package/dist/types/compute-engine/library/collections.d.ts +3 -2
  100. package/dist/types/compute-engine/library/complex.d.ts +1 -1
  101. package/dist/types/compute-engine/library/control-structures.d.ts +1 -1
  102. package/dist/types/compute-engine/library/core.d.ts +1 -1
  103. package/dist/types/compute-engine/library/invisible-operator.d.ts +1 -1
  104. package/dist/types/compute-engine/library/library.d.ts +1 -1
  105. package/dist/types/compute-engine/library/linear-algebra.d.ts +1 -1
  106. package/dist/types/compute-engine/library/logic.d.ts +1 -1
  107. package/dist/types/compute-engine/library/polynomials.d.ts +1 -1
  108. package/dist/types/compute-engine/library/random-expression.d.ts +1 -1
  109. package/dist/types/compute-engine/library/relational-operator.d.ts +1 -1
  110. package/dist/types/compute-engine/library/sets.d.ts +1 -1
  111. package/dist/types/compute-engine/library/statistics.d.ts +1 -1
  112. package/dist/types/compute-engine/library/trigonometry.d.ts +1 -1
  113. package/dist/types/compute-engine/library/utils.d.ts +3 -5
  114. package/dist/types/compute-engine/numeric-value/big-numeric-value.d.ts +1 -1
  115. package/dist/types/compute-engine/numeric-value/exact-numeric-value.d.ts +1 -1
  116. package/dist/types/compute-engine/numeric-value/machine-numeric-value.d.ts +1 -1
  117. package/dist/types/compute-engine/numeric-value/public.d.ts +1 -1
  118. package/dist/types/compute-engine/numerics/bigint.d.ts +1 -1
  119. package/dist/types/compute-engine/numerics/bignum.d.ts +1 -1
  120. package/dist/types/compute-engine/numerics/expression.d.ts +1 -1
  121. package/dist/types/compute-engine/numerics/interval.d.ts +1 -1
  122. package/dist/types/compute-engine/numerics/monte-carlo.d.ts +1 -1
  123. package/dist/types/compute-engine/numerics/numeric-bigint.d.ts +9 -1
  124. package/dist/types/compute-engine/numerics/numeric-bignum.d.ts +1 -2
  125. package/dist/types/compute-engine/numerics/numeric-complex.d.ts +1 -1
  126. package/dist/types/compute-engine/numerics/numeric.d.ts +2 -3
  127. package/dist/types/compute-engine/numerics/primes.d.ts +1 -1
  128. package/dist/types/compute-engine/numerics/rationals.d.ts +1 -1
  129. package/dist/types/compute-engine/numerics/richardson.d.ts +1 -1
  130. package/dist/types/compute-engine/numerics/special-functions.d.ts +1 -1
  131. package/dist/types/compute-engine/numerics/statistics.d.ts +24 -0
  132. package/dist/types/compute-engine/numerics/strings.d.ts +1 -1
  133. package/dist/types/compute-engine/private.d.ts +29 -0
  134. package/dist/types/compute-engine/public.d.ts +1 -1
  135. package/dist/types/compute-engine/symbolic/derivative.d.ts +1 -1
  136. package/dist/types/compute-engine/symbolic/distribute.d.ts +1 -1
  137. package/dist/types/compute-engine/symbolic/simplify-rules.d.ts +1 -1
  138. package/dist/types/compute-engine/tensor/tensors.d.ts +2 -2
  139. package/dist/types/compute-engine.d.ts +3 -2
  140. package/dist/types/math-json/identifiers.d.ts +1 -1
  141. package/dist/types/math-json/types.d.ts +6 -6
  142. package/dist/types/math-json/utils.d.ts +3 -3
  143. package/dist/types/math-json.d.ts +3 -3
  144. package/package.json +3 -3
  145. package/dist/types/common/suggest.d.ts +0 -1
@@ -1,4 +1,4 @@
1
- /* 0.26.4 */
1
+ /* 0.28.0 */
2
2
  * A primitive type is a simple type that represents a concrete value.
3
3
  *
4
4
  * - `any`: the top type
@@ -30,24 +30,26 @@
30
30
  * `tuple<number, boolean>`, `tuple<x: number, y: boolean>`.
31
31
  * - `map`: a set key-value pairs, e.g. `map<x: number, y: boolean>`.
32
32
  *
33
- * - `number`: any numeric value:
34
- * - `finite_number`: <finite_complex> or <finite_imaginary> or
35
- * <finite_real> or <finite_rational> or <finite_integer>
36
- * - `non_finite_number`: `NaN`, `PositiveInfinity`, `NegativeInfinity` or
37
- * `ComplexInfinity`
38
- * - `complex` and `finite_complex`: a complex number, with non-zero real
39
- * and imaginary parts.
40
- * - `imaginary` and `finite_imaginary`: a complex number with a real part
41
- * of 0 (pure imaginary).
42
- * - `real` and `finite_real`: a complex number with an imaginary part of 0.
43
- * - `rational` and `finite_rational`: a pure rational number
44
- * (not an integer)
45
- * - `integer` and `finite_integer`: a whole number
46
33
  *
47
34
  *
48
35
  */
49
36
  export type PrimitiveType = NumericType | 'collection' | 'list' | 'set' | 'map' | 'tuple' | 'value' | 'scalar' | 'function' | 'symbol' | 'boolean' | 'string' | 'expression' | 'unknown' | 'error' | 'nothing' | 'never' | 'any';
50
- export type NumericType = 'number' | 'finite_number' | 'complex' | 'finite_complex' | 'imaginary' | 'finite_imaginary' | 'real' | 'finite_real' | 'rational' | 'finite_rational' | 'integer' | 'finite_integer' | 'non_finite_number';
37
+ /**
38
+ * - `number`: any numeric value = `complex` + `real` plus `NaN`
39
+ * - `complex`: a number with non-zero real and imaginary parts = `finite_complex` plus `ComplexInfinity`
40
+ * - `finite_complex`: a finite complex number = `imaginary` + `finite_real`
41
+ * - `imaginary`: a complex number with a real part of 0 (pure imaginary)
42
+ * - `finite_number`: a finite numeric value = `finite_complex`
43
+ * - `finite_real`: a finite real number = `finite_rational` + `finite_integer`
44
+ * - `finite_rational`: a pure rational number
45
+ * - `finite_integer`: a whole number
46
+ * - `real`: a complex number with an imaginary part of 0 = `finite_real` + `non_finite_number`
47
+ * - `non_finite_number`: `PositiveInfinity`, `NegativeInfinity`
48
+ * - `integer`: a whole number = `finite_integer` + `non_finite_number`
49
+ * - `rational`: a pure rational number (not an integer) = `finite_rational` + `non_finite_number`
50
+ *
51
+ */
52
+ export type NumericType = 'number' | 'finite_number' | 'complex' | 'finite_complex' | 'imaginary' | 'real' | 'finite_real' | 'rational' | 'finite_rational' | 'integer' | 'finite_integer' | 'non_finite_number';
51
53
  export type NamedElement = {
52
54
  name?: string;
53
55
  type: Type;
@@ -71,7 +73,7 @@ export type ValueType = {
71
73
  kind: 'value';
72
74
  value: any;
73
75
  };
74
- /** Map is not a collection. It is a set of key/value pairs.
76
+ /** Map is a non-indexable collection of key/value pairs.
75
77
  * An element of a map whose type is a subtype of `nothing` is optional.
76
78
  * For example, in `{x: number, y: boolean | nothing}` the element `y` is optional.
77
79
  */
@@ -90,8 +92,8 @@ export type CollectionType = {
90
92
  /**
91
93
  * The elements of a list are ordered.
92
94
  *
93
- * All elements of a list have the same type (but it can be a broad type,
94
- * up to `any`).
95
+ * All elements of a list have the same type, but it can be a broad type,
96
+ * up to `any`.
95
97
  *
96
98
  * The same element can be present in the list more than once.
97
99
  *
@@ -130,7 +132,7 @@ export type Type = PrimitiveType | AlgebraicType | NegationType | CollectionType
130
132
  * Types are described using the following BNF grammar:
131
133
 
132
134
  ```bnf
133
- <type> ::= <union_type>
135
+ <type> ::= <union_type> | "(" <type> ")"
134
136
 
135
137
  <union_type> ::= <intersection_type> (" | " <intersection_type>)*
136
138
 
@@ -138,12 +140,8 @@ export type Type = PrimitiveType | AlgebraicType | NegationType | CollectionType
138
140
 
139
141
  <primary_type> ::= <primitive>
140
142
  | <tuple_type>
141
- | <function_type>
143
+ | <signature>
142
144
  | <list_type>
143
- | <wrapped_primary_type>
144
-
145
- <wrapped_primary_type> ::= "(" <primary_type> ")"
146
-
147
145
 
148
146
  <primitive> ::= "any" | "unknown" | <value-type> | <symbolic-type> | <numeric-type>
149
147
 
@@ -153,9 +151,9 @@ export type Type = PrimitiveType | AlgebraicType | NegationType | CollectionType
153
151
 
154
152
  <symbolic-type> ::= "expression" | "function" | "symbol"
155
153
 
156
- <tuple_type> ::= "(" (<name> <type> "," <named_tuple_elements>*) ")"
157
- | "(" (<type> "," <unnamed_tuple_elements>*) ")" |
158
- | "tuple(" <tuple_elements> ")"
154
+ <tuple_type> ::= "tuple<" (<name> <type> "," <named_tuple_elements>*) ">"
155
+ | "tuple<" (<type> "," <unnamed_tuple_elements>*) ">" |
156
+ | "tuple<" <tuple_elements> ">"
159
157
 
160
158
  <tuple_elements> ::= <unnamed_tuple_elements> | <named_tuple_elements>
161
159
 
@@ -163,15 +161,11 @@ export type Type = PrimitiveType | AlgebraicType | NegationType | CollectionType
163
161
 
164
162
  <named_tuple_elements> ::= <name> <type> ("," <name> <type>)*
165
163
 
166
- <function_type> ::= <arguments> " -> " <type>
164
+ <signature> ::= <arguments> " -> " <type>
167
165
 
168
166
  <arguments> ::= "()"
169
167
  | <argument>
170
168
  | "(" <argument-list> ")"
171
- | <deferred_evaluation>
172
-
173
- <deferred_evaluation> ::= "???" <argument>
174
- | "???" "(" <argument-list> ")"
175
169
 
176
170
  <argument> ::= <type>
177
171
  | <name> <type>
@@ -191,7 +185,7 @@ export type Type = PrimitiveType | AlgebraicType | NegationType | CollectionType
191
185
  | <rest_argument>
192
186
 
193
187
 
194
- <list_type> ::= "[" <type> <dimensions>? "]"
188
+ <list_type> ::= "list<" <type> <dimensions>? ">"
195
189
 
196
190
  <dimensions> ::= "^" <fixed_size>
197
191
  | "^(" <multi_dimensional_size> ")"
@@ -200,9 +194,7 @@ export type Type = PrimitiveType | AlgebraicType | NegationType | CollectionType
200
194
 
201
195
  <multi_dimensional_size> ::= <positive-integer_literal> "x" <positive-integer_literal> ("x" <positive-integer_literal>)*
202
196
 
203
- <map> ::= "{}"
204
- |"{" <map_elements> "}"
205
- | "map(" <map_elements> ")"
197
+ <map> ::= "map" | "map<" <map_elements> ">"
206
198
 
207
199
  <map_elements> ::= <name> <type> ("," <name> <type>)*
208
200
 
@@ -218,31 +210,29 @@ export type Type = PrimitiveType | AlgebraicType | NegationType | CollectionType
218
210
  ```
219
211
 
220
212
 
221
- Examples of types:
213
+ Examples of types strings:
222
214
  "number" -- a simple type primitive
223
-
224
-
225
215
  "(number, boolean)" -- a tuple type
226
216
  "(x: number, y:boolean)" -- a named tuple/record type. Either all arguments are named, or none are
227
217
 
228
- "[any]" -- an arbitrary collection type, with no length or element type restrictions
229
- "[integer]" -- a collection type where all the elements are integers
230
- "[(number, boolean)]" -- a collection of tuples
231
- "[(value:number, seen:boolean)]" -- a collection of named tuples
218
+ "collection<any>" -- an arbitrary collection type, with no length or element type restrictions
219
+ "collection<integer>" -- a collection type where all the elements are integers
220
+ "collection<(number, boolean)>" -- a collection of tuples
221
+ "collection<(value:number, seen:boolean)>" -- a collection of named tuples
232
222
  "[boolean]^32" -- a collection type with a fixed size of 32 elements
233
223
  "[integer]^(2x3)" -- an integer matrix of 2 columns and 3 rows
234
224
  "[integer]^(2x3x4)" -- a tensor of dimensions 2x3x4
235
225
 
236
- "number -> number" -- a function type with a single argument
237
- "(x: number, number) -> number" -- a function type with a named argument
238
- "(number, y:number?) -> number" -- a function type with an optional named argument (can have several optional arguments, at the end)
239
- "(number, ...number) -> number" -- a function type with a rest argument (can have only one, and no optional arguments if there is a rest argument).
240
- "() -> number" -- a function type with an empty argument list
226
+ "number -> number" -- a signature with a single argument
227
+ "(x: number, number) -> number" -- a signature with a named argument
228
+ "(number, y:number?) -> number" -- a signature with an optional named argument (can have several optional arguments, at the end)
229
+ "(number, ...number) -> number" -- a signature with a rest argument (can have only one, and no optional arguments if there is a rest argument).
230
+ "() -> number" -- a signature with an empty argument list
241
231
 
242
232
  "number | boolean" -- a union type
243
233
  "(x: number) & (y: number)" -- an intersection type
244
234
  "number | ((x: number) & (y: number))" -- a union type with an intersection type
245
- "(number -> number) | number" -- a union type with a function type
235
+ "(number -> number) | number" -- a union type with a signature and a primitive type
246
236
  */
247
237
  export type TypeString = string;
248
238
  export type TypeCompatibility = 'covariant' | 'contravariant' | 'bivariant' | 'invariant';
@@ -1,4 +1,4 @@
1
- /* 0.26.4 */
1
+ /* 0.28.0 */
2
2
  /** Convert two or more types into a more specific type that is a subtype of
3
3
  * all the input types. The resulting type is usually more constrained and
4
4
  * only encompasses values that belong to both input types.
@@ -27,13 +27,9 @@ export declare function narrow(...types: Readonly<Type>[]): Type;
27
27
  * widen('number', 'expression') => 'expression'
28
28
  * widen('number', 'string') => 'any'
29
29
  */
30
- export declare function widen(...types: Readonly<Type>[]): Type;
30
+ export declare function widen(...types: Readonly<Type>[]): Readonly<Type>;
31
31
  export declare function isSignatureType(type: Readonly<Type> | TypeString): type is FunctionSignature;
32
32
  export declare function functionSignature(type: Readonly<Type>): Type | undefined;
33
- export declare function functionResult(type: Readonly<Type>): Type | undefined;
33
+ export declare function functionResult(type: Readonly<Type> | undefined): Type | undefined;
34
34
  export declare function collectionElementType(type: Readonly<Type>): Type | undefined;
35
35
  export declare function isValidType(t: any): t is Readonly<Type>;
36
- /**
37
- * Add a `toString()` method to the type object
38
- */
39
- export declare function makeType(type: Type): Readonly<Type>;
@@ -1,2 +1,2 @@
1
- /* 0.26.4 */
1
+ /* 0.28.0 */
2
2
  export declare function hidePrivateProperties(obj: any): void;
@@ -1,4 +1,4 @@
1
- /* 0.26.4 */
1
+ /* 0.28.0 */
2
2
  /**
3
3
  * Add an assumption, in the form of a predicate, for example:
4
4
  *
@@ -1,9 +1,10 @@
1
- /* 0.26.4 */
1
+ /* 0.28.0 */
2
2
  import { Expression, MathJsonIdentifier } from '../../math-json/types';
3
3
  import type { BoxedBaseDefinition, BoxedExpression, BoxedFunctionDefinition, BoxedRuleSet, BoxedSubstitution, BoxedSymbolDefinition, CanonicalOptions, EvaluateOptions, IComputeEngine, JsonSerializationOptions, Metadata, PatternMatchOptions, Rule, RuntimeScope, Sign, SimplifyOptions, Substitution } from './public';
4
4
  import type { LatexString } from '../public';
5
5
  import type { NumericValue } from '../numeric-value/public';
6
6
  import type { SmallInteger } from '../numerics/numeric';
7
+ import { CompiledType } from '../compile';
7
8
  import type { SerializeLatexOptions } from '../latex-syntax/public';
8
9
  import { AsciiMathOptions } from './ascii-math';
9
10
  /**
@@ -116,7 +117,7 @@ export declare abstract class _BoxedExpression implements BoxedExpression {
116
117
  canonical: CanonicalOptions;
117
118
  recursive?: boolean;
118
119
  }): BoxedExpression;
119
- solve(_vars: Iterable<string> | string | BoxedExpression | Iterable<BoxedExpression>): null | ReadonlyArray<BoxedExpression>;
120
+ solve(_vars?: Iterable<string> | string | BoxedExpression | Iterable<BoxedExpression>): null | ReadonlyArray<BoxedExpression>;
120
121
  replace(_rules: BoxedRuleSet | Rule | Rule[]): null | BoxedExpression;
121
122
  has(_v: string | string[]): boolean;
122
123
  get isPositive(): boolean | undefined;
@@ -130,13 +131,13 @@ export declare abstract class _BoxedExpression implements BoxedExpression {
130
131
  get baseDefinition(): BoxedBaseDefinition | undefined;
131
132
  get symbolDefinition(): BoxedSymbolDefinition | undefined;
132
133
  get functionDefinition(): BoxedFunctionDefinition | undefined;
133
- infer(t: Type): boolean;
134
+ infer(_t: Type): boolean;
134
135
  bind(): void;
135
136
  reset(): void;
136
137
  get value(): number | boolean | string | object | undefined;
137
138
  set value(_value: BoxedExpression | number | boolean | string | number[] | undefined);
138
- get type(): Type;
139
- set type(_type: Type);
139
+ get type(): BoxedType;
140
+ set type(_type: Type | TypeString | BoxedType);
140
141
  get isNumber(): boolean | undefined;
141
142
  get isInteger(): boolean | undefined;
142
143
  get isRational(): boolean | undefined;
@@ -144,10 +145,15 @@ export declare abstract class _BoxedExpression implements BoxedExpression {
144
145
  simplify(_options?: Partial<SimplifyOptions>): BoxedExpression;
145
146
  expand(): BoxedExpression;
146
147
  evaluate(_options?: Partial<EvaluateOptions>): BoxedExpression;
148
+ evaluateAsync(_options?: Partial<EvaluateOptions>): Promise<BoxedExpression>;
147
149
  N(): BoxedExpression;
148
- compile(to?: string, options?: {
149
- optimize: ('simplify' | 'evaluate')[];
150
- }): ((args: Record<string, any>) => any | undefined) | undefined;
150
+ compile(options?: {
151
+ to?: 'javascript';
152
+ functions?: Record<MathJsonIdentifier, string | ((...any: any[]) => any)>;
153
+ vars?: Record<MathJsonIdentifier, string>;
154
+ imports?: Function[];
155
+ preamble?: string;
156
+ }): (args: Record<string, any>) => CompiledType;
151
157
  get isCollection(): boolean;
152
158
  contains(_rhs: BoxedExpression): boolean;
153
159
  subsetOf(_target: BoxedExpression, _strict: boolean): boolean;
@@ -158,5 +164,6 @@ export declare abstract class _BoxedExpression implements BoxedExpression {
158
164
  indexOf(_expr: BoxedExpression): number;
159
165
  }
160
166
  export declare function getSubexpressions(expr: BoxedExpression, name: MathJsonIdentifier): ReadonlyArray<BoxedExpression>;
161
- import { Type } from '../../common/type/types';
167
+ import type { Type, TypeString } from '../../common/type/types';
162
168
  import { AbstractTensor } from '../tensor/tensors';
169
+ import { BoxedType } from '../../common/type/boxed-type';
@@ -1,4 +1,4 @@
1
- /* 0.26.4 */
1
+ /* 0.28.0 */
2
2
  import { Decimal } from 'decimal.js';
3
3
  import type { BoxedExpression } from '../public';
4
4
  export declare function apply(expr: BoxedExpression, fn: (x: number) => number | Complex, bigFn?: (x: Decimal) => Decimal | Complex | number, complexFn?: (x: Complex) => number | Complex): BoxedExpression | undefined;
@@ -1,5 +1,6 @@
1
- /* 0.26.4 */
1
+ /* 0.28.0 */
2
2
  import { Type } from '../../common/type/types';
3
+ import { BoxedType } from '../../common/type/boxed-type';
3
4
  /**
4
5
  *
5
6
  * The canonical form of `Add`:
@@ -10,6 +11,6 @@ import { Type } from '../../common/type/types';
10
11
  *
11
12
  */
12
13
  export declare function canonicalAdd(ce: IComputeEngine, ops: ReadonlyArray<BoxedExpression>): BoxedExpression;
13
- export declare function addType(args: ReadonlyArray<BoxedExpression>): Type;
14
+ export declare function addType(args: ReadonlyArray<BoxedExpression>): Type | BoxedType;
14
15
  export declare function add(...xs: ReadonlyArray<BoxedExpression>): BoxedExpression;
15
16
  export declare function addN(...xs: ReadonlyArray<BoxedExpression>): BoxedExpression;
@@ -1,4 +1,4 @@
1
- /* 0.26.4 */
1
+ /* 0.28.0 */
2
2
  /**
3
3
  * Canonical form of 'Divide' (and 'Rational')
4
4
  * - remove denominator of 1
@@ -1,4 +1,4 @@
1
- /* 0.26.4 */
1
+ /* 0.28.0 */
2
2
  /**
3
3
  * The canonical form of `Multiply`:
4
4
  * - removes `1` anb `-1`
@@ -1,4 +1,4 @@
1
- /* 0.26.4 */
1
+ /* 0.28.0 */
2
2
  import type { Rational } from '../numerics/rationals';
3
3
  export declare function asRadical(expr: BoxedExpression): Rational | null;
4
4
  export declare function canonicalPower(a: BoxedExpression, b: BoxedExpression): BoxedExpression;
@@ -1,4 +1,4 @@
1
- /* 0.26.4 */
1
+ /* 0.28.0 */
2
2
  export type AsciiMathSerializer = (expr: BoxedExpression, precedence?: number) => string;
3
3
  export type AsciiMathOptions = {
4
4
  symbols: Record<string, string>;
@@ -1,4 +1,4 @@
1
- /* 0.26.4 */
1
+ /* 0.28.0 */
2
2
  import { Decimal } from 'decimal.js';
3
3
  import { IComputeEngine, SemiBoxedExpression, BoxedExpression, Metadata, CanonicalOptions } from './public';
4
4
  import { MathJsonIdentifier } from '../../math-json/types';
@@ -1,7 +1,8 @@
1
- /* 0.26.4 */
1
+ /* 0.28.0 */
2
2
  import type { BoxedExpression, CollectionHandlers, CompiledExpression, EvaluateOptions, Sign } from './public';
3
- import { Type } from '../../common/type/types';
3
+ import { Type, TypeString } from '../../common/type/types';
4
4
  import { OneOf } from '../../common/one-of';
5
+ import { BoxedType } from '../../common/type/boxed-type';
5
6
  export declare class _BoxedFunctionDefinition implements BoxedFunctionDefinition {
6
7
  engine: IComputeEngine;
7
8
  scope: RuntimeScope;
@@ -16,12 +17,12 @@ export declare class _BoxedFunctionDefinition implements BoxedFunctionDefinition
16
17
  involution: boolean;
17
18
  pure: boolean;
18
19
  complexity: number;
19
- hold: boolean;
20
- signature: Type;
20
+ lazy: boolean;
21
+ signature: BoxedType;
21
22
  inferredSignature: boolean;
22
23
  type?: (ops: ReadonlyArray<BoxedExpression>, options: {
23
24
  engine: IComputeEngine;
24
- }) => Type | undefined;
25
+ }) => BoxedType | Type | TypeString | undefined;
25
26
  sgn?: (ops: ReadonlyArray<BoxedExpression>, options: {
26
27
  engine: IComputeEngine;
27
28
  }) => Sign | undefined;
@@ -33,15 +34,21 @@ export declare class _BoxedFunctionDefinition implements BoxedFunctionDefinition
33
34
  canonical?: (ops: ReadonlyArray<BoxedExpression>, options: {
34
35
  engine: IComputeEngine;
35
36
  }) => BoxedExpression | null;
36
- evaluate?: (ops: ReadonlyArray<BoxedExpression>, options: EvaluateOptions & {
37
+ evaluate?: (ops: ReadonlyArray<BoxedExpression>, options: Partial<EvaluateOptions> & {
37
38
  engine: IComputeEngine;
38
39
  }) => BoxedExpression | undefined;
40
+ evaluateAsync?: (ops: ReadonlyArray<BoxedExpression>, options?: Partial<EvaluateOptions> & {
41
+ engine?: IComputeEngine;
42
+ }) => Promise<BoxedExpression | undefined>;
39
43
  evalDimension?: (ops: ReadonlyArray<BoxedExpression>, options: {
40
44
  engine: IComputeEngine;
41
45
  }) => BoxedExpression;
42
46
  compile?: (expr: BoxedExpression) => CompiledExpression;
43
47
  collection?: Partial<CollectionHandlers>;
44
48
  constructor(ce: IComputeEngine, name: string, def: FunctionDefinition);
49
+ infer(sig: Type): void;
50
+ update(def: FunctionDefinition): void;
45
51
  reset(): void;
46
52
  }
47
53
  export declare function makeFunctionDefinition(engine: IComputeEngine, name: string, def: OneOf<[FunctionDefinition | BoxedFunctionDefinition]>): BoxedFunctionDefinition;
54
+ export declare function isBoxedFunctionDefinition(x: any): x is BoxedFunctionDefinition;
@@ -1,15 +1,16 @@
1
- /* 0.26.4 */
1
+ /* 0.28.0 */
2
2
  import type { BoxedFunctionDefinition, IComputeEngine, BoxedRuleSet, SimplifyOptions, Substitution, ReplaceOptions, Metadata, PatternMatchOptions, RuntimeScope, BoxedSubstitution, EvaluateOptions, BoxedBaseDefinition, Rule, CanonicalOptions } from '../public';
3
3
  import type { BoxedExpression, Sign } from './public';
4
4
  import { NumericValue } from '../numeric-value/public';
5
5
  import { _BoxedExpression } from './abstract-boxed-expression';
6
6
  import { Type } from '../../common/type/types';
7
+ import { BoxedType } from '../../common/type/boxed-type';
7
8
  /**
8
- * A boxed function represent an expression that can be
9
- * represented by a function call.
9
+ * A boxed function represent an expression that can be represented by a
10
+ * function call.
10
11
  *
11
- * It is composed of an operator (the name of the function) and
12
- * a list of arguments.
12
+ * It is composed of an operator (the name of the function) and a list of
13
+ * arguments.
13
14
  *
14
15
  * It has a definition associated with it, based on the operator.
15
16
  * The definition contains the signature of the function, and the
@@ -98,11 +99,12 @@ export declare class BoxedFunction extends _BoxedExpression {
98
99
  get isReal(): boolean | undefined;
99
100
  get isFunctionExpression(): boolean;
100
101
  /** The type of the value of the function */
101
- get type(): Type;
102
+ get type(): BoxedType;
102
103
  simplify(options?: Partial<SimplifyOptions>): BoxedExpression;
103
- evaluate(options?: EvaluateOptions): BoxedExpression;
104
+ evaluate(options?: Partial<EvaluateOptions>): BoxedExpression;
105
+ evaluateAsync(options?: Partial<EvaluateOptions>): Promise<BoxedExpression>;
104
106
  N(): BoxedExpression;
105
- solve(vars: Iterable<string> | string | BoxedExpression | Iterable<BoxedExpression>): null | ReadonlyArray<BoxedExpression>;
107
+ solve(vars?: Iterable<string> | string | BoxedExpression | Iterable<BoxedExpression>): null | ReadonlyArray<BoxedExpression>;
106
108
  get isCollection(): boolean;
107
109
  contains(rhs: BoxedExpression): boolean;
108
110
  get size(): number;
@@ -111,4 +113,6 @@ export declare class BoxedFunction extends _BoxedExpression {
111
113
  get(index: BoxedExpression | string): BoxedExpression | undefined;
112
114
  indexOf(expr: BoxedExpression): number;
113
115
  subsetOf(rhs: BoxedExpression, strict: boolean): boolean;
116
+ _computeValue(options?: Partial<EvaluateOptions>): () => BoxedExpression;
117
+ _computeValueAsync(options?: Partial<EvaluateOptions>): () => Promise<BoxedExpression>;
114
118
  }
@@ -1,4 +1,4 @@
1
- /* 0.26.4 */
1
+ /* 0.28.0 */
2
2
  import { Decimal } from 'decimal.js';
3
3
  import type { BoxedExpression, IComputeEngine, Metadata, PatternMatchOptions, BoxedSubstitution, EvaluateOptions, BoxedRuleSet, ReplaceOptions, Rule, Substitution, CanonicalOptions, SimplifyOptions, Sign } from '../public';
4
4
  import type { Expression, MathJsonNumber } from '../../math-json';
@@ -6,7 +6,7 @@ import { SmallInteger } from '../numerics/numeric';
6
6
  import { Rational } from '../numerics/rationals';
7
7
  import { ExactNumericValueData, NumericValue, NumericValueData } from '../numeric-value/public';
8
8
  import { _BoxedExpression } from './abstract-boxed-expression';
9
- import { Type } from '../../common/type/types';
9
+ import { BoxedType } from '../../common/type/boxed-type';
10
10
  /**
11
11
  * BoxedNumber
12
12
  *
@@ -54,7 +54,7 @@ export declare class BoxedNumber extends _BoxedExpression {
54
54
  root(exp: number | BoxedExpression): BoxedExpression;
55
55
  sqrt(): BoxedExpression;
56
56
  ln(semiBase?: number | BoxedExpression): BoxedExpression;
57
- get type(): Type;
57
+ get type(): BoxedType;
58
58
  get sgn(): Sign | undefined;
59
59
  get numerator(): BoxedExpression;
60
60
  get denominator(): BoxedExpression;
@@ -87,7 +87,7 @@ export declare class BoxedNumber extends _BoxedExpression {
87
87
  get structural(): BoxedExpression;
88
88
  toNumericValue(): [NumericValue, BoxedExpression];
89
89
  simplify(options?: Partial<SimplifyOptions>): BoxedExpression;
90
- evaluate(options?: EvaluateOptions): BoxedExpression;
90
+ evaluate(options?: Partial<EvaluateOptions>): BoxedExpression;
91
91
  N(): BoxedExpression;
92
92
  }
93
93
  export declare function canonicalNumber(ce: IComputeEngine, value: number | bigint | string | Decimal | Complex | Rational | NumericValue | MathJsonNumber): number | NumericValue;
@@ -1,4 +1,4 @@
1
- /* 0.26.4 */
1
+ /* 0.28.0 */
2
2
  import type { BoxedExpression } from './public';
3
3
  export declare function isWildcard(expr: BoxedExpression): expr is BoxedSymbol;
4
4
  export declare function wildcardName(expr: BoxedExpression): string | null;
@@ -1,6 +1,6 @@
1
- /* 0.26.4 */
1
+ /* 0.28.0 */
2
2
  import { _BoxedExpression } from './abstract-boxed-expression';
3
- import { Type } from '../../common/type/types';
3
+ import { BoxedType } from '../../common/type/boxed-type';
4
4
  /**
5
5
  * BoxedString
6
6
  *
@@ -15,7 +15,7 @@ export declare class BoxedString extends _BoxedExpression {
15
15
  get isPure(): boolean;
16
16
  get isCanonical(): boolean;
17
17
  set isCanonical(_va: boolean);
18
- get type(): Type;
18
+ get type(): BoxedType;
19
19
  get complexity(): number;
20
20
  get string(): string;
21
21
  match(pattern: BoxedExpression, _options?: PatternMatchOptions): BoxedSubstitution | null;
@@ -1,5 +1,6 @@
1
- /* 0.26.4 */
2
- import { Type } from '../../common/type/types';
1
+ /* 0.28.0 */
2
+ import { Type, TypeString } from '../../common/type/types';
3
+ import { BoxedType } from '../../common/type/boxed-type';
3
4
  /**
4
5
  * ### THEORY OF OPERATIONS
5
6
  *
@@ -51,8 +52,8 @@ export declare class _BoxedSymbolDefinition implements BoxedSymbolDefinition {
51
52
  reset(): void;
52
53
  get value(): BoxedExpression | undefined;
53
54
  set value(val: SemiBoxedExpression | number | undefined);
54
- get type(): Type;
55
- set type(type: Type);
55
+ get type(): BoxedType;
56
+ set type(type: Type | TypeString | BoxedType);
56
57
  get sgn(): Sign | undefined;
57
58
  set sgn(val: Sign | undefined);
58
59
  get even(): boolean | undefined;
@@ -1,4 +1,4 @@
1
- /* 0.26.4 */
1
+ /* 0.28.0 */
2
2
  import type { Expression } from '../../math-json/types';
3
3
  import type { Type, TypeString } from '../../common/type/types';
4
4
  import type { BoxedExpression, BoxedRuleSet, BoxedSymbolDefinition, IComputeEngine, EvaluateOptions, ReplaceOptions, SimplifyOptions, Substitution, Metadata, PatternMatchOptions, RuntimeScope, BoxedFunctionDefinition, BoxedBaseDefinition, BoxedSubstitution, Rule, CanonicalOptions, BoxedRule, Sign } from './public';
@@ -6,6 +6,7 @@ import { NumericValue } from '../numeric-value/public';
6
6
  import { _BoxedExpression } from './abstract-boxed-expression';
7
7
  import { BigNum } from '../numerics/bignum';
8
8
  import type { OneOf } from '../../common/one-of';
9
+ import { BoxedType } from '../../common/type/boxed-type';
9
10
  /**
10
11
  * BoxedSymbol
11
12
  *
@@ -64,7 +65,7 @@ export declare class BoxedSymbol extends _BoxedExpression {
64
65
  root(n: number | BoxedExpression): BoxedExpression;
65
66
  sqrt(): BoxedExpression;
66
67
  ln(semiBase?: number | BoxedExpression): BoxedExpression;
67
- solve(vars: Iterable<string> | string | BoxedExpression | Iterable<BoxedExpression>): null | ReadonlyArray<BoxedExpression>;
68
+ solve(vars?: Iterable<string> | string | BoxedExpression | Iterable<BoxedExpression>): null | ReadonlyArray<BoxedExpression>;
68
69
  get complexity(): number;
69
70
  get operator(): string;
70
71
  get symbol(): string;
@@ -72,7 +73,7 @@ export declare class BoxedSymbol extends _BoxedExpression {
72
73
  get symbolDefinition(): BoxedSymbolDefinition | undefined;
73
74
  get functionDefinition(): BoxedFunctionDefinition | undefined;
74
75
  /**
75
- * Subsequence inferences will narrow the domain of the symbol.
76
+ * Subsequent inferences will narrow the domain of the symbol.
76
77
  * f: integer -> real, g: real -> real
77
78
  * g(x) => x: real
78
79
  * f(x) => x: integer narrowed from integer to real
@@ -90,8 +91,8 @@ export declare class BoxedSymbol extends _BoxedExpression {
90
91
  },
91
92
  BoxedExpression
92
93
  ]> | number | object | undefined);
93
- get type(): Type;
94
- set type(t: Type | TypeString);
94
+ get type(): BoxedType;
95
+ set type(t: Type | TypeString | BoxedType);
95
96
  get sgn(): Sign | undefined;
96
97
  has(x: string | string[]): boolean;
97
98
  match(pattern: BoxedExpression, options?: PatternMatchOptions): BoxedSubstitution | null;
@@ -113,7 +114,7 @@ export declare class BoxedSymbol extends _BoxedExpression {
113
114
  get bignumRe(): BigNum | undefined;
114
115
  get bignumIm(): BigNum | undefined;
115
116
  simplify(options?: Partial<SimplifyOptions>): BoxedExpression;
116
- evaluate(options?: EvaluateOptions): BoxedExpression;
117
+ evaluate(options?: Partial<EvaluateOptions>): BoxedExpression;
117
118
  N(): BoxedExpression;
118
119
  replace(rules: Rule | (Rule | BoxedRule)[] | BoxedRuleSet, options?: Partial<ReplaceOptions>): BoxedExpression | null;
119
120
  subs(sub: Substitution, options?: {
@@ -1,10 +1,10 @@
1
- /* 0.26.4 */
1
+ /* 0.28.0 */
2
2
  import type { BoxedExpression, IComputeEngine, EvaluateOptions, SimplifyOptions, Metadata, BoxedSubstitution, PatternMatchOptions, BoxedBaseDefinition, BoxedFunctionDefinition } from '../public';
3
3
  import { TensorDataType } from './tensor-fields';
4
4
  import { NumericValue } from '../numeric-value/public';
5
5
  import { _BoxedExpression } from './abstract-boxed-expression';
6
6
  import { AbstractTensor, TensorData } from '../tensor/tensors';
7
- import { Type } from '../../common/type/types';
7
+ import { BoxedType } from '../../common/type/boxed-type';
8
8
  /**
9
9
  * A boxed tensor represents an expression that can be represented by a tensor.
10
10
  * This could be a vector, matrix or multi-dimensional array.
@@ -66,7 +66,7 @@ export declare class BoxedTensor extends _BoxedExpression {
66
66
  sqrt(): BoxedExpression;
67
67
  get shape(): number[];
68
68
  get rank(): number;
69
- get type(): Type;
69
+ get type(): BoxedType;
70
70
  get json(): Expression;
71
71
  /** Mathematical equality */
72
72
  isEqual(rhs: number | BoxedExpression): boolean | undefined;
@@ -77,7 +77,7 @@ export declare class BoxedTensor extends _BoxedExpression {
77
77
  at(_index: number): BoxedExpression | undefined;
78
78
  indexOf(_expr: BoxedExpression): number;
79
79
  match(pattern: BoxedExpression, options?: PatternMatchOptions): BoxedSubstitution | null;
80
- evaluate(options?: EvaluateOptions): BoxedExpression;
80
+ evaluate(options?: Partial<EvaluateOptions>): BoxedExpression;
81
81
  simplify(options?: Partial<SimplifyOptions>): BoxedExpression;
82
82
  N(): BoxedExpression;
83
83
  }
@@ -1,6 +1,7 @@
1
- /* 0.26.4 */
1
+ /* 0.28.0 */
2
2
  value: T | null;
3
3
  generation: number | undefined;
4
4
  };
5
5
  /** The cache v will get updated if necessary */
6
6
  export declare function cachedValue<T>(v: CachedValue<T>, generation: number | undefined, fn: () => T): T;
7
+ export declare function cachedValueAsync<T>(v: CachedValue<T>, generation: number | undefined, fn: () => Promise<T>): Promise<T>;
@@ -1,2 +1,2 @@
1
- /* 0.26.4 */
1
+ /* 0.28.0 */
2
2
  export declare function canonicalForm(expr: BoxedExpression, forms: CanonicalOptions): BoxedExpression;
@@ -1,13 +1,13 @@
1
- /* 0.26.4 */
1
+ /* 0.28.0 */
2
2
  /**
3
3
  * Structural equality of boxed expressions.
4
4
  */
5
5
  export declare function same(a: BoxedExpression, b: BoxedExpression): boolean;
6
6
  /**
7
- * Mathematically equality of two boxed expressions.
7
+ * Mathematical equality of two boxed expressions.
8
8
  *
9
9
  * In general, it is impossible to always prove equality
10
10
  * ([Richardson's theorem](https://en.wikipedia.org/wiki/Richardson%27s_theorem)) but this works often...
11
11
  */
12
- export declare function eq(a: BoxedExpression, b: number | BoxedExpression): boolean | undefined;
12
+ export declare function eq(a: BoxedExpression, inputB: number | BoxedExpression): boolean | undefined;
13
13
  export declare function cmp(a: BoxedExpression, b: number | BoxedExpression): '<' | '=' | '>' | '>=' | '<=' | undefined;
@@ -1,4 +1,4 @@
1
- /* 0.26.4 */
1
+ /* 0.28.0 */
2
2
  export declare function expandProducts(ce: IComputeEngine, ops: ReadonlyArray<BoxedExpression>): BoxedExpression | null;
3
3
  export declare function choose(n: number, k: number): number;
4
4
  /** Attempt to transform the expression (h, ops) into a sum */