@cortex-js/compute-engine 0.12.5 → 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 +835 -735
- package/dist/compute-engine.js +835 -735
- package/dist/compute-engine.min.esm.js +835 -735
- package/dist/compute-engine.min.js +835 -735
- 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 +1 -1
- 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 +5 -5
- 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 +101 -76
- package/dist/types/compute-engine/latex-syntax/public.d.ts +137 -135
- 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 +98 -3
- 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,27 +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`)
|
|
115
136
|
*
|
|
116
|
-
* This returns an array of arguments, or null if there is no match.
|
|
117
|
-
*/
|
|
118
|
-
matchArguments(kind: undefined | '' | 'enclosure' | 'implicit', until?: Terminator): Expression[] | null;
|
|
119
|
-
/**
|
|
120
|
-
* A function can be followed by the following suffixes:
|
|
121
|
-
* - a `\prime`, `\doubleprime`, `'`, `(n)` to indicate a derivative
|
|
122
|
-
* - a subscript to indicate an argument
|
|
123
|
-
* - an argument, optionally inside an enclosure
|
|
124
137
|
*/
|
|
125
|
-
|
|
138
|
+
parseArguments(kind?: 'enclosure' | 'implicit', until?: Terminator): Expression[] | null;
|
|
126
139
|
/** A prime suffix is a sequence of `'`, `\prime` or `\doubleprime`
|
|
127
140
|
* after a function or in a superscript.
|
|
128
141
|
*/
|
|
129
|
-
matchPrimeSuffix(): number;
|
|
130
142
|
/** If matches the normalized open delimiter, return the
|
|
131
143
|
* expected closing delimiter.
|
|
132
144
|
*
|
|
@@ -135,55 +147,55 @@ export declare class _Parser implements Parser {
|
|
|
135
147
|
*
|
|
136
148
|
* If you need to match several tokens, use `matchAll()`
|
|
137
149
|
*/
|
|
138
|
-
matchOpenDelimiter
|
|
139
|
-
matchMiddleDelimiter(delimiter: '|' | ':' | LatexToken): boolean;
|
|
150
|
+
private matchOpenDelimiter;
|
|
140
151
|
/** For error handling, when there is potentially a mismatched delimiter.
|
|
141
152
|
* Return a LaTeX fragment of the expected closing delimiter
|
|
153
|
+
*
|
|
154
|
+
* @internal
|
|
142
155
|
*/
|
|
143
156
|
matchEnclosureOpen(): string | null;
|
|
157
|
+
/**
|
|
158
|
+
* Used for error handling
|
|
159
|
+
* @internal */
|
|
144
160
|
matchEnclosureClose(): string | null;
|
|
145
161
|
/**
|
|
146
162
|
* An enclosure is an opening matchfix operator, an optional expression,
|
|
147
163
|
* optionally followed multiple times by a separator and another expression,
|
|
148
164
|
* and finally a closing matching operator.
|
|
149
165
|
*/
|
|
150
|
-
|
|
151
|
-
matchIdentifier(): string | null;
|
|
166
|
+
private parseEnclosure;
|
|
152
167
|
/**
|
|
153
|
-
* A
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
|
|
158
|
-
|
|
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.
|
|
159
177
|
*/
|
|
160
|
-
|
|
178
|
+
private parseFunction;
|
|
179
|
+
parseSymbol(until?: Partial<Terminator>): Expression | null;
|
|
161
180
|
/**
|
|
162
|
-
*
|
|
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
|
+
*
|
|
163
190
|
*/
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
matchSingleAtomArgument(): Expression | null;
|
|
167
|
-
matchLatexGroup(): Expression | null;
|
|
168
|
-
matchSupsub(lhs: Expression | null): Expression | null;
|
|
169
|
-
matchPostfix(lhs: Expression | null, until?: Partial<Terminator>): Expression | null;
|
|
191
|
+
private parseSupsub;
|
|
192
|
+
parsePostfixOperator(lhs: Expression | null, until?: Partial<Terminator>): Expression | null;
|
|
170
193
|
/** Match a string used as a LaTeX identifier, for example an environment
|
|
171
194
|
* name.
|
|
172
195
|
* Not suitable for general purpose text, e.g. argument of a `\text{}
|
|
173
196
|
* command. See `matchChar()` instead.
|
|
174
197
|
*/
|
|
175
|
-
|
|
176
|
-
/** Match a string as an argument (in a `{}` pair) */
|
|
177
|
-
matchStringArgument(): string | null;
|
|
178
|
-
/**
|
|
179
|
-
* Match an expression in a tabular format, where rows are separated by `\\`
|
|
180
|
-
* and columns by `&`.
|
|
181
|
-
*
|
|
182
|
-
* Return rows of sparse columns: empty rows are indicated with `Nothing`,
|
|
183
|
-
* and empty cells are also indicated with `Nothing`.
|
|
184
|
-
*/
|
|
185
|
-
matchTabular(): null | Expression[][];
|
|
186
|
-
matchEnvironment(): Expression | null;
|
|
198
|
+
private parseStringGroupContent;
|
|
187
199
|
/**
|
|
188
200
|
* Apply an invisible operator between two expressions.
|
|
189
201
|
*
|
|
@@ -205,19 +217,30 @@ export declare class _Parser implements Parser {
|
|
|
205
217
|
* - x2 -> no
|
|
206
218
|
* => lhs is a number, rhs is a number, but not a literal
|
|
207
219
|
*/
|
|
208
|
-
applyInvisibleOperator
|
|
209
|
-
|
|
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;
|
|
210
228
|
/**
|
|
211
229
|
* <primary> :=
|
|
212
|
-
*
|
|
230
|
+
* (<number> | <symbol> | <environment> | <matchfix-expr>)
|
|
231
|
+
* <subsup>* <postfix-operator>*
|
|
213
232
|
*
|
|
214
|
-
* <symbol> ::=
|
|
233
|
+
* <symbol> ::=
|
|
234
|
+
* (<symbol-id> | (<latex-command><latex-arguments>)) <arguments>
|
|
215
235
|
*
|
|
216
236
|
* <matchfix-expr> :=
|
|
217
|
-
* <matchfix-op-open>
|
|
237
|
+
* <matchfix-op-open>
|
|
238
|
+
* <expression>
|
|
239
|
+
* (<matchfix-op-separator> <expression>)*
|
|
240
|
+
* <matchfix-op-close>
|
|
218
241
|
*
|
|
219
242
|
*/
|
|
220
|
-
|
|
243
|
+
private parsePrimary;
|
|
221
244
|
/**
|
|
222
245
|
* Parse an expression:
|
|
223
246
|
*
|
|
@@ -226,12 +249,14 @@ export declare class _Parser implements Parser {
|
|
|
226
249
|
* | <prefix-op> <primary>
|
|
227
250
|
* | <primary> <infix-op> <expression>
|
|
228
251
|
*
|
|
229
|
-
* Stop when an operator of precedence less than `until.minPrec`
|
|
252
|
+
* Stop when an operator of precedence less than `until.minPrec`
|
|
253
|
+
* is encountered
|
|
230
254
|
*/
|
|
231
|
-
|
|
255
|
+
parseExpression(until?: Partial<Terminator>): Expression | null;
|
|
232
256
|
/**
|
|
233
257
|
* Add LaTeX or other requested metadata to the expression
|
|
234
258
|
*/
|
|
235
259
|
decorate(expr: Expression | null, start: number): Expression | null;
|
|
236
260
|
error(code: string | [string, ...Expression[]], fromToken: number): Expression;
|
|
261
|
+
private isFunctionHead;
|
|
237
262
|
}
|