@cortex-js/compute-engine 0.4.0 → 0.4.3
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/README.md +2 -2
- package/dist/compute-engine.esm.js +22846 -16608
- package/dist/compute-engine.js +23518 -17282
- package/dist/compute-engine.min.esm.js +2 -7
- package/dist/compute-engine.min.js +2 -7
- package/dist/math-json.esm.js +4337 -10529
- package/dist/math-json.js +4354 -10532
- package/dist/math-json.min.esm.js +2 -7
- package/dist/math-json.min.js +2 -7
- package/dist/types/common/grapheme-splitter.d.ts +1 -1
- package/dist/types/common/signals.d.ts +90 -0
- package/dist/types/compute-engine/assume.d.ts +21 -0
- package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +107 -0
- package/dist/types/compute-engine/boxed-expression/box.d.ts +56 -0
- package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +39 -0
- package/dist/types/compute-engine/boxed-expression/boxed-domain.d.ts +8 -0
- package/dist/types/compute-engine/boxed-expression/boxed-function-definition.d.ts +2 -0
- package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +93 -0
- package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +83 -0
- package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +21 -0
- package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +23 -0
- package/dist/types/compute-engine/boxed-expression/boxed-symbol-definition.d.ts +98 -0
- package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +74 -0
- package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +12 -0
- package/dist/types/compute-engine/boxed-expression/order.d.ts +52 -0
- package/dist/types/compute-engine/boxed-expression/serialize.d.ts +15 -0
- package/dist/types/compute-engine/boxed-expression/utils.d.ts +37 -0
- package/dist/types/compute-engine/compute-engine.d.ts +252 -0
- package/dist/types/compute-engine/cost-function.d.ts +3 -0
- package/dist/types/compute-engine/dictionary/arithmetic-add.d.ts +11 -0
- package/dist/types/compute-engine/dictionary/arithmetic-divide.d.ts +9 -0
- package/dist/types/compute-engine/dictionary/arithmetic-multiply.d.ts +17 -0
- package/dist/types/compute-engine/dictionary/arithmetic-power.d.ts +9 -0
- package/dist/types/compute-engine/dictionary/arithmetic.d.ts +2 -12
- package/dist/types/compute-engine/dictionary/collections.d.ts +2 -0
- package/dist/types/compute-engine/dictionary/core.d.ts +2 -0
- package/dist/types/compute-engine/dictionary/dictionary.d.ts +26 -0
- package/dist/types/compute-engine/dictionary/logic.d.ts +2 -0
- package/dist/types/compute-engine/dictionary/polynomials.d.ts +2 -0
- package/dist/types/compute-engine/dictionary/relational-operator.d.ts +2 -0
- package/dist/types/compute-engine/dictionary/sets.d.ts +2 -0
- package/dist/types/compute-engine/dictionary/trigonometry.d.ts +2 -0
- package/dist/types/compute-engine/domain-utils.d.ts +30 -0
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +2 -0
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +2 -0
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +2 -0
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +4 -0
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-inequalities.d.ts +2 -0
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +2 -0
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +2 -0
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +2 -0
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +2 -0
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +2 -0
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +57 -0
- package/dist/types/compute-engine/latex-syntax/latex-syntax.d.ts +23 -0
- package/dist/types/compute-engine/latex-syntax/parse.d.ts +198 -0
- package/dist/types/compute-engine/latex-syntax/public.d.ts +550 -0
- package/dist/types/{common → compute-engine/latex-syntax}/serialize-number.d.ts +2 -3
- package/dist/types/{latex-syntax → compute-engine/latex-syntax}/serializer-style.d.ts +2 -1
- package/dist/types/compute-engine/latex-syntax/serializer.d.ts +43 -0
- package/dist/types/{latex-syntax/core → compute-engine/latex-syntax}/tokenizer.d.ts +2 -2
- package/dist/types/compute-engine/numerics/numeric-complex.d.ts +3 -0
- package/dist/types/compute-engine/numerics/numeric-decimal.d.ts +12 -0
- package/dist/types/compute-engine/numerics/numeric.d.ts +35 -0
- package/dist/types/compute-engine/numerics/primes.d.ts +2 -0
- package/dist/types/compute-engine/public.d.ts +1076 -434
- package/dist/types/compute-engine/rules.d.ts +18 -0
- package/dist/types/compute-engine/simplify-rules.d.ts +17 -0
- package/dist/types/compute-engine/symbolic/expand.d.ts +11 -0
- package/dist/types/compute-engine/symbolic/flatten.d.ts +7 -0
- package/dist/types/compute-engine/symbolic/negate.d.ts +12 -0
- package/dist/types/compute-engine/symbolic/polynomials.d.ts +52 -0
- package/dist/types/compute-engine/symbolic/product.d.ts +45 -0
- package/dist/types/compute-engine/symbolic/sum.d.ts +25 -0
- package/dist/types/compute-engine/symbolic/utils.d.ts +47 -0
- package/dist/types/compute-engine.d.ts +3 -0
- package/dist/types/math-json/math-json-format.d.ts +101 -0
- package/dist/types/math-json/utils.d.ts +97 -0
- package/dist/types/math-json.d.ts +5 -3
- package/package.json +39 -36
- package/dist/types/common/utils.d.ts +0 -153
- package/dist/types/compute-engine/expression-map.d.ts +0 -11
- package/dist/types/compute-engine/numeric-complex.d.ts +0 -2
- package/dist/types/compute-engine/numeric-decimal.d.ts +0 -12
- package/dist/types/compute-engine/numeric.d.ts +0 -21
- package/dist/types/compute-engine/patterns.d.ts +0 -22
- package/dist/types/compute-engine/predicates.d.ts +0 -42
- package/dist/types/compute-engine/utils.d.ts +0 -15
- package/dist/types/latex-syntax/definitions-algebra.d.ts +0 -2
- package/dist/types/latex-syntax/definitions-arithmetic.d.ts +0 -3
- package/dist/types/latex-syntax/definitions-calculus.d.ts +0 -2
- package/dist/types/latex-syntax/definitions-core.d.ts +0 -3
- package/dist/types/latex-syntax/definitions-inequalities.d.ts +0 -2
- package/dist/types/latex-syntax/definitions-other.d.ts +0 -3
- package/dist/types/latex-syntax/definitions-sets.d.ts +0 -2
- package/dist/types/latex-syntax/definitions-symbols.d.ts +0 -3
- package/dist/types/latex-syntax/definitions-trigonometry.d.ts +0 -3
- package/dist/types/latex-syntax/definitions.d.ts +0 -40
- package/dist/types/latex-syntax/latex-syntax.d.ts +0 -27
- package/dist/types/latex-syntax/parse.d.ts +0 -138
- package/dist/types/latex-syntax/public.d.ts +0 -455
- package/dist/types/latex-syntax/serializer.d.ts +0 -26
- package/dist/types/latex-syntax/utils.d.ts +0 -10
- package/dist/types/public.d.ts +0 -163
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
/* 0.4.0 */
|
|
2
|
-
import { Decimal } from 'decimal.js';
|
|
3
|
-
import { Complex } from 'complex.js';
|
|
4
|
-
import { Numeric } from '../compute-engine/public';
|
|
5
|
-
/**
|
|
6
|
-
* The `ExpressionX` type is used internally to make computations with
|
|
7
|
-
* arbitrarily large floating point and complex numbers
|
|
8
|
-
*
|
|
9
|
-
*/
|
|
10
|
-
export declare type ExpressionX = Expression<Numeric>;
|
|
11
|
-
/**
|
|
12
|
-
* These constants are the 'primitive' functions and constants that are used
|
|
13
|
-
* for some basic manipulations such as parsing, and transforming to canonical
|
|
14
|
-
* form.
|
|
15
|
-
*
|
|
16
|
-
*/
|
|
17
|
-
export declare const PARENTHESES = "Parentheses";
|
|
18
|
-
export declare const IDENTITY = "Identity";
|
|
19
|
-
export declare const LATEX_TOKENS = "LatexTokens";
|
|
20
|
-
export declare const LIST = "List";
|
|
21
|
-
export declare const MISSING = "Missing";
|
|
22
|
-
export declare const NOTHING = "Nothing";
|
|
23
|
-
export declare const SEQUENCE = "Sequence";
|
|
24
|
-
export declare const SEQUENCE2 = "Sequence2";
|
|
25
|
-
export declare const ADD = "Add";
|
|
26
|
-
export declare const DERIVATIVE = "Derivative";
|
|
27
|
-
export declare const DIVIDE = "Divide";
|
|
28
|
-
export declare const EXP = "Exp";
|
|
29
|
-
export declare const INVERSE_FUNCTION = "InverseFunction";
|
|
30
|
-
export declare const MULTIPLY = "Multiply";
|
|
31
|
-
export declare const NEGATE = "Negate";
|
|
32
|
-
export declare const POWER = "Power";
|
|
33
|
-
export declare const PRIME = "Prime";
|
|
34
|
-
export declare const ROOT = "Root";
|
|
35
|
-
export declare const SQRT = "Sqrt";
|
|
36
|
-
export declare const SUBTRACT = "Subtract";
|
|
37
|
-
export declare const COMPLEX_INFINITY = "ComplexInfinity";
|
|
38
|
-
export declare const PI = "Pi";
|
|
39
|
-
export declare const EXPONENTIAL_E = "ExponentialE";
|
|
40
|
-
export declare const IMAGINARY_UNIT = "ImaginaryUnit";
|
|
41
|
-
export declare function isNumberObject(expr: Expression | null): expr is MathJsonRealNumber;
|
|
42
|
-
export declare function isSymbolObject(expr: Expression | null): expr is MathJsonSymbol;
|
|
43
|
-
export declare function isStringObject(expr: Expression | null): expr is MathJsonString;
|
|
44
|
-
export declare function isFunctionObject<T extends number = number>(expr: Expression<T> | null): expr is MathJsonFunction<T>;
|
|
45
|
-
export declare function isDictionaryObject<T extends number = number>(expr: Expression<T>): expr is MathJsonRealNumber;
|
|
46
|
-
export declare function getNumberValue<T extends number = number>(expr: Expression<T> | null): number | null;
|
|
47
|
-
/** Only return non-null if the expression is a Complex number.
|
|
48
|
-
* Return null if it's a number, or a symbol (other than `ImaginaryUnit` or
|
|
49
|
-
* `ComplexInfinity`)
|
|
50
|
-
*
|
|
51
|
-
*/
|
|
52
|
-
export declare function getComplexValue(expr: Complex | Expression | null): Complex | null;
|
|
53
|
-
/**
|
|
54
|
-
* Return a multiple of the imaginary unit, e.g.
|
|
55
|
-
* - 'ImaginaryUnit'
|
|
56
|
-
* - ['Negate', 'ImaginaryUnit']
|
|
57
|
-
* - ['Multiply', 5, 'ImaginaryUnit']
|
|
58
|
-
* - ['Multiply', 'ImaginaryUnit', 5]
|
|
59
|
-
*/
|
|
60
|
-
export declare function getImaginaryValue(expr: Expression): number | null;
|
|
61
|
-
export declare function getDecimalValue(expr: Decimal | Expression | null): Decimal | null;
|
|
62
|
-
/** If expr is a string literal, return it.
|
|
63
|
-
*
|
|
64
|
-
* A string literal is a JSON string that begins and ends with
|
|
65
|
-
* **U+0027 APOSTROPHE** : **`'`** or an object literal with a `str` key.
|
|
66
|
-
*/
|
|
67
|
-
export declare function getStringValue(expr: Expression | null): string | null;
|
|
68
|
-
/**
|
|
69
|
-
* Return a rational (numer over denom) representation of the expression,
|
|
70
|
-
* if possible, `[null, null]` otherwise.
|
|
71
|
-
*
|
|
72
|
-
* The expression can be:
|
|
73
|
-
* - Some symbols: "ThreeQuarte", "Half"...
|
|
74
|
-
* - ["Power", d, -1]
|
|
75
|
-
* - ["Power", n, 1]
|
|
76
|
-
* - ["Divide", n, d]
|
|
77
|
-
*
|
|
78
|
-
* The denominator is always > 0.
|
|
79
|
-
*/
|
|
80
|
-
export declare function getRationalValue(expr: Expression): [number, number] | [null, null];
|
|
81
|
-
/**
|
|
82
|
-
* Reduce the numerator and denominator:
|
|
83
|
-
* `\frac{2}{4} -> \frac{1}{2})`
|
|
84
|
-
*/
|
|
85
|
-
export declare function simplifyRational([numer, denom]: [number, number] | [null, null]): [number, number] | [null, null];
|
|
86
|
-
/**
|
|
87
|
-
* Return the numerator and denominator of a product with the specified symbol.
|
|
88
|
-
* For example:
|
|
89
|
-
* `3π` -> [3, 1]
|
|
90
|
-
* `3π/2` -> [3, 2]
|
|
91
|
-
* `1/2 * π` -> [1, 2]
|
|
92
|
-
*/
|
|
93
|
-
export declare function getRationalSymbolicValue(expr: Expression, symbol: string): [number, number] | [null, null];
|
|
94
|
-
/** True if the expression is of the form \frac{n}{m} where n and m are both integers
|
|
95
|
-
*
|
|
96
|
-
* Note this detects fewer patterns than `getRationalValue()`, but it is
|
|
97
|
-
* intended to detect rational numbers used with invisible plus, i.e. `1\frac{1}{2}`
|
|
98
|
-
*
|
|
99
|
-
*/
|
|
100
|
-
export declare function isRationalNumber(expr: Expression): boolean;
|
|
101
|
-
/**
|
|
102
|
-
* Return the head of any expression, including symbols and numbers.
|
|
103
|
-
*
|
|
104
|
-
*/
|
|
105
|
-
export declare function getHead(expr: Expression): Expression | null;
|
|
106
|
-
/**
|
|
107
|
-
* The head of a function can be a string or an expression.
|
|
108
|
-
*
|
|
109
|
-
* Return `null` if the expression is not a function.
|
|
110
|
-
*
|
|
111
|
-
* Examples:
|
|
112
|
-
* * `["Negate", 5]` -> `"Negate"`
|
|
113
|
-
* * `[["Prime", "f"], "x"]` -> `["Prime", "f"]`
|
|
114
|
-
*/
|
|
115
|
-
export declare function getFunctionHead<T extends number = number>(expr: Expression<T> | null): Expression<T> | null;
|
|
116
|
-
/**
|
|
117
|
-
* True if the expression is a number, a symbol or a string
|
|
118
|
-
* (i.e. not a function and not a dictionary)
|
|
119
|
-
*/
|
|
120
|
-
export declare function isAtomic(expr: Expression | null): boolean;
|
|
121
|
-
export declare function getFunctionName<T extends number = number>(expr: Expression<T> | null): typeof MULTIPLY | typeof POWER | typeof DIVIDE | typeof ADD | typeof SUBTRACT | typeof NEGATE | typeof DERIVATIVE | typeof INVERSE_FUNCTION | typeof LATEX_TOKENS | typeof SQRT | typeof ROOT | typeof PARENTHESES | typeof LIST | typeof MISSING | typeof PRIME | typeof IDENTITY | typeof NOTHING | typeof SEQUENCE | typeof SEQUENCE2 | typeof PRIME | 'PartialDerivative' | 'Union' | 'Intersection' | 'SetMinus' | 'Cosh' | 'Exp' | 'Re' | 'And' | 'Not' | 'Equal' | 'NotEqual' | 'Element' | 'NotElement' | 'Complex' | 'Hold' | 'Evaluate' | '';
|
|
122
|
-
export declare function getSymbolName(expr: Expression | null): string | null;
|
|
123
|
-
/**
|
|
124
|
-
* Return all the elements but the first one, i.e. the arguments of a
|
|
125
|
-
* function.
|
|
126
|
-
*/
|
|
127
|
-
export declare function getTail<T extends number = number>(expr: Expression<T> | null): Expression<T>[];
|
|
128
|
-
export declare function applyRecursively<T extends number = number>(expr: Expression<T>, fn: (x: Expression<T>) => Expression<T>): Expression<T>;
|
|
129
|
-
/**
|
|
130
|
-
* Apply a function to the arguments of a function and return an array of T
|
|
131
|
-
*/
|
|
132
|
-
export declare function mapArgs<T>(expr: Expression, fn: (x: Expression) => T): T[];
|
|
133
|
-
export declare function getArg<T extends number = number>(expr: Expression<T> | null, n: number): Expression<T> | null;
|
|
134
|
-
export declare function getArgCount<T extends number = number>(expr: Expression<T>): number;
|
|
135
|
-
export declare function getDictionary<T extends number = number>(expr: Expression<T>): {
|
|
136
|
-
[key: string]: Expression<T>;
|
|
137
|
-
} | null;
|
|
138
|
-
/**
|
|
139
|
-
* Structurally compare two expressions, ignoring metadata.
|
|
140
|
-
*
|
|
141
|
-
* Compare with `match()` which ignores differences in representation.
|
|
142
|
-
*
|
|
143
|
-
* @revisit: is this really needed? Or just use `match()`?
|
|
144
|
-
*/
|
|
145
|
-
export declare function equalExpr<T extends number = number>(lhs: Expression<T> | null, rhs: Expression<T> | null): boolean;
|
|
146
|
-
/**
|
|
147
|
-
* Return the nth term in expr.
|
|
148
|
-
* If expr is not a "add" function, returns null.
|
|
149
|
-
*/
|
|
150
|
-
/**
|
|
151
|
-
* Return the coefficient of the expression, assuming vars are variables.
|
|
152
|
-
*/
|
|
153
|
-
export declare function coef(_expr: Expression, _vars: string[]): Expression | null;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/* 0.4.0 */
|
|
2
|
-
export declare class ExpressionMap<T extends number, U> {
|
|
3
|
-
readonly _items: Map<Expression<T>, U>;
|
|
4
|
-
constructor(source?: ExpressionMap<T, U> | Iterable<[T, U]>);
|
|
5
|
-
has(expr: Expression<T>): boolean;
|
|
6
|
-
get(expr: Expression<T>): U | undefined;
|
|
7
|
-
set(expr: Expression<T>, value: U): void;
|
|
8
|
-
delete(expr: Expression<T>): void;
|
|
9
|
-
[Symbol.iterator](): IterableIterator<[Expression<T>, U]>;
|
|
10
|
-
entries(): IterableIterator<[Expression<T>, U]>;
|
|
11
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/* 0.4.0 */
|
|
2
|
-
export declare const DECIMAL_ZERO: Decimal;
|
|
3
|
-
export declare const DECIMAL_ONE: Decimal;
|
|
4
|
-
export declare const DECIMAL_MINUS_ONE: Decimal;
|
|
5
|
-
export declare const DECIMAL_NAN: Decimal;
|
|
6
|
-
export declare const DECIMAL_POS_INFINITY: Decimal;
|
|
7
|
-
export declare const DECIMAL_NEG_INFINITY: Decimal;
|
|
8
|
-
export declare function gcd(a: Decimal, b: Decimal): Decimal;
|
|
9
|
-
export declare function lcm(a: Decimal, b: Decimal): Decimal;
|
|
10
|
-
export declare function factorial(n: Decimal | number): Decimal;
|
|
11
|
-
export declare function lngamma(z: Decimal | number): Decimal;
|
|
12
|
-
export declare function gamma(z: Decimal | number): Decimal;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/* 0.4.0 */
|
|
2
|
-
export declare const MACHINE_PRECISION: number;
|
|
3
|
-
export declare const MACHINE_TOLERANCE_BITS = 7;
|
|
4
|
-
export declare const MACHINE_TOLERANCE: number;
|
|
5
|
-
export declare const NUMERICAL_TOLERANCE: number;
|
|
6
|
-
/**
|
|
7
|
-
* Returns the smallest floating-point number greater than x.
|
|
8
|
-
* Denormalized values may not be supported.
|
|
9
|
-
*/
|
|
10
|
-
export declare function nextUp(x: number): number;
|
|
11
|
-
export declare function nextDown(x: number): number;
|
|
12
|
-
export declare const SMALL_PRIMES: Set<number>;
|
|
13
|
-
export declare const LARGEST_SMALL_PRIME = 7919;
|
|
14
|
-
export declare function primeFactors(_n: number): {
|
|
15
|
-
[factor: number]: number;
|
|
16
|
-
};
|
|
17
|
-
export declare function gcd(a: number, b: number): number;
|
|
18
|
-
export declare function lcm(a: number, b: number): number;
|
|
19
|
-
export declare function factorial(n: number): number;
|
|
20
|
-
export declare function lngamma(z: number): number;
|
|
21
|
-
export declare function gamma(z: number): number;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/* 0.4.0 */
|
|
2
|
-
import { Expression } from '../public';
|
|
3
|
-
import { Numeric } from './public';
|
|
4
|
-
export declare type Substitution<T extends number = number> = {
|
|
5
|
-
[symbol: string]: Expression<T>;
|
|
6
|
-
};
|
|
7
|
-
export declare function matchRecursive(expr: ExpressionX, pattern: ExpressionX, substitution: Substitution<Numeric>, options: {
|
|
8
|
-
numericalTolerance: number;
|
|
9
|
-
}): Substitution<Numeric> | null;
|
|
10
|
-
export declare function match<T extends number = number>(pattern: Expression<T>, expr: Expression<T>, options?: {
|
|
11
|
-
numericalTolerance: number;
|
|
12
|
-
}): Substitution<T> | null;
|
|
13
|
-
export declare function match1(expr: Expression, pattern: Expression, options: {
|
|
14
|
-
numericalTolerance: number;
|
|
15
|
-
}): Expression | null;
|
|
16
|
-
export declare function count(exprs: Iterable<Expression>, pattern: Expression, options: {
|
|
17
|
-
numericalTolerance: number;
|
|
18
|
-
}): number;
|
|
19
|
-
export declare function matchList(exprs: Iterable<Expression>, pattern: Expression, options: {
|
|
20
|
-
numericalTolerance: number;
|
|
21
|
-
}): Substitution[];
|
|
22
|
-
export declare function substitute<T extends number = Numeric>(expr: Expression<T>, substitution: Substitution<T>): Expression<T>;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/* 0.4.0 */
|
|
2
|
-
import { ComputeEngine, Domain } from './public';
|
|
3
|
-
export declare function isInteger(ce: ComputeEngine, expr: Expression): boolean;
|
|
4
|
-
export declare function isNumeric(_ce: ComputeEngine, _expr: Expression | null): boolean | undefined;
|
|
5
|
-
export declare function isZero(ce: ComputeEngine, expr: Expression): boolean | undefined;
|
|
6
|
-
export declare function isNotZero(engine: ComputeEngine, expr: Expression): boolean | undefined;
|
|
7
|
-
export declare function isInfinity(ce: ComputeEngine, expr: Expression | null): boolean | undefined;
|
|
8
|
-
export declare function isFinite(_ce: ComputeEngine, _expr: Expression | null): boolean | undefined;
|
|
9
|
-
export declare function isPosInfinity(ce: ComputeEngine, expr: Expression | null): boolean | undefined;
|
|
10
|
-
export declare function isNegInfinity(ce: ComputeEngine, expr: Expression | null): boolean | undefined;
|
|
11
|
-
export declare function isPositive(ce: ComputeEngine, expr: Expression | null): boolean | undefined;
|
|
12
|
-
export declare function isOne(ce: ComputeEngine, expr: Expression): boolean | undefined;
|
|
13
|
-
export declare function isNegativeOne(ce: ComputeEngine, expr: Expression): boolean | undefined;
|
|
14
|
-
/** Is `expr` >= 0? */
|
|
15
|
-
export declare function isNonNegative(ce: ComputeEngine, expr: Expression): boolean | undefined;
|
|
16
|
-
/** Is `expr` < 0? */
|
|
17
|
-
export declare function isNegative(ce: ComputeEngine, expr: Expression): boolean | undefined;
|
|
18
|
-
/** Is `expr` <= 0? */
|
|
19
|
-
export declare function isNonPositive(ce: ComputeEngine, expr: Expression): boolean | undefined;
|
|
20
|
-
export declare function isReal(_ce: ComputeEngine, expr: Expression | null): boolean | undefined;
|
|
21
|
-
/** Is `expr` an element of RR, including ±∞? */
|
|
22
|
-
export declare function isExtendedReal(_ce: ComputeEngine, _expr: Expression): boolean | undefined;
|
|
23
|
-
/** Is `expr` an element of QQ (can be written as p/q)? */
|
|
24
|
-
export declare function isRational(_ce: ComputeEngine, _expr: Expression): boolean | undefined;
|
|
25
|
-
/** Is `expr` an algebraic number, i.e. not transcendental (π, e)? */
|
|
26
|
-
export declare function isAlgebraic(_ce: ComputeEngine, _expr: Expression): boolean | undefined;
|
|
27
|
-
/** Is `expr` a complex number? */
|
|
28
|
-
export declare function isComplex(_ce: ComputeEngine, _expr: Expression): boolean | undefined;
|
|
29
|
-
/** Is `expr` an element of `dom`? */
|
|
30
|
-
export declare function isElement(_ce: ComputeEngine, _expr: Expression, _set: Expression): boolean | undefined;
|
|
31
|
-
/** Test if `lhs` is a subset of `rhs`.
|
|
32
|
-
*
|
|
33
|
-
* `lhs` and `rhs` can be set expressions, i.e.
|
|
34
|
-
* `["SetMinus", "ComplexNumber", 0]`
|
|
35
|
-
*
|
|
36
|
-
*/
|
|
37
|
-
export declare function isSubsetOf(ce: ComputeEngine, lhs: Domain | null, rhs: Domain | null): boolean;
|
|
38
|
-
export declare function isEqual(_ce: ComputeEngine, _lhs: Expression, _rhs: Expression): boolean | undefined;
|
|
39
|
-
export declare function isLess(_ce: ComputeEngine, _lhs: Expression, _rhs: Expression): boolean | undefined;
|
|
40
|
-
export declare function isLessEqual(_ce: ComputeEngine, _lhs: Expression, _rhs: Expression): boolean | undefined;
|
|
41
|
-
export declare function isGreater(_ce: ComputeEngine, _lhs: Expression, _rhs: Expression): boolean | undefined;
|
|
42
|
-
export declare function isGreaterEqual(_ce: ComputeEngine, _lhs: Expression, _rhs: Expression): boolean | undefined;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/* 0.4.0 */
|
|
2
|
-
import { ComputeEngine } from './public';
|
|
3
|
-
export declare class CortexError {
|
|
4
|
-
signal: ErrorSignal;
|
|
5
|
-
constructor(errorSignal: Signal);
|
|
6
|
-
toString(): string;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Return the set of variables (free or not) in an expression.
|
|
10
|
-
* Doesn't return free varas because doesn't account for variable declaration
|
|
11
|
-
* and scopes.
|
|
12
|
-
*/
|
|
13
|
-
export declare function getVariables(ce: ComputeEngine, expr: Expression): Set<string>;
|
|
14
|
-
export declare function isCanonical(ce: ComputeEngine, expr: Expression): boolean;
|
|
15
|
-
export declare function hasWildcards(expr: Expression): boolean;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/* 0.4.0 */
|
|
2
|
-
import { LatexDictionary, LatexString, LatexToken, ParserFunction, SerializerFunction, LatexDictionaryEntry } from './public';
|
|
3
|
-
import { Numeric } from '../compute-engine/public';
|
|
4
|
-
export declare type IndexedLatexDictionaryEntry<T extends number = number> = {
|
|
5
|
-
name: string;
|
|
6
|
-
trigger?: {
|
|
7
|
-
symbol?: LatexToken | LatexToken[];
|
|
8
|
-
matchfix?: LatexToken | LatexToken[];
|
|
9
|
-
infix?: LatexToken | LatexToken[];
|
|
10
|
-
prefix?: LatexToken | LatexToken[];
|
|
11
|
-
postfix?: LatexToken | LatexToken[];
|
|
12
|
-
superfix?: LatexToken | LatexToken[];
|
|
13
|
-
subfix?: LatexToken | LatexToken[];
|
|
14
|
-
};
|
|
15
|
-
parse: Expression<T> | ParserFunction<T>;
|
|
16
|
-
serialize: SerializerFunction<T> | LatexString;
|
|
17
|
-
associativity: 'right' | 'left' | 'non' | 'both';
|
|
18
|
-
precedence: number;
|
|
19
|
-
arguments: 'group' | 'implicit' | '';
|
|
20
|
-
optionalLatexArg: number;
|
|
21
|
-
requiredLatexArg: number;
|
|
22
|
-
separator: LatexString;
|
|
23
|
-
closeFence: LatexString;
|
|
24
|
-
};
|
|
25
|
-
export declare type IndexedLatexDictionary<T extends number = number> = {
|
|
26
|
-
lookahead: number;
|
|
27
|
-
name: Map<string, IndexedLatexDictionaryEntry<T>>;
|
|
28
|
-
prefix: (Map<LatexString, IndexedLatexDictionaryEntry<T>> | null)[];
|
|
29
|
-
infix: (Map<LatexString, IndexedLatexDictionaryEntry<T>> | null)[];
|
|
30
|
-
postfix: (Map<LatexString, IndexedLatexDictionaryEntry<T>> | null)[];
|
|
31
|
-
matchfix: (Map<LatexString, IndexedLatexDictionaryEntry<T>> | null)[];
|
|
32
|
-
superfix: (Map<LatexString, IndexedLatexDictionaryEntry<T>> | null)[];
|
|
33
|
-
subfix: (Map<LatexString, IndexedLatexDictionaryEntry<T>> | null)[];
|
|
34
|
-
symbol: (Map<LatexString, IndexedLatexDictionaryEntry<T>> | null)[];
|
|
35
|
-
environment: Map<string, IndexedLatexDictionaryEntry<T>>;
|
|
36
|
-
};
|
|
37
|
-
export declare function indexLatexDictionary<T extends number = number>(dic: readonly LatexDictionaryEntry<T>[], onError: ErrorListener<ErrorCode>): IndexedLatexDictionary<T>;
|
|
38
|
-
export declare const DEFAULT_LATEX_DICTIONARY: {
|
|
39
|
-
[category in DictionaryCategory]?: LatexDictionary<Numeric>;
|
|
40
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/* 0.4.0 */
|
|
2
|
-
import { DictionaryCategory, Expression, ErrorCode, ErrorListener } from '../public';
|
|
3
|
-
import { Numeric } from '../compute-engine/public';
|
|
4
|
-
export declare class LatexSyntax<T extends number = number> {
|
|
5
|
-
onError: ErrorListener<ErrorCode>;
|
|
6
|
-
options: Required<NumberFormattingOptions> & Required<ParseLatexOptions> & Required<SerializeLatexOptions>;
|
|
7
|
-
private dictionary;
|
|
8
|
-
constructor(options?: NumberFormattingOptions & ParseLatexOptions & SerializeLatexOptions & {
|
|
9
|
-
dictionary?: readonly LatexDictionaryEntry<T>[];
|
|
10
|
-
onError?: ErrorListener<ErrorCode>;
|
|
11
|
-
});
|
|
12
|
-
static getDictionary(domain?: DictionaryCategory | 'all'): Readonly<LatexDictionary<any>>;
|
|
13
|
-
parse(latex: LatexString): Expression;
|
|
14
|
-
serialize(expr: Expression<T>): LatexString;
|
|
15
|
-
}
|
|
16
|
-
export declare function parse<T extends number = Numeric>(latex: LatexString, options?: NumberFormattingOptions & ParseLatexOptions & {
|
|
17
|
-
dictionary?: Readonly<LatexDictionary<T>>;
|
|
18
|
-
onError?: ErrorListener<ErrorCode>;
|
|
19
|
-
}): Expression;
|
|
20
|
-
/**
|
|
21
|
-
* Serialize a MathJSON expression as a Latex string.
|
|
22
|
-
*
|
|
23
|
-
*/
|
|
24
|
-
export declare function serialize<T extends number = number>(expr: Expression<T>, options?: NumberFormattingOptions & SerializeLatexOptions & {
|
|
25
|
-
dictionary?: Readonly<LatexDictionary<T>>;
|
|
26
|
-
onError?: ErrorListener<ErrorCode>;
|
|
27
|
-
}): LatexString;
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
/* 0.4.0 */
|
|
2
|
-
import { ParseLatexOptions, LatexDictionaryEntry, LatexToken, NumberFormattingOptions } from './public';
|
|
3
|
-
import { IndexedLatexDictionary } from './definitions';
|
|
4
|
-
export declare class Scanner<T extends number = number> implements Scanner<T> {
|
|
5
|
-
index: number;
|
|
6
|
-
readonly tokens: LatexToken[];
|
|
7
|
-
readonly onError: ErrorListener<ErrorCode>;
|
|
8
|
-
readonly dictionary: IndexedLatexDictionary<T>;
|
|
9
|
-
readonly options: Required<NumberFormattingOptions> & Required<ParseLatexOptions>;
|
|
10
|
-
private invisibleOperatorPrecedence;
|
|
11
|
-
constructor(tokens: LatexToken[], options: Required<NumberFormattingOptions> & Required<ParseLatexOptions>, dictionary: IndexedLatexDictionary<T>, onError: ErrorListener<ErrorCode>);
|
|
12
|
-
clone(start: number, end: number): Scanner<T>;
|
|
13
|
-
balancedClone(open: LatexToken | LatexToken[], close: LatexToken | LatexToken[], silentError?: boolean): Scanner<T> | null;
|
|
14
|
-
get atEnd(): boolean;
|
|
15
|
-
get peek(): LatexToken;
|
|
16
|
-
latex(start: number, end?: number): string;
|
|
17
|
-
latexAhead(n: number): string;
|
|
18
|
-
latexBefore(): string;
|
|
19
|
-
latexAfter(): string;
|
|
20
|
-
/**
|
|
21
|
-
* Return at most `maxLookahead` strings made from the tokens
|
|
22
|
-
* ahead.
|
|
23
|
-
*
|
|
24
|
-
* The index in the returned array correspond to the number of tokens.
|
|
25
|
-
* Note that since a token can be longer than one char ('\\pi', but also
|
|
26
|
-
* some astral plane unicode characters), the length of the string
|
|
27
|
-
* does not match that index. However, knowing the index is important
|
|
28
|
-
* to know by how many tokens to advance.
|
|
29
|
-
*
|
|
30
|
-
*/
|
|
31
|
-
lookAhead(): string[];
|
|
32
|
-
peekDefinition(kind: 'symbol' | 'infix' | 'matchfix' | 'prefix' | 'postfix' | 'superfix' | 'subfix' | 'operator'): [LatexDictionaryEntry<T> | null, number];
|
|
33
|
-
next(): LatexToken;
|
|
34
|
-
skipSpace(): boolean;
|
|
35
|
-
match(target: LatexToken): boolean;
|
|
36
|
-
matchAll(target: LatexToken | LatexToken[]): boolean;
|
|
37
|
-
matchAny(targets: LatexToken[]): LatexToken;
|
|
38
|
-
matchWhile(targets: LatexToken[]): LatexToken[];
|
|
39
|
-
matchSign(): string;
|
|
40
|
-
matchDecimalDigits(): string;
|
|
41
|
-
matchSignedInteger(): string;
|
|
42
|
-
matchExponent(): string;
|
|
43
|
-
matchNumber(): string;
|
|
44
|
-
matchOperator(kind: 'infix' | 'prefix' | 'postfix', lhs?: Expression<T> | null, minPrec?: number): Expression<T> | null;
|
|
45
|
-
matchArguments(kind: undefined | '' | 'group' | 'implicit'): Expression<T>[] | null;
|
|
46
|
-
matchMatchfixOperator(): Expression<T> | null;
|
|
47
|
-
matchDefinition(kind: 'symbol' | 'infix' | 'matchfix' | 'prefix' | 'postfix' | 'superfix' | 'subfix' | 'operator'): [LatexDictionaryEntry<T> | null, Expression<T> | null];
|
|
48
|
-
/**
|
|
49
|
-
* A symbol can be:
|
|
50
|
-
* - a constant: `\pi`
|
|
51
|
-
* - a variable: `x`
|
|
52
|
-
* - a function with explicit arguments `f(x)`
|
|
53
|
-
* - a function with implicit arguments: `\cos x`
|
|
54
|
-
* - a command: `\frac{2}{3}`
|
|
55
|
-
*/
|
|
56
|
-
matchSymbol(): Expression<T> | null;
|
|
57
|
-
matchOptionalLatexArgument(): Expression<T> | null;
|
|
58
|
-
/**
|
|
59
|
-
* Match a required latex argument:
|
|
60
|
-
* - either enclosed in `{}`
|
|
61
|
-
* - or a single token.
|
|
62
|
-
*
|
|
63
|
-
* Return null if an argument was not found
|
|
64
|
-
* Return '' if an empty argument `{}` was found
|
|
65
|
-
*/
|
|
66
|
-
matchRequiredLatexArgument(): Expression<T> | null;
|
|
67
|
-
/**
|
|
68
|
-
* Match a superfix/subfix operator, e.g. `^{*}`
|
|
69
|
-
*/
|
|
70
|
-
matchSupsub(lhs: Expression<T> | null): Expression<T> | null;
|
|
71
|
-
matchPostfix(lhs: Expression<T> | null): Expression<T> | null;
|
|
72
|
-
matchString(): string;
|
|
73
|
-
matchEnvironmentName(command: '\\begin' | '\\end', envName: string): boolean;
|
|
74
|
-
/**
|
|
75
|
-
* Match an expression in a tabular format,
|
|
76
|
-
* where row are separated by `\\` and columns by `&`
|
|
77
|
-
*
|
|
78
|
-
* Return rows of sparse columns as a list: empty rows are indicated with NOTHING,
|
|
79
|
-
* and empty cells are also indicated with NOTHING.
|
|
80
|
-
*/
|
|
81
|
-
matchTabular(): null | Expression<T>;
|
|
82
|
-
matchEnvironment(): Expression<T> | null;
|
|
83
|
-
/**
|
|
84
|
-
* Apply the operator `op` to the left-hand-side and right-hand-side
|
|
85
|
-
* expression. Applies the associativity rule specified by the definition,
|
|
86
|
-
* i.e. 'op(a, op(b, c))` -> `op(a, b, c)`, etc...
|
|
87
|
-
*
|
|
88
|
-
* `op` is the name of the operator which should have a corresponding
|
|
89
|
-
* definition.
|
|
90
|
-
*
|
|
91
|
-
* If `op` is an infix operator, it should have both a lhs and rhs.
|
|
92
|
-
* If `op` is a postfix operator, it should only have a lhs.
|
|
93
|
-
* If `op` is a prefix operator, the lhs is returned as the first element
|
|
94
|
-
* of the return tuple.
|
|
95
|
-
*
|
|
96
|
-
* @return a tuple: [lhs, rhs]
|
|
97
|
-
*/
|
|
98
|
-
applyOperator(op: string, lhs: Expression<T> | null, rhs: Expression<T> | null): NonNullable<[Expression<T> | null, Expression<T> | null]>;
|
|
99
|
-
/**
|
|
100
|
-
* Apply an invisible operator between two expressions.
|
|
101
|
-
*
|
|
102
|
-
* If no `invisibleOperator` was specified, use the `latex` operator.
|
|
103
|
-
*
|
|
104
|
-
* If the lhs is a number and the rhs is a fraction of integers,
|
|
105
|
-
* assume an 'invisible plus', that is '2 3/4' -> ['add', 2, [divide, 3, 4]]
|
|
106
|
-
* unless `invisiblePlusOperator` is empty
|
|
107
|
-
*
|
|
108
|
-
*/
|
|
109
|
-
applyInvisibleOperator(lhs: Expression<T> | null, rhs: Expression<T> | null): Expression<T> | null;
|
|
110
|
-
matchUnknownLatexCommand(): Expression<T> | null;
|
|
111
|
-
/**
|
|
112
|
-
* <primary> :=
|
|
113
|
-
* (<number> | <symbol> | <environment> | <matchfix-expr>) <subsup>* <postfix-operator>*
|
|
114
|
-
*
|
|
115
|
-
* <symbol> ::= (<symbol-id> | (<latex-command><latex-arguments>)) <arguments>
|
|
116
|
-
*
|
|
117
|
-
* <matchfix-expr> :=
|
|
118
|
-
* <matchfix-op-open> <expression> [<matchfix-op-separator> <expression>] <matchfix-op-close>
|
|
119
|
-
*
|
|
120
|
-
*/
|
|
121
|
-
matchPrimary(_minPrec?: number): Expression<T> | null;
|
|
122
|
-
matchBalancedExpression(open: LatexToken | LatexToken[], close: LatexToken | LatexToken[], onError?: ErrorListener<ErrorCode>): Expression<T> | null;
|
|
123
|
-
/**
|
|
124
|
-
* Parse an expression:
|
|
125
|
-
*
|
|
126
|
-
* <expression> ::=
|
|
127
|
-
* | <primary>
|
|
128
|
-
* | <prefix-op> <primary>
|
|
129
|
-
* | <primary> <infix-op> <expression>
|
|
130
|
-
*
|
|
131
|
-
* Stop when an operator of precedence less than `minPrec` is encountered
|
|
132
|
-
*/
|
|
133
|
-
matchExpression(minPrec?: number): Expression<T> | null;
|
|
134
|
-
/**
|
|
135
|
-
* Add latex or other requested metadata to the expression
|
|
136
|
-
*/
|
|
137
|
-
decorate(expr: Expression<T> | null, start: number): Expression<T> | null;
|
|
138
|
-
}
|