@cortex-js/compute-engine 0.24.0 → 0.25.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.
- package/dist/compute-engine.esm.js +25479 -24875
- package/dist/compute-engine.js +25480 -24876
- package/dist/compute-engine.min.esm.js +13 -13
- package/dist/compute-engine.min.js +13 -13
- package/dist/math-json.esm.js +6 -3
- package/dist/math-json.js +6 -3
- package/dist/math-json.min.esm.js +6 -3
- package/dist/math-json.min.js +2 -2
- package/dist/types/common/ansi-codes.d.ts +1 -1
- package/dist/types/common/grapheme-splitter.d.ts +1 -1
- package/dist/types/common/signals.d.ts +1 -1
- package/dist/types/common/utils.d.ts +1 -1
- package/dist/types/compute-engine/assume.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +30 -19
- package/dist/types/compute-engine/boxed-expression/box.d.ts +9 -9
- package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +4 -4
- package/dist/types/compute-engine/boxed-expression/boxed-domain.d.ts +3 -2
- package/dist/types/compute-engine/boxed-expression/boxed-function-definition.d.ts +2 -1
- package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +9 -10
- package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +5 -4
- package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +2 -15
- package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +3 -4
- package/dist/types/compute-engine/boxed-expression/boxed-symbol-definition.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +7 -8
- package/dist/types/compute-engine/boxed-expression/boxed-tensor.d.ts +6 -7
- package/dist/types/compute-engine/boxed-expression/canonical.d.ts +2 -2
- package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/factor.d.ts +11 -0
- package/dist/types/compute-engine/boxed-expression/match.d.ts +14 -0
- package/dist/types/compute-engine/boxed-expression/numerics.d.ts +41 -0
- package/dist/types/compute-engine/boxed-expression/order.d.ts +6 -6
- package/dist/types/compute-engine/boxed-expression/public.d.ts +1964 -0
- package/dist/types/compute-engine/boxed-expression/serialize.d.ts +3 -15
- package/dist/types/compute-engine/boxed-expression/utils.d.ts +5 -2
- package/dist/types/compute-engine/boxed-expression/validate.d.ts +7 -6
- package/dist/types/compute-engine/collection-utils.d.ts +1 -1
- package/dist/types/compute-engine/compile.d.ts +2 -2
- package/dist/types/compute-engine/compute-engine.d.ts +83 -60
- package/dist/types/compute-engine/cost-function.d.ts +1 -1
- package/dist/types/compute-engine/domain-utils.d.ts +3 -2
- package/dist/types/compute-engine/function-utils.d.ts +2 -2
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-complex.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-linear-algebra.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-relational-operators.d.ts +1 -3
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-statistics.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +5 -4
- package/dist/types/compute-engine/latex-syntax/parse-identifier.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/parse.d.ts +71 -29
- package/dist/types/compute-engine/latex-syntax/public.d.ts +264 -252
- package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +9 -3
- package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/serializer.d.ts +6 -11
- package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +3 -2
- package/dist/types/compute-engine/library/arithmetic-add.d.ts +5 -5
- package/dist/types/compute-engine/library/arithmetic-divide.d.ts +2 -1
- package/dist/types/compute-engine/library/arithmetic-multiply.d.ts +4 -4
- package/dist/types/compute-engine/library/arithmetic-power.d.ts +2 -1
- package/dist/types/compute-engine/library/arithmetic.d.ts +1 -1
- package/dist/types/compute-engine/library/calculus.d.ts +1 -1
- package/dist/types/compute-engine/library/collections.d.ts +1 -1
- package/dist/types/compute-engine/library/complex.d.ts +1 -1
- package/dist/types/compute-engine/library/control-structures.d.ts +1 -1
- package/dist/types/compute-engine/library/core.d.ts +3 -2
- package/dist/types/compute-engine/library/domains.d.ts +1 -1
- package/dist/types/compute-engine/library/library.d.ts +1 -1
- package/dist/types/compute-engine/library/linear-algebra.d.ts +1 -1
- package/dist/types/compute-engine/library/logic.d.ts +1 -1
- package/dist/types/compute-engine/library/polynomials.d.ts +1 -1
- package/dist/types/compute-engine/library/random-expression.d.ts +1 -1
- package/dist/types/compute-engine/library/relational-operator.d.ts +1 -2
- package/dist/types/compute-engine/library/sets.d.ts +1 -1
- package/dist/types/compute-engine/library/statistics.d.ts +1 -1
- package/dist/types/compute-engine/library/trigonometry.d.ts +1 -1
- package/dist/types/compute-engine/library/utils.d.ts +2 -2
- package/dist/types/compute-engine/numerics/numeric-bigint.d.ts +7 -1
- package/dist/types/compute-engine/numerics/numeric-bignum.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric-complex.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric.d.ts +7 -17
- package/dist/types/compute-engine/numerics/primes.d.ts +6 -1
- package/dist/types/compute-engine/numerics/rationals.d.ts +4 -13
- package/dist/types/compute-engine/numerics/richardson.d.ts +1 -1
- package/dist/types/compute-engine/numerics/terms.d.ts +7 -4
- package/dist/types/compute-engine/public.d.ts +3 -1839
- package/dist/types/compute-engine/rules.d.ts +1 -1
- package/dist/types/compute-engine/simplify-rules.d.ts +1 -1
- package/dist/types/compute-engine/solve.d.ts +4 -3
- package/dist/types/compute-engine/symbolic/derivative.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/expand.d.ts +2 -2
- package/dist/types/compute-engine/symbolic/flatten.d.ts +6 -4
- package/dist/types/compute-engine/symbolic/negate.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/polynomials.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/product.d.ts +4 -3
- package/dist/types/compute-engine/symbolic/tensor-fields.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/tensors.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/utils.d.ts +5 -10
- package/dist/types/compute-engine.d.ts +2 -2
- package/dist/types/math-json/math-json-format.d.ts +3 -3
- package/dist/types/math-json/utils.d.ts +4 -6
- package/dist/types/math-json.d.ts +2 -2
- package/package.json +1 -1
- package/dist/types/compute-engine/latex-syntax/latex-syntax.d.ts +0 -28
- package/dist/types/compute-engine/numerics/factor.d.ts +0 -27
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
/* 0.
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import { BoxedExpression, IComputeEngine, Metadata, Rational } from '../public';
|
|
5
|
-
/**
|
|
6
|
-
* The canonical version of `serializeJsonFunction()` applies
|
|
7
|
-
* additional transformations to "reverse" some of the effects
|
|
8
|
-
* of canonicalization (or boxing), for example it uses `Divide`
|
|
9
|
-
* instead of `Multiply`/`Power` when applicable.
|
|
10
|
-
*/
|
|
11
|
-
export declare function serializeJsonCanonicalFunction(ce: IComputeEngine, head: string | BoxedExpression, args: BoxedExpression[], metadata?: Metadata): Expression;
|
|
12
|
-
export declare function serializeJsonFunction(ce: IComputeEngine, head: string | BoxedExpression, args: (undefined | BoxedExpression)[], metadata?: Metadata): Expression;
|
|
13
|
-
export declare function serializeJsonString(ce: IComputeEngine, s: string): Expression;
|
|
14
|
-
export declare function serializeJsonSymbol(ce: IComputeEngine, sym: string, metadata?: Metadata): Expression;
|
|
15
|
-
export declare function serializeJsonNumber(ce: IComputeEngine, value: number | Decimal | Complex | Rational, metadata?: Metadata): Expression;
|
|
1
|
+
/* 0.25.0 */
|
|
2
|
+
import { BoxedExpression, IComputeEngine, JsonSerializationOptions } from '../public';
|
|
3
|
+
export declare function serializeJson(ce: IComputeEngine, expr: BoxedExpression, options: Readonly<JsonSerializationOptions>): Expression;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.25.0 */
|
|
2
2
|
import { Expression } from '../../math-json/math-json-format';
|
|
3
|
-
import { BoxedExpression, IComputeEngine } from '
|
|
3
|
+
import { BoxedExpression, IComputeEngine } from './public';
|
|
4
4
|
export declare function isBoxedExpression(x: unknown): x is BoxedExpression;
|
|
5
5
|
/**
|
|
6
6
|
* For any numeric result, if `bignumPreferred()` is true, calculate using
|
|
@@ -23,6 +23,7 @@ export declare function hashCode(s: string): number;
|
|
|
23
23
|
*/
|
|
24
24
|
export declare function bignumValue(ce: IComputeEngine, expr: Expression | null | undefined): Decimal | null;
|
|
25
25
|
export declare function asBigint(expr: BoxedExpression): bigint | null;
|
|
26
|
+
export declare function normalizedUnknownsForSolve(syms: string | Iterable<string> | BoxedExpression | Iterable<BoxedExpression> | null | undefined): string[];
|
|
26
27
|
/** Return the local variables in the expression.
|
|
27
28
|
*
|
|
28
29
|
* A local variable is an identifier that is declared with a `Declare`
|
|
@@ -34,3 +35,5 @@ export declare function asBigint(expr: BoxedExpression): bigint | null;
|
|
|
34
35
|
* hoisted.
|
|
35
36
|
*
|
|
36
37
|
*/
|
|
38
|
+
export declare function isRelationalOperator(name: BoxedExpression | string): boolean;
|
|
39
|
+
export declare function isInequality(expr: BoxedExpression): boolean;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.25.0 */
|
|
2
|
+
import { BoxedExpression } from './public';
|
|
2
3
|
/**
|
|
3
4
|
* Check that the number of arguments is as expected.
|
|
4
5
|
*
|
|
5
6
|
* Converts the arguments to canonical, and flattens the sequence.
|
|
6
7
|
*/
|
|
7
|
-
export declare function checkArity(ce: IComputeEngine, ops: BoxedExpression
|
|
8
|
+
export declare function checkArity(ce: IComputeEngine, ops: ReadonlyArray<BoxedExpression>, count: number): ReadonlyArray<BoxedExpression>;
|
|
8
9
|
/**
|
|
9
10
|
* Validation of arguments is normally done by checking the signature of the
|
|
10
11
|
* function vs the arguments of the expression. However, we have a fastpath
|
|
@@ -19,10 +20,10 @@ export declare function checkArity(ce: IComputeEngine, ops: BoxedExpression[], c
|
|
|
19
20
|
*
|
|
20
21
|
* Converts the arguments to canonical, and flattens the sequence.
|
|
21
22
|
*/
|
|
22
|
-
export declare function checkNumericArgs(ce: IComputeEngine, ops: BoxedExpression
|
|
23
|
+
export declare function checkNumericArgs(ce: IComputeEngine, ops: ReadonlyArray<BoxedExpression>, options?: number | {
|
|
23
24
|
count?: number;
|
|
24
25
|
flatten?: boolean | string;
|
|
25
|
-
}): BoxedExpression
|
|
26
|
+
}): ReadonlyArray<BoxedExpression>;
|
|
26
27
|
/**
|
|
27
28
|
* Check that an argument is of the expected domain.
|
|
28
29
|
*
|
|
@@ -33,7 +34,7 @@ export declare function checkDomain(ce: IComputeEngine, arg: BoxedExpression | u
|
|
|
33
34
|
* Check that the argument is pure.
|
|
34
35
|
*/
|
|
35
36
|
export declare function checkPure(ce: IComputeEngine, arg: BoxedExpression | BoxedExpression | undefined | null): BoxedExpression;
|
|
36
|
-
export declare function checkDomains(ce: IComputeEngine, args: BoxedExpression
|
|
37
|
+
export declare function checkDomains(ce: IComputeEngine, args: ReadonlyArray<BoxedExpression>, doms: (BoxedDomain | DomainLiteral)[]): ReadonlyArray<BoxedExpression>;
|
|
37
38
|
/**
|
|
38
39
|
*
|
|
39
40
|
* If the arguments match the parameters, return null.
|
|
@@ -42,4 +43,4 @@ export declare function checkDomains(ce: IComputeEngine, args: BoxedExpression[]
|
|
|
42
43
|
* arguments.
|
|
43
44
|
*
|
|
44
45
|
*/
|
|
45
|
-
export declare function adjustArguments(ce: IComputeEngine, ops: BoxedExpression
|
|
46
|
+
export declare function adjustArguments(ce: IComputeEngine, ops: ReadonlyArray<BoxedExpression>, hold: Hold, threadable: boolean, params: BoxedDomain[], optParams: BoxedDomain[], restParam: BoxedDomain | undefined): ReadonlyArray<BoxedExpression> | null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.25.0 */
|
|
2
2
|
import { BoxedExpression } from './public';
|
|
3
3
|
export type CompiledType = boolean | number | string | object;
|
|
4
4
|
type JSSource = string;
|
|
@@ -7,7 +7,7 @@ export type CompiledOperators = Record<MathJsonIdentifier, [
|
|
|
7
7
|
prec: number
|
|
8
8
|
]>;
|
|
9
9
|
export type CompiledFunctions = {
|
|
10
|
-
[id: MathJsonIdentifier]: string | ((args: BoxedExpression
|
|
10
|
+
[id: MathJsonIdentifier]: string | ((args: ReadonlyArray<BoxedExpression>, compile: (expr: BoxedExpression) => JSSource, target: CompileTarget) => JSSource);
|
|
11
11
|
};
|
|
12
12
|
export type CompileTarget = {
|
|
13
13
|
operators?: (op: MathJsonIdentifier) => [op: string, prec: number];
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.25.0 */
|
|
2
2
|
import { Decimal } from 'decimal.js';
|
|
3
|
-
import {
|
|
4
|
-
import type { LibraryCategory, LatexDictionaryEntry, LatexString,
|
|
5
|
-
import { AssumeResult,
|
|
3
|
+
import { MathJsonIdentifier, MathJsonNumber } from '../math-json/math-json-format';
|
|
4
|
+
import type { LibraryCategory, LatexDictionaryEntry, LatexString, ParseLatexOptions } from './latex-syntax/public';
|
|
5
|
+
import { AssumeResult, BoxedFunctionDefinition, BoxedSymbolDefinition, IComputeEngine, IdentifierDefinitions, ExpressionMapInterface, NumericMode, RuntimeScope, Scope, SymbolDefinition, BoxedRuleSet, Rule, ComputeEngineStats, Metadata, BoxedDomain, DomainExpression, FunctionDefinition, BoxedSubstitution, AssignValue, DomainLiteral, ArrayValue, AngularUnit, CanonicalOptions } from './public';
|
|
6
|
+
import { Rational } from './numerics/rationals';
|
|
7
|
+
import { IndexedLatexDictionary } from './latex-syntax/dictionary/definitions';
|
|
8
|
+
import { BoxedExpression, SemiBoxedExpression } from './boxed-expression/public';
|
|
9
|
+
import './boxed-expression/serialize';
|
|
6
10
|
/**
|
|
7
11
|
*
|
|
8
12
|
* To use the Compute Engine, create a `ComputeEngine` instance:
|
|
@@ -55,6 +59,17 @@ export declare class ComputeEngine implements IComputeEngine {
|
|
|
55
59
|
readonly PositiveInfinity: BoxedExpression;
|
|
56
60
|
readonly NegativeInfinity: BoxedExpression;
|
|
57
61
|
readonly ComplexInfinity: BoxedExpression;
|
|
62
|
+
/** The symbol separating the whole part of a number from its fractional
|
|
63
|
+
* part.
|
|
64
|
+
*
|
|
65
|
+
* Commonly a period (`.`) in English, but a comma (`,`) in many European
|
|
66
|
+
* languages. For the comma, use `"{,}"` so that the spacing is correct.
|
|
67
|
+
*
|
|
68
|
+
* Note that this is a LaTeX string and is used when parsing or serializing
|
|
69
|
+
* LaTeX. MathJSON always uses a period.
|
|
70
|
+
*
|
|
71
|
+
* */
|
|
72
|
+
decimalSeparator: LatexString;
|
|
58
73
|
/** @internal */
|
|
59
74
|
_BIGNUM_NAN: Decimal;
|
|
60
75
|
/** @internal */
|
|
@@ -73,8 +88,8 @@ export declare class ComputeEngine implements IComputeEngine {
|
|
|
73
88
|
private _precision;
|
|
74
89
|
/** @internal */
|
|
75
90
|
private _numericMode;
|
|
76
|
-
/** @internal */
|
|
77
|
-
private
|
|
91
|
+
/** @ internal */
|
|
92
|
+
private _angularUnit;
|
|
78
93
|
/** @internal */
|
|
79
94
|
private _tolerance;
|
|
80
95
|
/** @internal */
|
|
@@ -86,16 +101,6 @@ export declare class ComputeEngine implements IComputeEngine {
|
|
|
86
101
|
/** @internal */
|
|
87
102
|
private _cost?;
|
|
88
103
|
/** @internal */
|
|
89
|
-
private _jsonSerializationOptions;
|
|
90
|
-
/**
|
|
91
|
-
* During certain operations (serializing to LaTeX, constructing error
|
|
92
|
-
* messages) we need to use a "raw" JSON serialization without any customization. Setting the `_useRawJsonSerializationOptions` will bypass
|
|
93
|
-
* the `_jsonSerializationOptions` and use `_rawJsonSerializationOptions`
|
|
94
|
-
* instead
|
|
95
|
-
* @internal */
|
|
96
|
-
private _useRawJsonSerializationOptions;
|
|
97
|
-
private _rawJsonSerializationOptions;
|
|
98
|
-
/** @internal */
|
|
99
104
|
private _commonSymbols;
|
|
100
105
|
/** @internal */
|
|
101
106
|
private _commonNumbers;
|
|
@@ -136,6 +141,10 @@ export declare class ComputeEngine implements IComputeEngine {
|
|
|
136
141
|
* manipulate them.
|
|
137
142
|
*
|
|
138
143
|
*/
|
|
144
|
+
/** @private */
|
|
145
|
+
private _latexDictionaryInput;
|
|
146
|
+
/** @private */
|
|
147
|
+
_indexedLatexDictionary: IndexedLatexDictionary;
|
|
139
148
|
static getStandardLibrary(categories?: LibraryCategory[] | LibraryCategory | 'all'): readonly IdentifierDefinitions[];
|
|
140
149
|
/**
|
|
141
150
|
* Construct a new `ComputeEngine` instance.
|
|
@@ -164,13 +173,14 @@ export declare class ComputeEngine implements IComputeEngine {
|
|
|
164
173
|
* `chop()` as well.
|
|
165
174
|
*/
|
|
166
175
|
constructor(options?: {
|
|
176
|
+
ids?: readonly IdentifierDefinitions[];
|
|
167
177
|
numericMode?: NumericMode;
|
|
168
178
|
numericPrecision?: number;
|
|
169
|
-
ids?: readonly IdentifierDefinitions[];
|
|
170
179
|
tolerance?: number;
|
|
171
180
|
});
|
|
172
|
-
get latexDictionary():
|
|
173
|
-
set latexDictionary(dic:
|
|
181
|
+
get latexDictionary(): Readonly<LatexDictionaryEntry[]>;
|
|
182
|
+
set latexDictionary(dic: Readonly<LatexDictionaryEntry[]>);
|
|
183
|
+
get indexedLatexDictionary(): IndexedLatexDictionary;
|
|
174
184
|
/** After the configuration of the engine has changed, clear the caches
|
|
175
185
|
* so that new values can be recalculated.
|
|
176
186
|
*
|
|
@@ -203,6 +213,12 @@ export declare class ComputeEngine implements IComputeEngine {
|
|
|
203
213
|
get numericMode(): NumericMode;
|
|
204
214
|
/** {@inheritDoc NumericMode} */
|
|
205
215
|
set numericMode(f: NumericMode);
|
|
216
|
+
/**
|
|
217
|
+
* The unit used for angles in trigonometric functions.
|
|
218
|
+
* Default is `"rad"` (radians).
|
|
219
|
+
*/
|
|
220
|
+
get angularUnit(): AngularUnit;
|
|
221
|
+
set angularUnit(u: AngularUnit);
|
|
206
222
|
/** @experimental */
|
|
207
223
|
get timeLimit(): number;
|
|
208
224
|
/** @experimental */
|
|
@@ -322,9 +338,38 @@ export declare class ComputeEngine implements IComputeEngine {
|
|
|
322
338
|
complex(a: number | Decimal | Complex, b?: number | Decimal): Complex;
|
|
323
339
|
isBignum(a: unknown): a is Decimal;
|
|
324
340
|
isComplex(a: unknown): a is Complex;
|
|
325
|
-
/**
|
|
326
|
-
|
|
327
|
-
|
|
341
|
+
/**
|
|
342
|
+
* Return a LaTeX dictionary suitable for the specified category, or `"all"`
|
|
343
|
+
* for all categories (`"arithmetic"`, `"algebra"`, etc...).
|
|
344
|
+
*
|
|
345
|
+
* A LaTeX dictionary is needed to translate between LaTeX and MathJSON.
|
|
346
|
+
*
|
|
347
|
+
* Each entry in the dictionary indicate how a LaTeX token (or string of
|
|
348
|
+
* tokens) should be parsed into a MathJSON expression.
|
|
349
|
+
*
|
|
350
|
+
* For example an entry can define that the `\pi` LaTeX token should map to the
|
|
351
|
+
* symbol `"Pi"`, or that the token `-` should map to the function
|
|
352
|
+
* `["Negate",...]` when in a prefix position and to the function
|
|
353
|
+
* `["Subtract", ...]` when in an infix position.
|
|
354
|
+
*
|
|
355
|
+
* Furthermore, the information in each dictionary entry is used to serialize
|
|
356
|
+
* the LaTeX string corresponding to a MathJSON expression.
|
|
357
|
+
*
|
|
358
|
+
* Use with `ce.latexDictionary` to set the dictionary. You can complement
|
|
359
|
+
* it with your own definitions, for example with:
|
|
360
|
+
*
|
|
361
|
+
* ```ts
|
|
362
|
+
* ce.latexDictionary = [
|
|
363
|
+
* ...ce.getLatexDictionary("all"),
|
|
364
|
+
* {
|
|
365
|
+
* kind: "function",
|
|
366
|
+
* identifierTrigger: "concat",
|
|
367
|
+
* parse: "Concatenate"
|
|
368
|
+
* }
|
|
369
|
+
* ];
|
|
370
|
+
* ```
|
|
371
|
+
*/
|
|
372
|
+
static getLatexDictionary(domain?: LibraryCategory | 'all'): readonly Readonly<LatexDictionaryEntry>[];
|
|
328
373
|
/**
|
|
329
374
|
* 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.
|
|
330
375
|
*/
|
|
@@ -453,17 +498,15 @@ export declare class ComputeEngine implements IComputeEngine {
|
|
|
453
498
|
checkContinueExecution(): void;
|
|
454
499
|
/** @internal */
|
|
455
500
|
cache<T>(cacheName: string, build: () => T, purge: (T: any) => T | undefined): T;
|
|
456
|
-
/** Return a canonical version of an array of semi-boxed-expressions. */
|
|
457
|
-
canonical(xs: SemiBoxedExpression[]): BoxedExpression[];
|
|
458
501
|
/** Return a boxed expression from a number, string or semiboxed expression.
|
|
459
|
-
* Calls `function()`, `number()` or `symbol()` as appropriate.
|
|
502
|
+
* Calls `ce.function()`, `ce.number()` or `ce.symbol()` as appropriate.
|
|
460
503
|
*/
|
|
461
504
|
box(expr: Decimal | Complex | [num: number, denom: number] | SemiBoxedExpression, options?: {
|
|
462
|
-
canonical?:
|
|
505
|
+
canonical?: CanonicalOptions;
|
|
463
506
|
}): BoxedExpression;
|
|
464
507
|
function(head: string, ops: SemiBoxedExpression[], options?: {
|
|
465
508
|
metadata?: Metadata;
|
|
466
|
-
canonical?:
|
|
509
|
+
canonical?: CanonicalOptions;
|
|
467
510
|
}): BoxedExpression;
|
|
468
511
|
/**
|
|
469
512
|
*
|
|
@@ -471,7 +514,7 @@ export declare class ComputeEngine implements IComputeEngine {
|
|
|
471
514
|
*
|
|
472
515
|
* The result is canonical.
|
|
473
516
|
*/
|
|
474
|
-
error(message:
|
|
517
|
+
error(message: MathJsonIdentifier | [MathJsonIdentifier, ...SemiBoxedExpression[]], where?: SemiBoxedExpression): BoxedExpression;
|
|
475
518
|
domainError(expectedDomain: BoxedDomain | DomainLiteral, actualDomain: undefined | BoxedDomain, where?: SemiBoxedExpression): BoxedExpression;
|
|
476
519
|
/**
|
|
477
520
|
* Add a`["Hold"]` wrapper to `expr.
|
|
@@ -493,7 +536,7 @@ export declare class ComputeEngine implements IComputeEngine {
|
|
|
493
536
|
* Shortcut for `this.box(["Multiply", ...]).evaluate()`
|
|
494
537
|
*
|
|
495
538
|
*/
|
|
496
|
-
mul(...ops: BoxedExpression
|
|
539
|
+
mul(...ops: ReadonlyArray<BoxedExpression>): BoxedExpression;
|
|
497
540
|
/**
|
|
498
541
|
*
|
|
499
542
|
* Shortcut for `this.box(["Divide", num, denom]).evaluate()`
|
|
@@ -535,7 +578,7 @@ export declare class ComputeEngine implements IComputeEngine {
|
|
|
535
578
|
/** Return a boxed symbol */
|
|
536
579
|
symbol(name: string, options?: {
|
|
537
580
|
metadata?: Metadata;
|
|
538
|
-
canonical?:
|
|
581
|
+
canonical?: CanonicalOptions;
|
|
539
582
|
}): BoxedExpression;
|
|
540
583
|
/** Return a canonical boxed domain.
|
|
541
584
|
*
|
|
@@ -548,8 +591,8 @@ export declare class ComputeEngine implements IComputeEngine {
|
|
|
548
591
|
* to a common value for which we have a shared instance (-1, 0, NaN, etc...)
|
|
549
592
|
*/
|
|
550
593
|
number(value: number | bigint | string | MathJsonNumber | Decimal | Complex | Rational, options?: {
|
|
551
|
-
canonical?: boolean;
|
|
552
594
|
metadata?: Metadata;
|
|
595
|
+
canonical?: CanonicalOptions;
|
|
553
596
|
}): BoxedExpression;
|
|
554
597
|
rules(rules: Rule[]): BoxedRuleSet;
|
|
555
598
|
/**
|
|
@@ -557,41 +600,21 @@ export declare class ComputeEngine implements IComputeEngine {
|
|
|
557
600
|
* sure that the arguments are canonical.
|
|
558
601
|
*
|
|
559
602
|
* @internal */
|
|
560
|
-
_fn(head: string | BoxedExpression, ops: BoxedExpression[],
|
|
603
|
+
_fn(head: string | BoxedExpression, ops: BoxedExpression[], options?: Metadata & {
|
|
604
|
+
canonical?: boolean;
|
|
605
|
+
}): BoxedExpression;
|
|
561
606
|
/**
|
|
562
607
|
* Parse a string of LaTeX and return a corresponding `BoxedExpression`.
|
|
563
608
|
*
|
|
564
|
-
*
|
|
609
|
+
* If the `canonical` option is set to `true`, the result will be canonical
|
|
565
610
|
*
|
|
566
611
|
*/
|
|
567
|
-
parse(latex:
|
|
568
|
-
canonical?:
|
|
569
|
-
}): BoxedExpression;
|
|
570
|
-
parse(s: null, options?: {
|
|
571
|
-
canonical?: boolean | CanonicalForm | CanonicalForm[];
|
|
612
|
+
parse(latex: null, options?: Partial<ParseLatexOptions> & {
|
|
613
|
+
canonical?: CanonicalOptions;
|
|
572
614
|
}): null;
|
|
573
|
-
parse(latex: LatexString
|
|
574
|
-
canonical?:
|
|
575
|
-
}):
|
|
576
|
-
/** Serialize a `BoxedExpression` or a `MathJSON` expression to
|
|
577
|
-
* a LaTeX string
|
|
578
|
-
*/
|
|
579
|
-
serialize(x: Expression | BoxedExpression, options?: {
|
|
580
|
-
canonical?: boolean;
|
|
581
|
-
}): string;
|
|
582
|
-
get latexOptions(): NumberFormattingOptions & ParseLatexOptions & SerializeLatexOptions;
|
|
583
|
-
/**
|
|
584
|
-
* Options to control the serialization of MathJSON expression to LaTeX
|
|
585
|
-
* when using `expr.latex` or `ce.serialize()`.
|
|
586
|
-
*
|
|
587
|
-
*/
|
|
588
|
-
/** {@inheritDoc NumberFormattingOptions} */
|
|
589
|
-
/** {@inheritDoc ParseLatexOptions} */
|
|
590
|
-
/** {@inheritDoc SerializeLatexOptions} */
|
|
591
|
-
set latexOptions(opts: Partial<NumberFormattingOptions> & Partial<ParseLatexOptions> & Partial<SerializeLatexOptions>);
|
|
592
|
-
get jsonSerializationOptions(): Readonly<JsonSerializationOptions>;
|
|
593
|
-
set jsonSerializationOptions(val: Partial<JsonSerializationOptions>);
|
|
594
|
-
rawJson(expr: BoxedExpression): Expression;
|
|
615
|
+
parse(latex: LatexString, options?: Partial<ParseLatexOptions> & {
|
|
616
|
+
canonical?: CanonicalOptions;
|
|
617
|
+
}): BoxedExpression;
|
|
595
618
|
/**
|
|
596
619
|
* Return a list of all the assumptions that match a pattern.
|
|
597
620
|
*
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.25.0 */
|
|
2
2
|
import { Decimal } from 'decimal.js';
|
|
3
|
-
import {
|
|
3
|
+
import { Rational } from './numerics/rationals';
|
|
4
|
+
import type { BoxedDomain, BoxedFunctionSignature, DomainLiteral, FunctionSignature, IComputeEngine } from './public';
|
|
4
5
|
/**
|
|
5
6
|
* Determine the numeric domain of a number.
|
|
6
7
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.25.0 */
|
|
2
2
|
/***
|
|
3
3
|
* ### THEORY OF OPERATIONS
|
|
4
4
|
*
|
|
@@ -71,7 +71,7 @@ export declare function canonicalFunctionExpression(expr: BoxedExpression): Boxe
|
|
|
71
71
|
* - an expression with anonymous parameters, e.g. ["Add", "_", 1]
|
|
72
72
|
* - the identifier for a function, e.g. "Sin".
|
|
73
73
|
*/
|
|
74
|
-
export declare function apply(fn: BoxedExpression, args: BoxedExpression
|
|
74
|
+
export declare function apply(fn: BoxedExpression, args: ReadonlyArray<BoxedExpression>): BoxedExpression;
|
|
75
75
|
/**
|
|
76
76
|
* Return a lambda function, assuming a scoped environment has been
|
|
77
77
|
* created and there is a single numeric argument
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.25.0 */
|
|
2
2
|
export declare const DEFINITIONS_ALGEBRA: LatexDictionary;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.25.0 */
|
|
2
2
|
export declare const DEFINITIONS_ARITHMETIC: LatexDictionary;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.25.0 */
|
|
2
2
|
export declare const DEFINITIONS_CALCULUS: LatexDictionary;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.25.0 */
|
|
2
2
|
export declare const DEFINITIONS_COMPLEX: LatexDictionary;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.25.0 */
|
|
2
2
|
export declare const DEFINITIONS_LINEAR_ALGEBRA: LatexDictionary;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.25.0 */
|
|
2
2
|
export declare const DEFINITIONS_LOGIC: LatexDictionary;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.25.0 */
|
|
2
2
|
export declare const DEFINITIONS_OTHERS: LatexDictionary;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.25.0 */
|
|
2
2
|
export declare const DEFINITIONS_SETS: LatexDictionary;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.25.0 */
|
|
2
2
|
export declare const DEFINITIONS_STATISTICS: LatexDictionary;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.25.0 */
|
|
2
2
|
export declare const DEFINITIONS_TRIGONOMETRY: LatexDictionary;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/* 0.
|
|
2
|
-
import {
|
|
1
|
+
/* 0.25.0 */
|
|
2
|
+
import { Delimiter, EnvironmentParseHandler, ExpressionParseHandler, InfixParseHandler, LatexDictionary, LatexDictionaryEntry, LatexString, LatexToken, LibraryCategory, MatchfixParseHandler, PostfixParseHandler, Precedence, SerializeHandler } from '../public';
|
|
3
3
|
export type CommonEntry = {
|
|
4
4
|
/** Note: a name is required if a serialize handler is provided */
|
|
5
5
|
name?: string;
|
|
@@ -49,7 +49,7 @@ export type IndexedMatchfixEntry = CommonEntry & {
|
|
|
49
49
|
export declare function isIndexedMatchfixEntry(entry: IndexedLatexDictionaryEntry): entry is IndexedMatchfixEntry;
|
|
50
50
|
export type IndexedInfixEntry = CommonEntry & {
|
|
51
51
|
kind: 'infix';
|
|
52
|
-
associativity: 'right' | 'left' | '
|
|
52
|
+
associativity: 'right' | 'left' | 'none' | 'any';
|
|
53
53
|
precedence: Precedence;
|
|
54
54
|
parse: InfixParseHandler;
|
|
55
55
|
};
|
|
@@ -81,7 +81,8 @@ export type IndexedLatexDictionary = {
|
|
|
81
81
|
lookahead: number;
|
|
82
82
|
defs: IndexedLatexDictionaryEntry[];
|
|
83
83
|
};
|
|
84
|
-
export declare function indexLatexDictionary(dic:
|
|
84
|
+
export declare function indexLatexDictionary(dic: Readonly<Partial<LatexDictionaryEntry>[]>, onError: (sig: WarningSignal) => void): IndexedLatexDictionary;
|
|
85
85
|
export declare const DEFAULT_LATEX_DICTIONARY: {
|
|
86
86
|
[category in LibraryCategory]?: LatexDictionary;
|
|
87
87
|
};
|
|
88
|
+
export declare function getLatexDictionary(category?: LibraryCategory | 'all'): readonly Readonly<LatexDictionaryEntry>[];
|