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