@cortex-js/compute-engine 0.12.4 → 0.12.6
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 +916 -782
- package/dist/compute-engine.js +916 -782
- package/dist/compute-engine.min.esm.js +916 -782
- package/dist/compute-engine.min.js +916 -782
- package/dist/math-json.esm.js +2 -2
- package/dist/math-json.js +2 -2
- package/dist/math-json.min.esm.js +2 -2
- package/dist/math-json.min.js +2 -2
- 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 +1 -1
- package/dist/types/compute-engine/boxed-expression/box.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-domain.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-function-definition.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +2 -2
- package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +1 -1
- 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 +1 -1
- package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/order.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/serialize.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/utils.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/validate.d.ts +1 -1
- package/dist/types/compute-engine/compute-engine.d.ts +8 -6
- package/dist/types/compute-engine/cost-function.d.ts +1 -1
- package/dist/types/compute-engine/domain-utils.d.ts +1 -1
- 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-core.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-inequalities.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-sets.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 +14 -9
- package/dist/types/compute-engine/latex-syntax/latex-syntax.d.ts +2 -2
- package/dist/types/compute-engine/latex-syntax/parse-identifier.d.ts +2 -2
- package/dist/types/compute-engine/latex-syntax/parse.d.ts +102 -75
- package/dist/types/compute-engine/latex-syntax/public.d.ts +138 -136
- package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/serializer.d.ts +4 -4
- package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +1 -1
- package/dist/types/compute-engine/library/arithmetic-add.d.ts +1 -1
- package/dist/types/compute-engine/library/arithmetic-divide.d.ts +1 -1
- package/dist/types/compute-engine/library/arithmetic-multiply.d.ts +1 -1
- package/dist/types/compute-engine/library/arithmetic-power.d.ts +1 -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/core.d.ts +1 -1
- package/dist/types/compute-engine/library/domains.d.ts +2 -1
- package/dist/types/compute-engine/library/library.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 -1
- package/dist/types/compute-engine/library/sets.d.ts +1 -1
- package/dist/types/compute-engine/library/trigonometry.d.ts +1 -1
- package/dist/types/compute-engine/library/utils.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric-bigint.d.ts +1 -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 +1 -1
- package/dist/types/compute-engine/numerics/primes.d.ts +1 -1
- package/dist/types/compute-engine/numerics/rationals.d.ts +1 -1
- package/dist/types/compute-engine/public.d.ts +102 -5
- 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 +1 -1
- package/dist/types/compute-engine/symbolic/expand.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/flatten.d.ts +1 -1
- 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 +1 -1
- package/dist/types/compute-engine/symbolic/sum.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/utils.d.ts +1 -1
- package/dist/types/compute-engine.d.ts +2 -2
- package/dist/types/math-json/math-json-format.d.ts +1 -1
- package/dist/types/math-json/utils.d.ts +2 -1
- package/dist/types/math-json.d.ts +2 -2
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/* 0.12.
|
|
2
|
-
import { IndexedLatexDictionary, IndexedInfixEntry, IndexedPostfixEntry, IndexedPrefixEntry,
|
|
1
|
+
/* 0.12.6 */
|
|
2
|
+
import { IndexedLatexDictionary, IndexedInfixEntry, IndexedPostfixEntry, IndexedPrefixEntry, IndexedSymbolEntry, IndexedExpressionEntry } from './dictionary/definitions';
|
|
3
3
|
import { IComputeEngine } from '../public';
|
|
4
4
|
import { Expression } from '../../math-json/math-json-format';
|
|
5
5
|
export declare const DEFAULT_LATEX_NUMBER_OPTIONS: NumberFormattingOptions;
|
|
@@ -8,7 +8,7 @@ export declare class _Parser implements Parser {
|
|
|
8
8
|
readonly computeEngine: IComputeEngine;
|
|
9
9
|
readonly options: NumberFormattingOptions & ParseLatexOptions;
|
|
10
10
|
index: number;
|
|
11
|
-
private
|
|
11
|
+
private _tokens;
|
|
12
12
|
private _positiveInfinityTokens;
|
|
13
13
|
private _negativeInfinityTokens;
|
|
14
14
|
private _notANumberTokens;
|
|
@@ -29,7 +29,7 @@ export declare class _Parser implements Parser {
|
|
|
29
29
|
updateOptions(opt: Partial<NumberFormattingOptions> & Partial<ParseLatexOptions>): void;
|
|
30
30
|
get atEnd(): boolean;
|
|
31
31
|
get peek(): LatexToken;
|
|
32
|
-
|
|
32
|
+
nextToken(): LatexToken;
|
|
33
33
|
/**
|
|
34
34
|
* Return true if
|
|
35
35
|
* - at end of the token stream
|
|
@@ -44,12 +44,9 @@ export declare class _Parser implements Parser {
|
|
|
44
44
|
matchBoundary(): boolean;
|
|
45
45
|
boundaryError(msg: string | [string, ...Expression[]]): Expression;
|
|
46
46
|
latex(start: number, end?: number): string;
|
|
47
|
-
latexAhead
|
|
48
|
-
latexBefore(): string;
|
|
49
|
-
latexAfter(): string;
|
|
47
|
+
private latexAhead;
|
|
50
48
|
/**
|
|
51
|
-
* Return at most `this._dictionary.lookahead`
|
|
52
|
-
* ahead.
|
|
49
|
+
* Return at most `this._dictionary.lookahead` LaTeX tokens.
|
|
53
50
|
*
|
|
54
51
|
* The index in the returned array correspond to the number of tokens.
|
|
55
52
|
* Note that since a token can be longer than one char ('\\pi', but also
|
|
@@ -57,11 +54,16 @@ export declare class _Parser implements Parser {
|
|
|
57
54
|
* does not match that index. However, knowing the index is important
|
|
58
55
|
* to know by how many tokens to advance.
|
|
59
56
|
*
|
|
57
|
+
* For example:
|
|
58
|
+
*
|
|
59
|
+
* `[empty, '\\sqrt', '\\sqrt{', '\\sqrt{2', '\\sqrt{2}']`
|
|
60
|
+
*
|
|
60
61
|
*/
|
|
61
62
|
lookAhead(): string[];
|
|
62
63
|
/** Return all the definitions that potentially match the tokens ahead */
|
|
64
|
+
peekDefinitions(kind: 'expression'): [IndexedExpressionEntry, number][] | null;
|
|
63
65
|
peekDefinitions(kind: 'function'): [FunctionEntry, number][] | null;
|
|
64
|
-
peekDefinitions(kind: '
|
|
66
|
+
peekDefinitions(kind: 'symbol'): [IndexedSymbolEntry, number][] | null;
|
|
65
67
|
peekDefinitions(kind: 'postfix'): [IndexedPostfixEntry, number][] | null;
|
|
66
68
|
peekDefinitions(kind: 'infix'): [IndexedInfixEntry, number][] | null;
|
|
67
69
|
peekDefinitions(kind: 'prefix'): [IndexedPrefixEntry, number][] | null;
|
|
@@ -77,23 +79,38 @@ export declare class _Parser implements Parser {
|
|
|
77
79
|
*/
|
|
78
80
|
skipSpace(): boolean;
|
|
79
81
|
skipVisualSpace(): void;
|
|
80
|
-
matchChar(): string | null;
|
|
81
|
-
matchColor(_background?: boolean): string | null;
|
|
82
|
-
matchLatexDimension(): string | null;
|
|
83
82
|
match(token: LatexToken): boolean;
|
|
84
|
-
matchAll(tokens: LatexToken
|
|
83
|
+
matchAll(tokens: LatexToken[]): boolean;
|
|
85
84
|
matchAny(tokens: LatexToken[]): LatexToken;
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
85
|
+
matchChar(): string | null;
|
|
86
|
+
parseGroup(): Expression | null;
|
|
87
|
+
parseToken(): Expression | null;
|
|
88
|
+
parseOptionalGroup(): Expression | null;
|
|
89
|
+
/**
|
|
90
|
+
* Parse an expression in a tabular format, where rows are separated by `\\`
|
|
91
|
+
* and columns by `&`.
|
|
92
|
+
*
|
|
93
|
+
* Return rows of sparse columns: empty rows are indicated with `Nothing`,
|
|
94
|
+
* and empty cells are also indicated with `Nothing`.
|
|
95
|
+
*/
|
|
96
|
+
parseTabular(): null | Expression[][];
|
|
97
|
+
/** Parse a group as a a string, for example for `\operatorname` or `\begin` */
|
|
98
|
+
parseStringGroup(): string | null;
|
|
99
|
+
/** Parse an environment: `\begin{env}...\end{end}`
|
|
100
|
+
*/
|
|
101
|
+
private parseEnvironment;
|
|
102
|
+
/** If the next token matches a `+` or `-` sign, return it and advance the index.
|
|
103
|
+
* Otherwise return `''` and do not advance */
|
|
104
|
+
private parseOptionalSign;
|
|
105
|
+
private parseDecimalDigits;
|
|
106
|
+
private parseSignedInteger;
|
|
107
|
+
private parseExponent;
|
|
108
|
+
parseRepeatingDecimal(): string;
|
|
109
|
+
/**
|
|
110
|
+
* Parse a number, with an optional sign, exponent, decimal marker,
|
|
111
|
+
* repeating decimals, etc...
|
|
112
|
+
*/
|
|
113
|
+
private parseNumber;
|
|
97
114
|
/**
|
|
98
115
|
* A Latex number can be a decimal, hex or octal number.
|
|
99
116
|
* It is used in some Latex commands, such as `\char`
|
|
@@ -106,25 +123,22 @@ export declare class _Parser implements Parser {
|
|
|
106
123
|
* > an internal variable.
|
|
107
124
|
*/
|
|
108
125
|
matchLatexNumber(isInteger?: boolean): null | number;
|
|
109
|
-
|
|
110
|
-
|
|
126
|
+
private parsePrefixOperator;
|
|
127
|
+
private parseInfixOperator;
|
|
111
128
|
/**
|
|
112
|
-
*
|
|
129
|
+
* This returns an array of arguments (as in a function application),
|
|
130
|
+
* or null if there is no match.
|
|
131
|
+
*
|
|
132
|
+
* - 'enclosure' : will look for an argument inside an enclosure
|
|
133
|
+
* (open/close fence)
|
|
113
134
|
* - 'implicit': either an expression inside a pair of `()`, or just a product
|
|
114
135
|
* (i.e. we interpret `\cos 2x + 1` as `\cos(2x) + 1`)
|
|
136
|
+
*
|
|
115
137
|
*/
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* A function can be followed by the following suffixes:
|
|
119
|
-
* - a `\prime`, `\doubleprime`, `'`, `(n)` to indicate a derivative
|
|
120
|
-
* - a subscript to indicate an argument
|
|
121
|
-
* - an argument, optionally inside an enclosure
|
|
122
|
-
*/
|
|
123
|
-
matchFunctionSuffix(id: string): Expression;
|
|
138
|
+
parseArguments(kind?: 'enclosure' | 'implicit', until?: Terminator): Expression[] | null;
|
|
124
139
|
/** A prime suffix is a sequence of `'`, `\prime` or `\doubleprime`
|
|
125
140
|
* after a function or in a superscript.
|
|
126
141
|
*/
|
|
127
|
-
matchPrimeSuffix(): number;
|
|
128
142
|
/** If matches the normalized open delimiter, return the
|
|
129
143
|
* expected closing delimiter.
|
|
130
144
|
*
|
|
@@ -133,55 +147,55 @@ export declare class _Parser implements Parser {
|
|
|
133
147
|
*
|
|
134
148
|
* If you need to match several tokens, use `matchAll()`
|
|
135
149
|
*/
|
|
136
|
-
matchOpenDelimiter
|
|
137
|
-
matchMiddleDelimiter(delimiter: '|' | ':' | LatexToken): boolean;
|
|
150
|
+
private matchOpenDelimiter;
|
|
138
151
|
/** For error handling, when there is potentially a mismatched delimiter.
|
|
139
152
|
* Return a LaTeX fragment of the expected closing delimiter
|
|
153
|
+
*
|
|
154
|
+
* @internal
|
|
140
155
|
*/
|
|
141
156
|
matchEnclosureOpen(): string | null;
|
|
157
|
+
/**
|
|
158
|
+
* Used for error handling
|
|
159
|
+
* @internal */
|
|
142
160
|
matchEnclosureClose(): string | null;
|
|
143
161
|
/**
|
|
144
162
|
* An enclosure is an opening matchfix operator, an optional expression,
|
|
145
163
|
* optionally followed multiple times by a separator and another expression,
|
|
146
164
|
* and finally a closing matching operator.
|
|
147
165
|
*/
|
|
148
|
-
|
|
149
|
-
matchIdentifier(): string | null;
|
|
166
|
+
private parseEnclosure;
|
|
150
167
|
/**
|
|
151
|
-
* A
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
-
*
|
|
155
|
-
|
|
156
|
-
|
|
168
|
+
* A generic expression is used for dictionary entries that take do
|
|
169
|
+
* some complex (non-standard) parsing. This includes trig functions (to
|
|
170
|
+
* parse implicit arguments), and integrals (to parse the integrand and
|
|
171
|
+
* limits and the "dx" terminator).
|
|
172
|
+
*/
|
|
173
|
+
private parseGenericExpression;
|
|
174
|
+
/**
|
|
175
|
+
* A function is an identifier followed by postfix operators
|
|
176
|
+
* (`\prime`...) and some arguments.
|
|
157
177
|
*/
|
|
158
|
-
|
|
178
|
+
private parseFunction;
|
|
179
|
+
parseSymbol(until?: Partial<Terminator>): Expression | null;
|
|
159
180
|
/**
|
|
160
|
-
*
|
|
181
|
+
* Parse a sequence superfix/subfix operator, e.g. `^{*}`
|
|
182
|
+
*
|
|
183
|
+
* Superfix and subfix need special handling:
|
|
184
|
+
*
|
|
185
|
+
* - they act mostly like an infix operator, but they are commutative, i.e.
|
|
186
|
+
* `x_a^b` should be parsed identically to `x^b_a`.
|
|
187
|
+
*
|
|
188
|
+
* - furthermore, in LaTeX `x^a^b` parses the same as `x^a{}^b`.
|
|
189
|
+
*
|
|
161
190
|
*/
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
matchSingleAtomArgument(): Expression | null;
|
|
165
|
-
matchLatexGroup(): Expression | null;
|
|
166
|
-
matchSupsub(lhs: Expression | null): Expression | null;
|
|
167
|
-
matchPostfix(lhs: Expression | null): Expression | null;
|
|
191
|
+
private parseSupsub;
|
|
192
|
+
parsePostfixOperator(lhs: Expression | null, until?: Partial<Terminator>): Expression | null;
|
|
168
193
|
/** Match a string used as a LaTeX identifier, for example an environment
|
|
169
194
|
* name.
|
|
170
195
|
* Not suitable for general purpose text, e.g. argument of a `\text{}
|
|
171
196
|
* command. See `matchChar()` instead.
|
|
172
197
|
*/
|
|
173
|
-
|
|
174
|
-
/** Match a string as an argument (in a `{}` pair) */
|
|
175
|
-
matchStringArgument(): string | null;
|
|
176
|
-
/**
|
|
177
|
-
* Match an expression in a tabular format, where rows are separated by `\\`
|
|
178
|
-
* and columns by `&`.
|
|
179
|
-
*
|
|
180
|
-
* Return rows of sparse columns: empty rows are indicated with `Nothing`,
|
|
181
|
-
* and empty cells are also indicated with `Nothing`.
|
|
182
|
-
*/
|
|
183
|
-
matchTabular(): null | Expression[][];
|
|
184
|
-
matchEnvironment(): Expression | null;
|
|
198
|
+
private parseStringGroupContent;
|
|
185
199
|
/**
|
|
186
200
|
* Apply an invisible operator between two expressions.
|
|
187
201
|
*
|
|
@@ -203,19 +217,30 @@ export declare class _Parser implements Parser {
|
|
|
203
217
|
* - x2 -> no
|
|
204
218
|
* => lhs is a number, rhs is a number, but not a literal
|
|
205
219
|
*/
|
|
206
|
-
applyInvisibleOperator
|
|
207
|
-
|
|
220
|
+
private applyInvisibleOperator;
|
|
221
|
+
/**
|
|
222
|
+
* This is an error handling method. We've encountered a LaTeX command
|
|
223
|
+
* but were not able to match it to any entry in the LaTeX dictionary,
|
|
224
|
+
* or ran into it in an unexpected context (postfix operator lacking an
|
|
225
|
+
* argument, for example)
|
|
226
|
+
*/
|
|
227
|
+
private parseUnexpectedLatexCommand;
|
|
208
228
|
/**
|
|
209
229
|
* <primary> :=
|
|
210
|
-
*
|
|
230
|
+
* (<number> | <symbol> | <environment> | <matchfix-expr>)
|
|
231
|
+
* <subsup>* <postfix-operator>*
|
|
211
232
|
*
|
|
212
|
-
* <symbol> ::=
|
|
233
|
+
* <symbol> ::=
|
|
234
|
+
* (<symbol-id> | (<latex-command><latex-arguments>)) <arguments>
|
|
213
235
|
*
|
|
214
236
|
* <matchfix-expr> :=
|
|
215
|
-
* <matchfix-op-open>
|
|
237
|
+
* <matchfix-op-open>
|
|
238
|
+
* <expression>
|
|
239
|
+
* (<matchfix-op-separator> <expression>)*
|
|
240
|
+
* <matchfix-op-close>
|
|
216
241
|
*
|
|
217
242
|
*/
|
|
218
|
-
|
|
243
|
+
private parsePrimary;
|
|
219
244
|
/**
|
|
220
245
|
* Parse an expression:
|
|
221
246
|
*
|
|
@@ -224,12 +249,14 @@ export declare class _Parser implements Parser {
|
|
|
224
249
|
* | <prefix-op> <primary>
|
|
225
250
|
* | <primary> <infix-op> <expression>
|
|
226
251
|
*
|
|
227
|
-
* Stop when an operator of precedence less than `until.minPrec`
|
|
252
|
+
* Stop when an operator of precedence less than `until.minPrec`
|
|
253
|
+
* is encountered
|
|
228
254
|
*/
|
|
229
|
-
|
|
255
|
+
parseExpression(until?: Partial<Terminator>): Expression | null;
|
|
230
256
|
/**
|
|
231
257
|
* Add LaTeX or other requested metadata to the expression
|
|
232
258
|
*/
|
|
233
259
|
decorate(expr: Expression | null, start: number): Expression | null;
|
|
234
260
|
error(code: string | [string, ...Expression[]], fromToken: number): Expression;
|
|
261
|
+
private isFunctionHead;
|
|
235
262
|
}
|