@cortex-js/compute-engine 0.31.0 → 0.32.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 (149) hide show
  1. package/package.json +1 -1
  2. package/dist/compute-engine.esm.js +0 -41311
  3. package/dist/compute-engine.min.esm.js +0 -125
  4. package/dist/compute-engine.min.umd.js +0 -127
  5. package/dist/compute-engine.umd.js +0 -41336
  6. package/dist/math-json.esm.js +0 -130
  7. package/dist/math-json.min.esm.js +0 -130
  8. package/dist/math-json.min.umd.js +0 -4
  9. package/dist/math-json.umd.js +0 -155
  10. package/dist/types/common/ansi-codes.d.ts +0 -41
  11. package/dist/types/common/configuration-change.d.ts +0 -28
  12. package/dist/types/common/fuzzy-string-match.d.ts +0 -2
  13. package/dist/types/common/grapheme-splitter.d.ts +0 -15
  14. package/dist/types/common/interruptible.d.ts +0 -20
  15. package/dist/types/common/one-of.d.ts +0 -10
  16. package/dist/types/common/signals.d.ts +0 -96
  17. package/dist/types/common/type/ast-nodes.d.ts +0 -146
  18. package/dist/types/common/type/boxed-type.d.ts +0 -30
  19. package/dist/types/common/type/lexer.d.ts +0 -51
  20. package/dist/types/common/type/parse.d.ts +0 -211
  21. package/dist/types/common/type/parser.d.ts +0 -45
  22. package/dist/types/common/type/primitive.d.ts +0 -10
  23. package/dist/types/common/type/serialize.d.ts +0 -2
  24. package/dist/types/common/type/subtype.d.ts +0 -6
  25. package/dist/types/common/type/type-builder.d.ts +0 -32
  26. package/dist/types/common/type/types.d.ts +0 -300
  27. package/dist/types/common/type/utils.d.ts +0 -36
  28. package/dist/types/common/utils.d.ts +0 -23
  29. package/dist/types/compute-engine/assume.d.ts +0 -26
  30. package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +0 -165
  31. package/dist/types/compute-engine/boxed-expression/apply.d.ts +0 -5
  32. package/dist/types/compute-engine/boxed-expression/arithmetic-add.d.ts +0 -16
  33. package/dist/types/compute-engine/boxed-expression/arithmetic-mul-div.d.ts +0 -27
  34. package/dist/types/compute-engine/boxed-expression/arithmetic-power.d.ts +0 -38
  35. package/dist/types/compute-engine/boxed-expression/ascii-math.d.ts +0 -11
  36. package/dist/types/compute-engine/boxed-expression/box.d.ts +0 -47
  37. package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +0 -44
  38. package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +0 -136
  39. package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +0 -103
  40. package/dist/types/compute-engine/boxed-expression/boxed-operator-definition.d.ts +0 -53
  41. package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +0 -107
  42. package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +0 -27
  43. package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +0 -170
  44. package/dist/types/compute-engine/boxed-expression/boxed-tensor.d.ts +0 -83
  45. package/dist/types/compute-engine/boxed-expression/boxed-value-definition.d.ts +0 -46
  46. package/dist/types/compute-engine/boxed-expression/cache.d.ts +0 -7
  47. package/dist/types/compute-engine/boxed-expression/canonical-utils.d.ts +0 -5
  48. package/dist/types/compute-engine/boxed-expression/canonical.d.ts +0 -2
  49. package/dist/types/compute-engine/boxed-expression/compare.d.ts +0 -13
  50. package/dist/types/compute-engine/boxed-expression/expand.d.ts +0 -20
  51. package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +0 -12
  52. package/dist/types/compute-engine/boxed-expression/factor.d.ts +0 -10
  53. package/dist/types/compute-engine/boxed-expression/flatten.d.ts +0 -25
  54. package/dist/types/compute-engine/boxed-expression/hold.d.ts +0 -10
  55. package/dist/types/compute-engine/boxed-expression/match.d.ts +0 -19
  56. package/dist/types/compute-engine/boxed-expression/negate.d.ts +0 -11
  57. package/dist/types/compute-engine/boxed-expression/numerics.d.ts +0 -34
  58. package/dist/types/compute-engine/boxed-expression/order.d.ts +0 -71
  59. package/dist/types/compute-engine/boxed-expression/polynomials.d.ts +0 -105
  60. package/dist/types/compute-engine/boxed-expression/product.d.ts +0 -66
  61. package/dist/types/compute-engine/boxed-expression/rules.d.ts +0 -129
  62. package/dist/types/compute-engine/boxed-expression/serialize.d.ts +0 -3
  63. package/dist/types/compute-engine/boxed-expression/sgn.d.ts +0 -46
  64. package/dist/types/compute-engine/boxed-expression/simplify.d.ts +0 -6
  65. package/dist/types/compute-engine/boxed-expression/solve.d.ts +0 -20
  66. package/dist/types/compute-engine/boxed-expression/terms.d.ts +0 -10
  67. package/dist/types/compute-engine/boxed-expression/trigonometry.d.ts +0 -9
  68. package/dist/types/compute-engine/boxed-expression/utils.d.ts +0 -64
  69. package/dist/types/compute-engine/boxed-expression/validate.d.ts +0 -58
  70. package/dist/types/compute-engine/collection-utils.d.ts +0 -35
  71. package/dist/types/compute-engine/compilation/base-compiler.d.ts +0 -31
  72. package/dist/types/compute-engine/compilation/javascript-target.d.ts +0 -68
  73. package/dist/types/compute-engine/compilation/types.d.ts +0 -83
  74. package/dist/types/compute-engine/cost-function.d.ts +0 -13
  75. package/dist/types/compute-engine/function-utils.d.ts +0 -120
  76. package/dist/types/compute-engine/global-types.d.ts +0 -2930
  77. package/dist/types/compute-engine/index.d.ts +0 -660
  78. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +0 -2
  79. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +0 -2
  80. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +0 -2
  81. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-complex.d.ts +0 -2
  82. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +0 -27
  83. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-linear-algebra.d.ts +0 -2
  84. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +0 -2
  85. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +0 -2
  86. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-relational-operators.d.ts +0 -2
  87. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +0 -2
  88. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-statistics.d.ts +0 -2
  89. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +0 -3
  90. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +0 -2
  91. package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +0 -88
  92. package/dist/types/compute-engine/latex-syntax/parse-symbol.d.ts +0 -21
  93. package/dist/types/compute-engine/latex-syntax/parse.d.ts +0 -303
  94. package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +0 -29
  95. package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +0 -10
  96. package/dist/types/compute-engine/latex-syntax/serializer.d.ts +0 -37
  97. package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +0 -18
  98. package/dist/types/compute-engine/latex-syntax/types.d.ts +0 -845
  99. package/dist/types/compute-engine/latex-syntax/utils.d.ts +0 -5
  100. package/dist/types/compute-engine/library/arithmetic.d.ts +0 -4
  101. package/dist/types/compute-engine/library/calculus.d.ts +0 -2
  102. package/dist/types/compute-engine/library/collections.d.ts +0 -27
  103. package/dist/types/compute-engine/library/combinatorics.d.ts +0 -2
  104. package/dist/types/compute-engine/library/complex.d.ts +0 -2
  105. package/dist/types/compute-engine/library/control-structures.d.ts +0 -2
  106. package/dist/types/compute-engine/library/core.d.ts +0 -2
  107. package/dist/types/compute-engine/library/invisible-operator.d.ts +0 -4
  108. package/dist/types/compute-engine/library/library.d.ts +0 -17
  109. package/dist/types/compute-engine/library/linear-algebra.d.ts +0 -2
  110. package/dist/types/compute-engine/library/logic.d.ts +0 -6
  111. package/dist/types/compute-engine/library/number-theory.d.ts +0 -2
  112. package/dist/types/compute-engine/library/polynomials.d.ts +0 -2
  113. package/dist/types/compute-engine/library/random-expression.d.ts +0 -2
  114. package/dist/types/compute-engine/library/relational-operator.d.ts +0 -2
  115. package/dist/types/compute-engine/library/sets.d.ts +0 -2
  116. package/dist/types/compute-engine/library/statistics.d.ts +0 -2
  117. package/dist/types/compute-engine/library/trigonometry.d.ts +0 -2
  118. package/dist/types/compute-engine/library/utils.d.ts +0 -77
  119. package/dist/types/compute-engine/numeric-value/big-numeric-value.d.ts +0 -57
  120. package/dist/types/compute-engine/numeric-value/exact-numeric-value.d.ts +0 -75
  121. package/dist/types/compute-engine/numeric-value/machine-numeric-value.d.ts +0 -56
  122. package/dist/types/compute-engine/numeric-value/types.d.ts +0 -116
  123. package/dist/types/compute-engine/numerics/bigint.d.ts +0 -2
  124. package/dist/types/compute-engine/numerics/expression.d.ts +0 -4
  125. package/dist/types/compute-engine/numerics/interval.d.ts +0 -12
  126. package/dist/types/compute-engine/numerics/monte-carlo.d.ts +0 -4
  127. package/dist/types/compute-engine/numerics/numeric-bigint.d.ts +0 -18
  128. package/dist/types/compute-engine/numerics/numeric-bignum.d.ts +0 -9
  129. package/dist/types/compute-engine/numerics/numeric-complex.d.ts +0 -3
  130. package/dist/types/compute-engine/numerics/numeric.d.ts +0 -60
  131. package/dist/types/compute-engine/numerics/primes.d.ts +0 -7
  132. package/dist/types/compute-engine/numerics/rationals.d.ts +0 -43
  133. package/dist/types/compute-engine/numerics/richardson.d.ts +0 -80
  134. package/dist/types/compute-engine/numerics/special-functions.d.ts +0 -28
  135. package/dist/types/compute-engine/numerics/statistics.d.ts +0 -24
  136. package/dist/types/compute-engine/numerics/strings.d.ts +0 -2
  137. package/dist/types/compute-engine/numerics/types.d.ts +0 -30
  138. package/dist/types/compute-engine/symbolic/antiderivative.d.ts +0 -3
  139. package/dist/types/compute-engine/symbolic/derivative.d.ts +0 -18
  140. package/dist/types/compute-engine/symbolic/distribute.d.ts +0 -5
  141. package/dist/types/compute-engine/symbolic/simplify-rules.d.ts +0 -27
  142. package/dist/types/compute-engine/tensor/tensor-fields.d.ts +0 -128
  143. package/dist/types/compute-engine/tensor/tensors.d.ts +0 -93
  144. package/dist/types/compute-engine/types.d.ts +0 -8
  145. package/dist/types/compute-engine.d.ts +0 -3
  146. package/dist/types/math-json/symbols.d.ts +0 -11
  147. package/dist/types/math-json/types.d.ts +0 -122
  148. package/dist/types/math-json/utils.d.ts +0 -87
  149. package/dist/types/math-json.d.ts +0 -3
@@ -1,660 +0,0 @@
1
- /* 0.31.0 */
2
- import { Decimal } from 'decimal.js';
3
- import { Type, TypeResolver, TypeString } from '../common/type/types';
4
- import { BoxedType } from '../common/type/boxed-type';
5
- import type { OneOf } from '../common/one-of';
6
- import { ConfigurationChangeListener } from '../common/configuration-change';
7
- import type { Expression, MathJsonSymbol, MathJsonNumberObject } from '../math-json/types';
8
- import type { ValueDefinition, OperatorDefinition, AngularUnit, AssignValue, AssumeResult, BoxedExpression, BoxedRule, BoxedRuleSet, BoxedSubstitution, CanonicalOptions, SymbolDefinitions, Metadata, Rule, Scope, EvalContext, SemiBoxedExpression, ComputeEngine as IComputeEngine, BoxedDefinition, SymbolDefinition } from './global-types';
9
- import type { LatexDictionaryEntry, LatexString, LibraryCategory, ParseLatexOptions } from './latex-syntax/types';
10
- import { type IndexedLatexDictionary } from './latex-syntax/dictionary/definitions';
11
- import type { BigNum, Rational } from './numerics/types';
12
- import { ExactNumericValueData, NumericValue, NumericValueData } from './numeric-value/types';
13
- import { validatePattern } from './boxed-expression/boxed-patterns';
14
- import './boxed-expression/serialize';
15
- export * from './global-types';
16
- export { validatePattern };
17
- /**
18
- *
19
- * To use the Compute Engine, create a `ComputeEngine` instance:
20
- *
21
- * ```js
22
- * ce = new ComputeEngine();
23
- * ```
24
- *
25
- * If using a mathfield, use the default Compute Engine instance from the
26
- * `MathfieldElement` class:
27
- *
28
- * ```js
29
- * ce = MathfieldElement.computeEngine
30
- * ```
31
- *
32
- * Use the instance to create boxed expressions with `ce.parse()` and `ce.box()`.
33
- *
34
- * ```js
35
- * const ce = new ComputeEngine();
36
- *
37
- * let expr = ce.parse("e^{i\\pi}");
38
- * console.log(expr.N().latex);
39
- * // ➔ "-1"
40
- *
41
- * expr = ce.box(["Expand", ["Power", ["Add", "a", "b"], 2]]);
42
- * console.log(expr.evaluate().latex);
43
- * // ➔ "a^2 + 2ab + b^2"
44
- * ```
45
- *
46
- * @category Compute Engine
47
- *
48
- */
49
- export declare class ComputeEngine implements IComputeEngine {
50
- readonly True: BoxedExpression;
51
- readonly False: BoxedExpression;
52
- readonly Pi: BoxedExpression;
53
- readonly E: BoxedExpression;
54
- readonly Nothing: BoxedExpression;
55
- readonly Zero: BoxedExpression;
56
- readonly One: BoxedExpression;
57
- readonly Half: BoxedExpression;
58
- readonly NegativeOne: BoxedExpression;
59
- readonly Two: BoxedExpression;
60
- readonly I: BoxedExpression;
61
- readonly NaN: BoxedExpression;
62
- readonly PositiveInfinity: BoxedExpression;
63
- readonly NegativeInfinity: BoxedExpression;
64
- readonly ComplexInfinity: BoxedExpression;
65
- /** The symbol separating the whole part of a number from its fractional
66
- * part in a LaTeX string.
67
- *
68
- * Commonly a period (`.`) in English, but a comma (`,`) in many European
69
- * languages. For the comma, use `"{,}"` so that the spacing is correct.
70
- *
71
- * Note that this is a LaTeX string and is used when parsing or serializing
72
- * LaTeX. MathJSON always uses a period.
73
- *
74
- * */
75
- decimalSeparator: LatexString;
76
- /** @internal */
77
- _BIGNUM_NAN: Decimal;
78
- /** @internal */
79
- _BIGNUM_ZERO: Decimal;
80
- /** @internal */
81
- _BIGNUM_ONE: Decimal;
82
- /** @internal */
83
- _BIGNUM_TWO: Decimal;
84
- /** @internal */
85
- _BIGNUM_HALF: Decimal;
86
- /** @internal */
87
- _BIGNUM_PI: Decimal;
88
- /** @internal */
89
- _BIGNUM_NEGATIVE_ONE: Decimal;
90
- /** @internal */
91
- private _precision;
92
- /** @ internal */
93
- private _angularUnit;
94
- /** @internal */
95
- private _tolerance;
96
- /** @internal */
97
- private _bignumTolerance;
98
- private _negBignumTolerance;
99
- /** @internal */
100
- private __cache;
101
- private _configurationChangeTracker;
102
- /** @internal */
103
- private _cost?;
104
- /** @internal */
105
- private _commonSymbols;
106
- /** @internal */
107
- private _commonNumbers;
108
- /**
109
- * The stack of evaluation contexts.
110
- *
111
- * An **evaluation context** contains bindings of symbols to their
112
- * values, assumptions, and the matching scope.
113
- *
114
- */
115
- _evalContextStack: EvalContext[];
116
- /** The current evaluation context */
117
- get context(): EvalContext;
118
- get contextStack(): ReadonlyArray<EvalContext>;
119
- set contextStack(stack: ReadonlyArray<EvalContext>);
120
- /** @internal */
121
- get _typeResolver(): TypeResolver;
122
- /**
123
- * Declare a new type in the current scope.
124
- *
125
- * By default, types are nominal. To declare a structural type, set
126
- * `alias` to `true`.
127
- */
128
- declareType(name: string, type: BoxedType | Type | TypeString, { alias }?: {
129
- alias?: boolean;
130
- }): void;
131
- /**
132
- * A list of the function calls to the current evaluation context,
133
- * most recent first.
134
- */
135
- get trace(): ReadonlyArray<string>;
136
- /**
137
- * The generation is incremented each time the context changes.
138
- * It is used to invalidate caches.
139
- * @internal
140
- */
141
- _generation: number;
142
- /** In strict mode (the default) the Compute Engine performs
143
- * validation of domains and signature and may report errors.
144
- *
145
- * These checks may impact performance
146
- *
147
- * When strict mode is off, results may be incorrect or generate JavaScript
148
- * errors if the input is not valid.
149
- *
150
- */
151
- strict: boolean;
152
- /** Absolute time beyond which evaluation should not proceed.
153
- * @internal
154
- */
155
- deadline?: number;
156
- /**
157
- * Return symbol tables suitable for the specified categories, or `"all"`
158
- * for all categories (`"arithmetic"`, `"algebra"`, etc...).
159
- *
160
- * A symbol table defines how to evaluate and manipulate symbols.
161
- *
162
- */
163
- /** @internal */
164
- private _latexDictionaryInput;
165
- /** @internal */
166
- __indexedLatexDictionary: IndexedLatexDictionary;
167
- /** @internal */
168
- _bignum: Decimal.Constructor;
169
- static getStandardLibrary(categories?: LibraryCategory[] | LibraryCategory | 'all'): readonly SymbolDefinitions[];
170
- /**
171
- * Return a LaTeX dictionary suitable for the specified category, or `"all"`
172
- * for all categories (`"arithmetic"`, `"algebra"`, etc...).
173
- *
174
- * A LaTeX dictionary is needed to translate between LaTeX and MathJSON.
175
- *
176
- * Each entry in the dictionary indicate how a LaTeX token (or string of
177
- * tokens) should be parsed into a MathJSON expression.
178
- *
179
- * For example an entry can define that the `\pi` LaTeX token should map to the
180
- * symbol `"Pi"`, or that the token `-` should map to the function
181
- * `["Negate",...]` when in a prefix position and to the function
182
- * `["Subtract", ...]` when in an infix position.
183
- *
184
- * Furthermore, the information in each dictionary entry is used to serialize
185
- * the LaTeX string corresponding to a MathJSON expression.
186
- *
187
- * Use with `ce.latexDictionary` to set the dictionary. You can complement
188
- * it with your own definitions, for example with:
189
- *
190
- * ```ts
191
- * ce.latexDictionary = [
192
- * ...ce.getLatexDictionary("all"),
193
- * {
194
- * kind: "function",
195
- * symbolTrigger: "concat",
196
- * parse: "Concatenate"
197
- * }
198
- * ];
199
- * ```
200
- */
201
- static getLatexDictionary(domain?: LibraryCategory | 'all'): readonly Readonly<LatexDictionaryEntry>[];
202
- /**
203
- * Construct a new `ComputeEngine` instance.
204
- *
205
- * Symbols tables define functions, constants and variables (in `options.ids`).
206
- * If no table is provided the MathJSON Standard Library is used (`ComputeEngine.getStandardLibrary()`)
207
- *
208
- * The LaTeX syntax dictionary is defined in `options.latexDictionary`.
209
- *
210
- * The order of the dictionaries matter: the definitions from the later ones
211
- * override the definitions from earlier ones. The first dictionary should
212
- * be the `'core'` dictionary which include basic definitions that are used
213
- * by later dictionaries.
214
- *
215
- *
216
- * @param options.precision Specific how many digits of precision
217
- * for the numeric calculations. Default is 300.
218
- *
219
- * @param options.tolerance If the absolute value of the difference of two
220
- * numbers is less than `tolerance`, they are considered equal. Used by
221
- * `chop()` as well.
222
- */
223
- constructor(options?: {
224
- ids?: readonly SymbolDefinitions[];
225
- precision?: number | 'machine';
226
- tolerance?: number | 'auto';
227
- });
228
- toJSON(): string;
229
- [Symbol.toStringTag]: string;
230
- get latexDictionary(): Readonly<LatexDictionaryEntry[]>;
231
- set latexDictionary(dic: Readonly<LatexDictionaryEntry[]>);
232
- get _indexedLatexDictionary(): IndexedLatexDictionary;
233
- /** After the configuration of the engine has changed, clear the caches
234
- * so that new values can be recalculated.
235
- *
236
- * This needs to happen for example when the numeric precision changes.
237
- *
238
- * @internal
239
- */
240
- _reset(): void;
241
- /** @internal */
242
- listenToConfigurationChange(tracker: ConfigurationChangeListener): () => void;
243
- get precision(): number;
244
- /** The precision, or number of significant digits, of numeric
245
- * calculations.
246
- *
247
- * To make calculations using more digits, at the cost of expanded memory
248
- * usage and slower computations, set the `precision` higher.
249
- *
250
- * Trigonometric operations are accurate for precision up to 1,000.
251
- *
252
- * If the precision is set to `machine`, floating point numbers
253
- * are represented internally as a 64-bit floating point number (as
254
- * per IEEE 754-2008), with a 52-bit mantissa, which gives about 15
255
- * digits of precision.
256
- *
257
- * If the precision is set to `auto`, the precision is set to a default value.
258
- *
259
- */
260
- set precision(p: number | 'machine' | 'auto');
261
- /**
262
- * The unit used for unitless angles in trigonometric functions.
263
- *
264
- * - `rad`: radian, $2\pi$ radians is a full circle
265
- * - `deg`: degree, 360 degrees is a full circle
266
- * - `grad`: gradians, 400 gradians is a full circle
267
- * - `turn`: turn, 1 turn is a full circle
268
- *
269
- * Default is `"rad"` (radians).
270
- */
271
- get angularUnit(): AngularUnit;
272
- set angularUnit(u: AngularUnit);
273
- /** Throw a `CancellationError` when the duration of an evaluation exceeds
274
- * the time limit.
275
- *
276
- * Time in milliseconds, default 2000 ms = 2 seconds.
277
- *
278
- */
279
- get timeLimit(): number;
280
- set timeLimit(t: number);
281
- private _timeLimit;
282
- /** The time after which the time limit has been exceeded */
283
- _deadline: number | undefined;
284
- get _timeRemaining(): number;
285
- /** Throw `CancellationError` `iteration-limit-exceeded` when the iteration limit
286
- * in a loop is exceeded. Default: no limits.
287
- *
288
- * @experimental
289
- */
290
- get iterationLimit(): number;
291
- set iterationLimit(t: number);
292
- private _iterationLimit;
293
- /** Signal `recursion-depth-exceeded` when the recursion depth for this
294
- * scope is exceeded.
295
- *
296
- * @experimental
297
- */
298
- get recursionLimit(): number;
299
- set recursionLimit(t: number);
300
- private _recursionLimit;
301
- get tolerance(): number;
302
- /**
303
- * Values smaller than the tolerance are considered to be zero for the
304
- * purpose of comparison, i.e. if `|b - a| <= tolerance`, `b` is considered
305
- * equal to `a`.
306
- */
307
- set tolerance(val: number | 'auto');
308
- /** Replace a number that is close to 0 with the exact integer 0.
309
- *
310
- * How close to 0 the number has to be to be considered 0 is determined by {@linkcode tolerance}.
311
- */
312
- chop(n: number): number;
313
- chop(n: Decimal): Decimal | 0;
314
- chop(n: Complex): Complex | 0;
315
- /** Create an arbitrary precision number.
316
- *
317
- * The return value is an object with methods to perform arithmetic
318
- * operations:
319
- * - `toNumber()`: convert to a JavaScript `number` with potential loss of precision
320
- * - `add()`
321
- * - `sub()`
322
- * - `neg()` (unary minus)
323
- * - `mul()`
324
- * - `div()`
325
- * - `pow()`
326
- * - `sqrt()` (square root)
327
- * - `cbrt()` (cube root)
328
- * - `exp()` (e^x)
329
- * - `log()`
330
- * - `ln()` (natural logarithm)
331
- * - `mod()`
332
-
333
- * - `abs()`
334
- * - `ceil()`
335
- * - `floor()`
336
- * - `round()`
337
-
338
- * - `equals()`
339
- * - `gt()`
340
- * - `gte()`
341
- * - `lt()`
342
- * - `lte()`
343
- *
344
- * - `cos()`
345
- * - `sin()`
346
- * - `tanh()`
347
- * - `acos()`
348
- * - `asin()`
349
- * - `atan()`
350
- * - `cosh()`
351
- * - `sinh()`
352
- * - `acosh()`
353
- * - `asinh()`
354
- * - `atanh()`
355
- *
356
- * - `isFinite()`
357
- * - `isInteger()`
358
- * - `isNaN()`
359
- * - `isNegative()`
360
- * - `isPositive()`
361
- * - `isZero()`
362
- * - `sign()` (1, 0 or -1)
363
- *
364
- */
365
- bignum(a: Decimal.Value | bigint): Decimal;
366
- /** Create a complex number.
367
- * The return value is an object with methods to perform arithmetic
368
- * operations:
369
- * - `re` (real part, as a JavaScript `number`)
370
- * - `im` (imaginary part, as a JavaScript `number`)
371
- * - `add()`
372
- * - `sub()`
373
- * - `neg()` (unary minus)
374
- * - `mul()`
375
- * - `div()`
376
- * - `pow()`
377
- * - `sqrt()` (square root)
378
- * - `exp()` (e^x)
379
- * - `log()`
380
- * - `ln()` (natural logarithm)
381
- * - `mod()`
382
-
383
- * - `abs()`
384
- * - `ceil()`
385
- * - `floor()`
386
- * - `round()`
387
-
388
- * - `arg()` the angle of the complex number
389
- * - `inverse()` the inverse of the complex number 1/z
390
- * - `conjugate()` the conjugate of the complex number
391
-
392
- * - `equals()`
393
- *
394
- * - `cos()`
395
- * - `sin()`
396
- * - `tanh()`
397
- * - `acos()`
398
- * - `asin()`
399
- * - `atan()`
400
- * - `cosh()`
401
- * - `sinh()`
402
- * - `acosh()`
403
- * - `asinh()`
404
- * - `atanh()`
405
- *
406
- * - `isFinite()`
407
- * - `isNaN()`
408
- * - `isZero()`
409
- * - `sign()` (1, 0 or -1)
410
- */
411
- complex(a: number | Decimal | Complex, b?: number | Decimal): Complex;
412
- /**
413
- *
414
- * Create a Numeric Value.
415
- *
416
- * @internal
417
- */
418
- _numericValue(value: number | bigint | Complex | OneOf<[BigNum | NumericValueData | ExactNumericValueData]>): NumericValue;
419
- /**
420
- * The cost function is used to determine the "cost" of an expression. For example, when simplifying an expression, the simplification that results in the lowest cost is chosen.
421
- */
422
- get costFunction(): (expr: BoxedExpression) => number;
423
- set costFunction(fn: ((expr: BoxedExpression) => number) | undefined);
424
- /**
425
- * Return definition matching the symbol, starting with the current
426
- * lexical scope and going up the scope chain.
427
- */
428
- lookupDefinition(id: MathJsonSymbol): undefined | BoxedDefinition;
429
- /**
430
- * Associate a new definition to a symbol in the current context.
431
- *
432
- * For internal use. Use `ce.declare()` instead.
433
- *
434
- * @internal
435
- */
436
- _declareSymbolValue(name: MathJsonSymbol, def: Partial<ValueDefinition>, scope?: Scope): BoxedDefinition;
437
- /**
438
- * Associate a new OperatorDefinition to a function in the current context.
439
- *
440
- * For internal use. Use `ce.declare()` instead.
441
- *
442
- * @internal
443
- */
444
- _declareSymbolOperator(name: string, def: OperatorDefinition, scope?: Scope): BoxedDefinition;
445
- /**
446
- *
447
- * Create a new lexical scope and matching evaluation context and add it
448
- * to the evaluation context stack.
449
- *
450
- */
451
- pushScope(scope?: Scope, name?: string): void;
452
- /**
453
- * Remove the most recent scope from the scope stack.
454
- */
455
- popScope(): void;
456
- /** @internal */
457
- _pushEvalContext(scope: Scope, name?: string): void;
458
- /** @internal */
459
- _popEvalContext(): void;
460
- /** @internal */
461
- _inScope<T>(scope: Scope | undefined, f: () => T): T;
462
- /** @internal */
463
- _printStack(options?: {
464
- details?: boolean;
465
- maxDepth?: number;
466
- }): void;
467
- /**
468
- * Use `ce.box(name)` instead
469
- * @internal */
470
- _getSymbolValue(id: MathJsonSymbol): BoxedExpression | undefined;
471
- /**
472
- * For internal use. Use `ce.assign(name, value)` instead.
473
- * @internal
474
- */
475
- _setSymbolValue(id: MathJsonSymbol, value: BoxedExpression | boolean | number | undefined): void;
476
- /**
477
- * Declare a symbol in the current lexical scope: specify their type and
478
- * other attributes, including optionally a value.
479
- *
480
- * Once the type of a symbol has been declared, it cannot be changed.
481
- * The type information is used to calculate the canonical form of
482
- * expressions and ensure they are valid. If the type could be changed
483
- * after the fact, previously valid expressions could become invalid.
484
- *
485
- * Set the type to `unknown` if the type is not known yet: it will be
486
- * inferred based on usage. Use `any` for a very generic type.
487
- *
488
- *
489
- */
490
- declare(id: string, def: Type | TypeString | Partial<SymbolDefinition>, scope?: Scope): IComputeEngine;
491
- declare(symbols: {
492
- [id: string]: Type | TypeString | Partial<SymbolDefinition>;
493
- }): IComputeEngine;
494
- /**
495
- * Return an evaluation context in which the symbol is defined.
496
- */
497
- lookupContext(id: MathJsonSymbol): EvalContext | undefined;
498
- /** Find the context in the stack frame, and set the stack frame to
499
- * it. This is used to evaluate expressions in the context of
500
- * a different scope.
501
- */
502
- _swapContext(context: EvalContext): void;
503
- /**
504
- * Assign a value to a symbol in the current scope.
505
- * Use `undefined` to reset the symbol to no value.
506
- *
507
- * The symbol should be a valid MathJSON symbol not a LaTeX string.
508
- *
509
- * If the symbol was not previously declared, it will be declared as a
510
- * symbol of a type inferred from its value.
511
- *
512
- * To more precisely define the type of the symbol, use `ce.declare()`
513
- * instead, which allows you to specify the type, value and other
514
- * attributes of the symbol.
515
- */
516
- assign(id: string, value: AssignValue): IComputeEngine;
517
- assign(ids: {
518
- [id: string]: AssignValue;
519
- }): IComputeEngine;
520
- /**
521
- * Return false if the execution should stop.
522
- *
523
- * This can occur if:
524
- * - an error has been signaled
525
- * - the time limit or memory limit has been exceeded
526
- *
527
- * @internal
528
- */
529
- _shouldContinueExecution(): boolean;
530
- /** @internal */
531
- _checkContinueExecution(): void;
532
- /** @internal */
533
- _cache<T>(cacheName: string, build: () => T, purge?: (t: T) => T | undefined): T;
534
- /** Return a boxed expression from a number, string or semiboxed expression.
535
- * Calls `ce.function()`, `ce.number()` or `ce.symbol()` as appropriate.
536
- */
537
- box(expr: NumericValue | SemiBoxedExpression, options?: {
538
- canonical?: CanonicalOptions;
539
- structural?: boolean;
540
- scope?: Scope | undefined;
541
- }): BoxedExpression;
542
- function(name: string, ops: ReadonlyArray<BoxedExpression> | ReadonlyArray<Expression>, options?: {
543
- metadata?: Metadata;
544
- canonical?: CanonicalOptions;
545
- structural?: boolean;
546
- scope?: Scope | undefined;
547
- }): BoxedExpression;
548
- /**
549
- *
550
- * Shortcut for `this.box(["Error",...])`.
551
- *
552
- * The result is canonical.
553
- */
554
- error(message: string | string[], where?: string): BoxedExpression;
555
- typeError(expected: Type, actual: undefined | Type | BoxedType, where?: string): BoxedExpression;
556
- /**
557
- * Add a `["Hold"]` wrapper to `expr`.
558
- */
559
- hold(expr: SemiBoxedExpression): BoxedExpression;
560
- /** Shortcut for `this.box(["Tuple", ...])`
561
- *
562
- * The result is canonical.
563
- */
564
- tuple(...elements: ReadonlyArray<number>): BoxedExpression;
565
- tuple(...elements: ReadonlyArray<BoxedExpression>): BoxedExpression;
566
- type(type: Type | TypeString | BoxedType): BoxedType;
567
- string(s: string, metadata?: Metadata): BoxedExpression;
568
- /** Create a boxed symbol */
569
- symbol(name: string, options?: {
570
- canonical?: CanonicalOptions;
571
- metadata?: Metadata;
572
- }): BoxedExpression;
573
- /**
574
- * This function tries to avoid creating a boxed number if `num` corresponds
575
- * to a common value for which we have a shared instance (-1, 0, NaN, etc...)
576
- */
577
- number(value: number | bigint | string | NumericValue | MathJsonNumberObject | Decimal | Complex | Rational, options?: {
578
- metadata: Metadata;
579
- canonical: CanonicalOptions;
580
- }): BoxedExpression;
581
- rules(rules: Rule | ReadonlyArray<Rule | BoxedRule> | BoxedRuleSet | undefined | null, options?: {
582
- canonical?: boolean;
583
- }): BoxedRuleSet;
584
- /**
585
- * Return a set of built-in rules.
586
- */
587
- getRuleSet(id?: string): BoxedRuleSet | undefined;
588
- /**
589
- * Return a function expression, but the caller is responsible for making
590
- * sure that the arguments are canonical.
591
- *
592
- * Unlike `ce.function()`, the operator of the result is the name argument.
593
- * Calling this function directly is potentially unsafe, as it bypasses
594
- * the canonicalization of the arguments.
595
- *
596
- * For example:
597
- *
598
- * - `ce._fn('Multiply', [1, 'x'])` returns `['Multiply', 1, 'x']` as a
599
- * canonical expression, even though it doesn't follow the canonical form
600
- * - `ce.function('Multiply', [1, 'x']` returns `'x'` which is the correct
601
- * canonical form
602
- *
603
- * @internal */
604
- _fn(name: MathJsonSymbol, ops: ReadonlyArray<BoxedExpression>, options?: {
605
- metadata?: Metadata;
606
- canonical?: boolean;
607
- scope?: Scope;
608
- }): BoxedExpression;
609
- /**
610
- * Parse a string of LaTeX and return a corresponding `BoxedExpression`.
611
- *
612
- * If the `canonical` option is set to `true`, the result will be canonical
613
- *
614
- */
615
- parse(latex: null, options?: Partial<ParseLatexOptions> & {
616
- canonical?: CanonicalOptions;
617
- }): null;
618
- parse(latex: LatexString, options?: Partial<ParseLatexOptions> & {
619
- canonical?: CanonicalOptions;
620
- }): BoxedExpression;
621
- /**
622
- * Return a list of all the assumptions that match a pattern.
623
- *
624
- * ```js
625
- * ce.assume(['Element', 'x', 'PositiveIntegers');
626
- * ce.ask(['Greater', 'x', '_val'])
627
- * // -> [{'val': 0}]
628
- * ```
629
- */
630
- ask(pattern: BoxedExpression): BoxedSubstitution[];
631
- /**
632
- * Answer a query based on the current assumptions.
633
- *
634
- */
635
- verify(_query: BoxedExpression): boolean;
636
- /**
637
- * Add an assumption.
638
- *
639
- * Note that the assumption is put into canonical form before being added.
640
- *
641
- * Returns:
642
- * - `contradiction` if the new assumption is incompatible with previous
643
- * ones.
644
- * - `tautology` if the new assumption is redundant with previous ones.
645
- * - `ok` if the assumption was successfully added to the assumption set.
646
- *
647
- *
648
- */
649
- assume(predicate: BoxedExpression): AssumeResult;
650
- /**
651
- * Remove all assumptions about one or more symbols.
652
- *
653
- * `ce.forget()` will remove all assumptions.
654
- *
655
- * Note that assumptions are scoped, so when exiting the current lexical
656
- * scope, the previous assumptions will be restored.
657
- *
658
- * */
659
- forget(symbol: undefined | MathJsonSymbol | MathJsonSymbol[]): void;
660
- }
@@ -1,2 +0,0 @@
1
- /* 0.31.0 */
2
- export declare const DEFINITIONS_ALGEBRA: LatexDictionary;
@@ -1,2 +0,0 @@
1
- /* 0.31.0 */
2
- export declare const DEFINITIONS_ARITHMETIC: LatexDictionary;
@@ -1,2 +0,0 @@
1
- /* 0.31.0 */
2
- export declare const DEFINITIONS_CALCULUS: LatexDictionary;
@@ -1,2 +0,0 @@
1
- /* 0.31.0 */
2
- export declare const DEFINITIONS_COMPLEX: LatexDictionary;
@@ -1,27 +0,0 @@
1
- /* 0.31.0 */
2
- export declare const DEFINITIONS_CORE: LatexDictionary;
3
- export declare const DELIMITERS_SHORTHAND: {
4
- '(': string;
5
- ')': string;
6
- '[': string;
7
- ']': string;
8
- '\u27E6': string;
9
- '\u27E7': string;
10
- '{': string;
11
- '}': string;
12
- '<': string;
13
- '>': string;
14
- '\u2016': string;
15
- '\\': string;
16
- '\u2308': string;
17
- '\u2309': string;
18
- '\u230A': string;
19
- '\u230B': string;
20
- '\u231C': string;
21
- '\u231D': string;
22
- '\u231E': string;
23
- '\u231F': string;
24
- '\u23B0': string;
25
- '\u23B1': string;
26
- };
27
- export declare function latexToDelimiterShorthand(s: string): string | undefined;