@cortex-js/compute-engine 0.4.1 → 0.4.4
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 +4 -5
- package/dist/compute-engine.esm.js +22496 -16245
- package/dist/compute-engine.min.esm.js +2 -7
- package/dist/compute-engine.min.js +2 -7
- package/dist/math-json.esm.js +4338 -10523
- 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 -6
- 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 +53 -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 +238 -97
- 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 +1 -1
- package/dist/types/compute-engine/dictionary/core.d.ts +2 -2
- package/dist/types/compute-engine/dictionary/dictionary.d.ts +18 -11
- package/dist/types/compute-engine/dictionary/logic.d.ts +1 -1
- 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 +1 -1
- package/dist/types/compute-engine/dictionary/trigonometry.d.ts +2 -2
- 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 +4 -5
- 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 +1109 -434
- package/dist/types/compute-engine/rules.d.ts +16 -6
- 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 -5
- 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 +29 -29
- package/dist/compute-engine.js +0 -17296
- package/dist/cortex.esm.js +0 -20989
- package/dist/cortex.js +0 -21011
- package/dist/cortex.min.esm.js +0 -7
- package/dist/cortex.min.js +0 -7
- package/dist/math-json.js +0 -12517
- package/dist/types/common/debug.d.ts +0 -28
- package/dist/types/common/utils.d.ts +0 -153
- package/dist/types/compute-engine/canonical-forms.d.ts +0 -74
- package/dist/types/compute-engine/dictionary/domains.d.ts +0 -26
- package/dist/types/compute-engine/dictionary/utils.d.ts +0 -5
- package/dist/types/compute-engine/domains.d.ts +0 -4
- package/dist/types/compute-engine/evaluate.d.ts +0 -13
- package/dist/types/compute-engine/expression-map.d.ts +0 -11
- package/dist/types/compute-engine/internal-compute-engine.d.ts +0 -108
- 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/numerical-eval.d.ts +0 -5
- package/dist/types/compute-engine/order.d.ts +0 -18
- 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/simplify.d.ts +0 -6
- package/dist/types/compute-engine/utils.d.ts +0 -15
- package/dist/types/cortex/formatter.d.ts +0 -165
- package/dist/types/cortex/parse-cortex.d.ts +0 -5
- package/dist/types/cortex/reserved-words.d.ts +0 -1
- package/dist/types/cortex/serialize-cortex.d.ts +0 -14
- package/dist/types/cortex.d.ts +0 -8
- 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 -456
- package/dist/types/latex-syntax/serializer.d.ts +0 -26
- package/dist/types/latex-syntax/utils.d.ts +0 -10
- package/dist/types/point-free-parser/characters.d.ts +0 -25
- package/dist/types/point-free-parser/combinators.d.ts +0 -46
- package/dist/types/point-free-parser/core-combinators.d.ts +0 -78
- package/dist/types/point-free-parser/grammar.d.ts +0 -12
- package/dist/types/point-free-parser/identifier-parsers.d.ts +0 -7
- package/dist/types/point-free-parser/numeric-parsers.d.ts +0 -8
- package/dist/types/point-free-parser/parsers.d.ts +0 -130
- package/dist/types/point-free-parser/string-parsers.d.ts +0 -29
- package/dist/types/point-free-parser/whitespace-parsers.d.ts +0 -17
- package/dist/types/public.d.ts +0 -163
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/* 0.4.1 */
|
|
2
|
-
export declare type Terminal = {
|
|
3
|
-
joinLines(lines: string[]): string;
|
|
4
|
-
grey(s: string): string;
|
|
5
|
-
red(s: string): string;
|
|
6
|
-
highlightBackground(s: string): string;
|
|
7
|
-
};
|
|
8
|
-
export declare const colorTerminal: Terminal;
|
|
9
|
-
export declare class Origin {
|
|
10
|
-
url: string;
|
|
11
|
-
source: string;
|
|
12
|
-
_lines: string[];
|
|
13
|
-
_lineOffsets: number[];
|
|
14
|
-
constructor(source: string, url?: string);
|
|
15
|
-
get lines(): string[];
|
|
16
|
-
get lineOffsets(): number[];
|
|
17
|
-
getLinecol(offset: number): [line: number, col: number];
|
|
18
|
-
signalOrigin(offset: number): SignalOrigin;
|
|
19
|
-
chalkGutter(s: string): string;
|
|
20
|
-
chalkMarker(s: string): string;
|
|
21
|
-
chalkMessage(s: string): string;
|
|
22
|
-
/** line: 1..., column: 1... */
|
|
23
|
-
sourceAround(line: number, column: number, message?: string): string;
|
|
24
|
-
}
|
|
25
|
-
/** Word-wrap a string that contains ANSI escape sequences.
|
|
26
|
-
* ANSI escape sequences do not add to the string length.
|
|
27
|
-
*/
|
|
28
|
-
export declare const wrapAnsiString: (string: string, terminalWidth: number) => string;
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
/* 0.4.1 */
|
|
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,74 +0,0 @@
|
|
|
1
|
-
/* 0.4.1 */
|
|
2
|
-
import { Form, ComputeEngine } from './public';
|
|
3
|
-
export declare function canonicalNumberForm(expr: Expression, engine: ComputeEngine): Expression;
|
|
4
|
-
/**
|
|
5
|
-
* Transform the expression so that object literals for numbers, symbols and
|
|
6
|
-
* functions are used only when necessary, i.e. when they have associated
|
|
7
|
-
* metadata attributes. Otherwise, use a plain number, string or array
|
|
8
|
-
*
|
|
9
|
-
* For example:
|
|
10
|
-
*
|
|
11
|
-
* ```
|
|
12
|
-
* {num: 2} -> 2
|
|
13
|
-
* {sym: "x"} -> "x"
|
|
14
|
-
* {fn:['add', {num: 1}, {sym: "x"}]} -> ['add', 1, "x"]
|
|
15
|
-
* ```
|
|
16
|
-
*
|
|
17
|
-
*/
|
|
18
|
-
export declare function jsonForm(expr: Expression | null, engine: ComputeEngine): Expression | null;
|
|
19
|
-
export declare function strippedMetadataForm(expr: Expression | null, engine: ComputeEngine): Expression | null;
|
|
20
|
-
export declare function objectLiteralForm(expr: Expression, engine: ComputeEngine): Expression;
|
|
21
|
-
/**
|
|
22
|
-
* Transform the expression so that the arguments of functions that have the
|
|
23
|
-
* `isCommutative` attributes are ordered as follow:
|
|
24
|
-
*
|
|
25
|
-
* - Real numbers
|
|
26
|
-
* - Complex numbers
|
|
27
|
-
* - Symbols
|
|
28
|
-
* - Functions
|
|
29
|
-
*
|
|
30
|
-
* Within Real Numbers:
|
|
31
|
-
* - by their value
|
|
32
|
-
*
|
|
33
|
-
* Within Complex numbers:
|
|
34
|
-
* - by the value of their imaginary component,
|
|
35
|
-
* - then by the value of their real component
|
|
36
|
-
*
|
|
37
|
-
* Within Symbols:
|
|
38
|
-
* - constants (`isConstant === true`) before non-constants
|
|
39
|
-
* - then alphabetically
|
|
40
|
-
*
|
|
41
|
-
* Within Functions:
|
|
42
|
-
* - if a `[MULTIPLY]` or a `[POWER]`... @todo
|
|
43
|
-
*
|
|
44
|
-
*/
|
|
45
|
-
export declare function sortedForm(expr: Expression, engine: ComputeEngine): Expression;
|
|
46
|
-
/**
|
|
47
|
-
* Return the expression in canonical form:
|
|
48
|
-
*
|
|
49
|
-
* - `"divide"`, `"exp"`,` `"subtract"`, `"root"`, `"exp"` replaced with
|
|
50
|
-
* `"add"`, `"multiply"`, "`power"`
|
|
51
|
-
* - some trivial simplifications (multiply by 1, addition of 0, division by 1)
|
|
52
|
-
* - terms sorted
|
|
53
|
-
*
|
|
54
|
-
*/
|
|
55
|
-
export declare function canonicalForm(expr: Expression | null, engine: ComputeEngine): Expression | null;
|
|
56
|
-
/**
|
|
57
|
-
* Return a string escaped as necessary to comply with the JSON format
|
|
58
|
-
*
|
|
59
|
-
*/
|
|
60
|
-
export declare function escapeText(s: string): string;
|
|
61
|
-
/**
|
|
62
|
-
* Transform an expression by applying one or more rewriting rules to it,
|
|
63
|
-
* recursively.
|
|
64
|
-
*
|
|
65
|
-
* There are many ways to symbolically manipulate an expression, but
|
|
66
|
-
* transformations with `form` have the following characteristics:
|
|
67
|
-
*
|
|
68
|
-
* - they don't require calculations or assumptions about the domain of free
|
|
69
|
-
* variables or the value of constants
|
|
70
|
-
* - the output expression is expressed with more primitive functions,
|
|
71
|
-
* for example subtraction is replaced with addition
|
|
72
|
-
*
|
|
73
|
-
*/
|
|
74
|
-
export declare function format(engine: ComputeEngine, expr: Expression | null, forms: Form[]): Expression | null;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/* 0.4.1 */
|
|
2
|
-
import { ComputeEngine, Dictionary, Domain } from '../public';
|
|
3
|
-
/**
|
|
4
|
-
* The set of domains form a lattice with 'Anything' at the top and 'Nothing'
|
|
5
|
-
* at the bottom.
|
|
6
|
-
*
|
|
7
|
-
* The DOMAIN_PARENT table represents this lattice by indicating the parent(s)
|
|
8
|
-
* for each domain.
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* These synonyms are shortcuts that get normalized to their definition.
|
|
12
|
-
*/
|
|
13
|
-
export declare const DOMAIN_SYNONYMS: {
|
|
14
|
-
[synonym: string]: Expression;
|
|
15
|
-
};
|
|
16
|
-
export declare function getDomainsDictionary(): Dictionary;
|
|
17
|
-
/**
|
|
18
|
-
* Check the domains of the entries in a dictionary for logical consistency
|
|
19
|
-
*
|
|
20
|
-
*/
|
|
21
|
-
/**
|
|
22
|
-
* Return a simplified form of the domain
|
|
23
|
-
*
|
|
24
|
-
*/
|
|
25
|
-
export declare function simplifyDomain(dom: Domain, _engine: ComputeEngine): Domain;
|
|
26
|
-
export declare function canonicalDomain(engine: ComputeEngine, expr: Expression): Expression;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/* 0.4.1 */
|
|
2
|
-
export declare function isSetDefinition(def: number | Definition<any> | undefined | null): def is SetDefinition<Numeric>;
|
|
3
|
-
export declare function isSymbolDefinition(def: number | Definition<any> | undefined | null): def is SymbolDefinition<Numeric>;
|
|
4
|
-
export declare function isFunctionDefinition(def: number | Definition<any> | undefined | null): def is FunctionDefinition<Numeric>;
|
|
5
|
-
export declare function isCollectionDefinition(def: number | Definition<any> | undefined | null): def is CollectionDefinition<Numeric>;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/* 0.4.1 */
|
|
2
|
-
import { ComputeEngine } from './public';
|
|
3
|
-
export declare function evaluateOnce(engine: ComputeEngine, expr: Expression | null): Expression | null;
|
|
4
|
-
/**
|
|
5
|
-
* Evaluate until:
|
|
6
|
-
* - the timeLimit is reached
|
|
7
|
-
* - the iterationLimit is reached
|
|
8
|
-
* - the expression stops changing
|
|
9
|
-
*/
|
|
10
|
-
export declare function internalEvaluate(engine: ComputeEngine, expr: Expression, options?: {
|
|
11
|
-
timeLimit?: number;
|
|
12
|
-
iterationLimit?: number;
|
|
13
|
-
}): Promise<Expression | null>;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/* 0.4.1 */
|
|
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,108 +0,0 @@
|
|
|
1
|
-
/* 0.4.1 */
|
|
2
|
-
import { CollectionDefinition, ComputeEngine, Definition, Dictionary, Domain, Form, FunctionDefinition, Numeric, NumericFormat, RuleSet, RuntimeScope, Scope, SetDefinition, Simplification, SymbolDefinition } from './public';
|
|
3
|
-
import { ExpressionMap } from './expression-map';
|
|
4
|
-
import { LatexSyntax } from '../latex-syntax/latex-syntax';
|
|
5
|
-
/**
|
|
6
|
-
* The internal compute engine implements the ComputeEngine interface
|
|
7
|
-
* but does not:
|
|
8
|
-
* - account for time limits
|
|
9
|
-
* - account for iteration limits
|
|
10
|
-
* - apply a canonical form
|
|
11
|
-
*
|
|
12
|
-
* It is used for recursive calls, and by the "top-level" `ComputeEngine`.
|
|
13
|
-
*/
|
|
14
|
-
export declare class InternalComputeEngine implements ComputeEngine<Numeric> {
|
|
15
|
-
static getDictionaries(categories?: DictionaryCategory[] | 'all'): Readonly<Dictionary<Numeric>>[];
|
|
16
|
-
private _precision;
|
|
17
|
-
private _numericFormat;
|
|
18
|
-
private _latexSyntax?;
|
|
19
|
-
private _tolerance;
|
|
20
|
-
private _rules?;
|
|
21
|
-
/**
|
|
22
|
-
* The current scope.
|
|
23
|
-
*
|
|
24
|
-
* A scope is a dictionary that contains the definition of local symbols.
|
|
25
|
-
*
|
|
26
|
-
* Scopes form a stack, and definitions in more recent
|
|
27
|
-
* scopes can obscure definitions from older scopes.
|
|
28
|
-
*
|
|
29
|
-
*/
|
|
30
|
-
context: RuntimeScope<Numeric>;
|
|
31
|
-
/** Absolute time beyond which evaluation should not proceed */
|
|
32
|
-
deadline?: number;
|
|
33
|
-
constructor(options?: {
|
|
34
|
-
dictionaries?: Readonly<Dictionary<Numeric>>[];
|
|
35
|
-
});
|
|
36
|
-
get precision(): number;
|
|
37
|
-
set precision(p: number | 'machine');
|
|
38
|
-
get numericFormat(): NumericFormat;
|
|
39
|
-
set numericFormat(f: NumericFormat);
|
|
40
|
-
get tolerance(): number;
|
|
41
|
-
set tolerance(val: number);
|
|
42
|
-
/** Generator function (indicated by the leading '*') that returns all the
|
|
43
|
-
* rules in all the topics requested.
|
|
44
|
-
*/
|
|
45
|
-
getRules(topics: string | string[]): RuleSet;
|
|
46
|
-
get latexSyntax(): LatexSyntax;
|
|
47
|
-
pushScope(dictionary: Readonly<Dictionary<Numeric>>, scope?: Partial<Scope>): void;
|
|
48
|
-
popScope(): void;
|
|
49
|
-
get assumptions(): ExpressionMap<Numeric, boolean>;
|
|
50
|
-
signal(_sig: ErrorSignal | WarningSignal): void;
|
|
51
|
-
get timeLimit(): undefined | number;
|
|
52
|
-
get recursionLimit(): undefined | number;
|
|
53
|
-
get iterationLimit(): undefined | number;
|
|
54
|
-
shouldContinueExecution(): boolean;
|
|
55
|
-
checkContinueExecution(): void;
|
|
56
|
-
getFunctionDefinition(name: string): FunctionDefinition | null;
|
|
57
|
-
getSymbolDefinition(name: string): SymbolDefinition<Numeric> | null;
|
|
58
|
-
getSetDefinition(name: string): SetDefinition<Numeric> | null;
|
|
59
|
-
getCollectionDefinition(name: string): CollectionDefinition<Numeric> | null;
|
|
60
|
-
getDefinition(name: string): Definition<Numeric> | null;
|
|
61
|
-
canonical(expr: Expression | null): Expression | null;
|
|
62
|
-
format(expr: Expression | null, forms?: Form | Form[]): Expression | null;
|
|
63
|
-
evaluate(expr: Expression, options?: {
|
|
64
|
-
timeLimit?: number;
|
|
65
|
-
iterationLimit?: number;
|
|
66
|
-
}): Promise<Expression | null>;
|
|
67
|
-
simplify(expr: Expression, options?: {
|
|
68
|
-
simplifications?: Simplification[];
|
|
69
|
-
}): Expression | null;
|
|
70
|
-
N(expr: Expression, options?: {
|
|
71
|
-
precision?: number;
|
|
72
|
-
}): Expression | null;
|
|
73
|
-
is(arg1: Expression, arg2?: Domain): boolean | undefined;
|
|
74
|
-
ask(pattern: Expression): {
|
|
75
|
-
[symbol: string]: Expression;
|
|
76
|
-
}[];
|
|
77
|
-
assume(arg1: Expression, arg2?: Domain): 'contradiction' | 'tautology' | 'ok';
|
|
78
|
-
replace(rules: RuleSet, expr: Expression<Numeric>): Expression<Numeric>;
|
|
79
|
-
domain(expr: Expression): Domain | null;
|
|
80
|
-
getVars(expr: Expression): Set<string>;
|
|
81
|
-
chop(n: Numeric): Numeric;
|
|
82
|
-
parse(s: string): Expression;
|
|
83
|
-
serialize(x: Expression): string;
|
|
84
|
-
isZero(x: Expression): boolean | undefined;
|
|
85
|
-
isNotZero(x: Expression): boolean | undefined;
|
|
86
|
-
isNumeric(x: Expression): boolean | undefined;
|
|
87
|
-
isInfinity(x: Expression): boolean | undefined;
|
|
88
|
-
isFinite(x: Expression): boolean | undefined;
|
|
89
|
-
isNonNegative(x: Expression): boolean | undefined;
|
|
90
|
-
isPositive(x: Expression): boolean | undefined;
|
|
91
|
-
isNegative(x: Expression): boolean | undefined;
|
|
92
|
-
isNonPositive(x: Expression): boolean | undefined;
|
|
93
|
-
isInteger(x: Expression): boolean | undefined;
|
|
94
|
-
isRational(x: Expression): boolean | undefined;
|
|
95
|
-
isAlgebraic(x: Expression): boolean | undefined;
|
|
96
|
-
isReal(x: Expression): boolean | undefined;
|
|
97
|
-
isExtendedReal(x: Expression): boolean | undefined;
|
|
98
|
-
isComplex(x: Expression): boolean | undefined;
|
|
99
|
-
isOne(x: Expression): boolean | undefined;
|
|
100
|
-
isNegativeOne(x: Expression): boolean | undefined;
|
|
101
|
-
isElement(x: Expression, set: Expression): boolean | undefined;
|
|
102
|
-
isSubsetOf(lhs: Domain | null, rhs: Domain | null): boolean;
|
|
103
|
-
isEqual(lhs: Expression, rhs: Expression): boolean | undefined;
|
|
104
|
-
isLess(lhs: Expression, rhs: Expression): boolean | undefined;
|
|
105
|
-
isLessEqual(lhs: Expression, rhs: Expression): boolean | undefined;
|
|
106
|
-
isGreater(lhs: Expression, rhs: Expression): boolean | undefined;
|
|
107
|
-
isGreaterEqual(lhs: Expression, rhs: Expression): boolean | undefined;
|
|
108
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/* 0.4.1 */
|
|
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.1 */
|
|
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,18 +0,0 @@
|
|
|
1
|
-
/* 0.4.1 */
|
|
2
|
-
import { ComputeEngine } from './public';
|
|
3
|
-
export declare function order(a: Expression, b: Expression): number;
|
|
4
|
-
/**
|
|
5
|
-
* Return the (total) degree of the term
|
|
6
|
-
*/
|
|
7
|
-
export declare function degree(expr: Expression, sortedVars: string[]): number;
|
|
8
|
-
/**
|
|
9
|
-
* The deglex order is used for sum of factors:
|
|
10
|
-
* - first by total degree of each factor
|
|
11
|
-
* - then lexicographically for each variable
|
|
12
|
-
* - then lexicographically for other symbols
|
|
13
|
-
* - then by length
|
|
14
|
-
* - then by value
|
|
15
|
-
*
|
|
16
|
-
*/
|
|
17
|
-
export declare function deglex(a: Expression, b: Expression, sortedVars: string[]): number;
|
|
18
|
-
export declare function canonicalOrder(engine: ComputeEngine, sortedVars: string[], expr: Expression): Expression;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/* 0.4.1 */
|
|
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.1 */
|
|
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,6 +0,0 @@
|
|
|
1
|
-
/* 0.4.1 */
|
|
2
|
-
import { ComputeEngine, Rule, Simplification } from './public';
|
|
3
|
-
export declare const SIMPLIFY_RULES: {
|
|
4
|
-
[topic: string]: Rule[];
|
|
5
|
-
};
|
|
6
|
-
export declare function internalSimplify(engine: ComputeEngine, expr: Expression | null, simplifications?: Simplification[]): Expression | null;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/* 0.4.1 */
|
|
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;
|