@cortex-js/compute-engine 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/compute-engine.esm.js +4312 -3783
- package/dist/compute-engine.min.esm.js +2 -2
- package/dist/compute-engine.min.js +2 -2
- package/dist/math-json.esm.js +48 -13
- 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/compute-engine/assume.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +6 -5
- package/dist/types/compute-engine/boxed-expression/box.d.ts +3 -5
- package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +3 -3
- package/dist/types/compute-engine/boxed-expression/boxed-domain.d.ts +32 -6
- 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 +5 -3
- package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +3 -3
- package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +3 -3
- package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +3 -3
- package/dist/types/compute-engine/boxed-expression/boxed-symbol-definition.d.ts +5 -5
- package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +4 -4
- 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 +3 -3
- package/dist/types/compute-engine/compute-engine.d.ts +10 -8
- package/dist/types/compute-engine/cost-function.d.ts +1 -1
- package/dist/types/compute-engine/dictionary/arithmetic-add.d.ts +2 -2
- package/dist/types/compute-engine/dictionary/arithmetic-divide.d.ts +1 -1
- package/dist/types/compute-engine/dictionary/arithmetic-multiply.d.ts +1 -1
- package/dist/types/compute-engine/dictionary/arithmetic-power.d.ts +1 -1
- package/dist/types/compute-engine/dictionary/arithmetic.d.ts +1 -1
- package/dist/types/compute-engine/dictionary/collections.d.ts +1 -1
- package/dist/types/compute-engine/dictionary/core.d.ts +1 -1
- package/dist/types/compute-engine/dictionary/dictionary.d.ts +1 -1
- package/dist/types/compute-engine/dictionary/logic.d.ts +1 -1
- package/dist/types/compute-engine/dictionary/polynomials.d.ts +1 -1
- package/dist/types/compute-engine/dictionary/relational-operator.d.ts +1 -1
- package/dist/types/compute-engine/dictionary/sets.d.ts +1 -1
- package/dist/types/compute-engine/dictionary/trigonometry.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 +1 -2
- package/dist/types/compute-engine/latex-syntax/latex-syntax.d.ts +2 -2
- package/dist/types/compute-engine/latex-syntax/parse.d.ts +10 -9
- package/dist/types/compute-engine/latex-syntax/public.d.ts +23 -24
- 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 +1 -1
- package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric-complex.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric-decimal.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/public.d.ts +72 -76
- 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/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 +3 -2
- package/dist/types/math-json/math-json-format.d.ts +1 -1
- package/dist/types/math-json/utils.d.ts +3 -4
- package/dist/types/math-json.d.ts +2 -2
- package/package.json +6 -7
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.6.0 */
|
|
2
2
|
export declare const DEFINITIONS_TRIGONOMETRY: LatexDictionary;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.6.0 */
|
|
2
2
|
import { WarningSignal } from '../../../common/signals';
|
|
3
3
|
export declare type CommonEntry = {
|
|
4
4
|
name?: string;
|
|
@@ -7,7 +7,6 @@ export declare type CommonEntry = {
|
|
|
7
7
|
export declare type SymbolEntry = CommonEntry & {
|
|
8
8
|
kind: 'symbol';
|
|
9
9
|
precedence: number;
|
|
10
|
-
arguments: 'group' | 'implicit' | '';
|
|
11
10
|
optionalLatexArg: number;
|
|
12
11
|
requiredLatexArg: number;
|
|
13
12
|
parse: SymbolParseHandler;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.6.0 */
|
|
2
2
|
import { Serializer } from './serializer';
|
|
3
3
|
import { Expression } from '../../math-json/math-json-format';
|
|
4
4
|
import { WarningSignalHandler } from '../../common/signals';
|
|
@@ -16,7 +16,7 @@ export declare class LatexSyntax {
|
|
|
16
16
|
onError?: WarningSignalHandler;
|
|
17
17
|
});
|
|
18
18
|
updateOptions(opt: Partial<NumberFormattingOptions> & Partial<ParseLatexOptions> & Partial<SerializeLatexOptions>): void;
|
|
19
|
-
static getDictionary(
|
|
19
|
+
static getDictionary(category?: DictionaryCategory | 'all'): Readonly<LatexDictionary>;
|
|
20
20
|
parse(latex: LatexString): Expression;
|
|
21
21
|
serialize(expr: Expression): LatexString;
|
|
22
22
|
get serializer(): Serializer;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.6.0 */
|
|
2
2
|
import { ParseLatexOptions, LatexToken, NumberFormattingOptions, Delimiter, Terminator, Parser } from './public';
|
|
3
3
|
import { IndexedLatexDictionary, InfixEntry, PostfixEntry, PrefixEntry, SymbolEntry } from './dictionary/definitions';
|
|
4
4
|
import { WarningSignalHandler } from '../../common/signals';
|
|
@@ -79,11 +79,13 @@ export declare class _Parser implements Parser {
|
|
|
79
79
|
matchPrefixOperator(until?: Terminator): Expression | null;
|
|
80
80
|
matchInfixOperator(lhs: Expression, until?: Terminator): Expression | null;
|
|
81
81
|
/**
|
|
82
|
-
* '
|
|
83
|
-
* 'implicit': either an expression inside a pair of `()`, or just a primary
|
|
82
|
+
* - 'enclosure' : will look for an argument inside an enclosure (open/close fence)
|
|
83
|
+
* - 'implicit': either an expression inside a pair of `()`, or just a primary
|
|
84
84
|
* (i.e. we interpret `\cos x + 1` as `\cos(x) + 1`)
|
|
85
|
+
* - 'group': the arguments follow until an end of group, `<}>`. This is the
|
|
86
|
+
* case for example for `\displaystyle`
|
|
85
87
|
*/
|
|
86
|
-
matchArguments(kind: undefined | '' | '
|
|
88
|
+
matchArguments(kind: undefined | '' | 'enclosure' | 'implicit' | 'group'): Expression[] | null;
|
|
87
89
|
/** If matches the normalized open delimiter, returns the
|
|
88
90
|
* expected closing delimiter.
|
|
89
91
|
*
|
|
@@ -103,7 +105,8 @@ export declare class _Parser implements Parser {
|
|
|
103
105
|
/**
|
|
104
106
|
* A symbol can be:
|
|
105
107
|
* - a constant: `\pi`
|
|
106
|
-
* - a variable: `x`
|
|
108
|
+
* - a single-letter variable: `x`
|
|
109
|
+
* - a multi-letter variable: `\mathit{speed}` or `\mathrm{speed}`
|
|
107
110
|
* - a function with explicit arguments `f(x)`
|
|
108
111
|
* - a function with implicit arguments: `\cos x`
|
|
109
112
|
* - a command: `\frac{2}{3}`
|
|
@@ -133,9 +136,7 @@ export declare class _Parser implements Parser {
|
|
|
133
136
|
*/
|
|
134
137
|
matchSupsub(lhs: Expression | null): Expression | null;
|
|
135
138
|
matchPostfix(lhs: Expression | null): Expression | null;
|
|
136
|
-
matchString(until:
|
|
137
|
-
tokens: LatexToken[];
|
|
138
|
-
} & Partial<Terminator>): string;
|
|
139
|
+
matchString(until: Partial<Terminator>): string;
|
|
139
140
|
matchEnvironmentName(command: '\\begin' | '\\end', envName: string): boolean;
|
|
140
141
|
/**
|
|
141
142
|
* Match an expression in a tabular format,
|
|
@@ -192,7 +193,7 @@ export declare class _Parser implements Parser {
|
|
|
192
193
|
*/
|
|
193
194
|
matchExpression(until?: Partial<Terminator>): Expression | null;
|
|
194
195
|
/**
|
|
195
|
-
* Add
|
|
196
|
+
* Add LaTeX or other requested metadata to the expression
|
|
196
197
|
*/
|
|
197
198
|
decorate(expr: Expression | null, start: number): Expression | null;
|
|
198
199
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.6.0 */
|
|
2
2
|
import { Expression } from '../../math-json/math-json-format';
|
|
3
3
|
import type { IComputeEngine } from '../public';
|
|
4
4
|
/**
|
|
@@ -165,6 +165,7 @@ export declare type SymbolEntry = BaseEntry & {
|
|
|
165
165
|
precedence?: number;
|
|
166
166
|
/**
|
|
167
167
|
* Indicate if this symbol can be followed by arguments.
|
|
168
|
+
*
|
|
168
169
|
* The presence of arguments will indicate that the arguments should be
|
|
169
170
|
* applied to the symbol. Otherwise, the invisible operator is applied
|
|
170
171
|
* to the symbol and the arguments.
|
|
@@ -172,14 +173,14 @@ export declare type SymbolEntry = BaseEntry & {
|
|
|
172
173
|
* If `arguments` is `"group"`:
|
|
173
174
|
*
|
|
174
175
|
* "f(x)" -> `["f", "x"]`
|
|
175
|
-
* "f x" -> `["
|
|
176
|
+
* "f x" -> `["Multiply", "f", "x"]`
|
|
176
177
|
*
|
|
177
178
|
* If `arguments` is `""`:
|
|
178
179
|
*
|
|
179
|
-
* "f(x)" -> `["
|
|
180
|
-
* "f x" -> `["
|
|
180
|
+
* "f(x)" -> `["Multiply", "f", "x"]`
|
|
181
|
+
* "f x" -> `["Multiply", "f", "x"]`
|
|
181
182
|
*
|
|
182
|
-
* If `arguments` is `"
|
|
183
|
+
* If `arguments` is `"implicit"` and the symbol is followed either
|
|
183
184
|
* by a group or by a primary (prefix + symbol + subsupfix + postfix).
|
|
184
185
|
* Used for trig functions. i.e. `\sin x` vs `\sin(x)`:
|
|
185
186
|
*
|
|
@@ -187,9 +188,7 @@ export declare type SymbolEntry = BaseEntry & {
|
|
|
187
188
|
* "f x" -> `["f", "x"]`
|
|
188
189
|
*
|
|
189
190
|
*/
|
|
190
|
-
arguments?: 'group' | 'implicit' | '';
|
|
191
191
|
/**
|
|
192
|
-
* Applicable when `kind` is `"symbol"`.
|
|
193
192
|
*
|
|
194
193
|
* If a LaTeX command (i.e. the trigger starts with `\`, e.g. `\sqrt`)
|
|
195
194
|
* indicates the number of optional arguments expected (indicate with
|
|
@@ -200,7 +199,6 @@ export declare type SymbolEntry = BaseEntry & {
|
|
|
200
199
|
*/
|
|
201
200
|
optionalLatexArg?: number;
|
|
202
201
|
/**
|
|
203
|
-
* Applicable when `kind` is `"symbol"`.
|
|
204
202
|
*
|
|
205
203
|
* If a LaTeX command (i.e. the trigger starts with `\`, e.g. `\frac`)
|
|
206
204
|
* indicates the number of required arguments expected (indicated with
|
|
@@ -217,7 +215,6 @@ export declare type SymbolEntry = BaseEntry & {
|
|
|
217
215
|
*/
|
|
218
216
|
export declare type DefaultEntry = BaseEntry & {
|
|
219
217
|
precedence?: number;
|
|
220
|
-
arguments?: 'group' | 'implicit' | '';
|
|
221
218
|
optionalLatexArg?: number;
|
|
222
219
|
requiredLatexArg?: number;
|
|
223
220
|
parse?: Expression | SymbolParseHandler;
|
|
@@ -280,22 +277,22 @@ export declare type ParseLatexOptions = {
|
|
|
280
277
|
*/
|
|
281
278
|
parseNumbers: boolean;
|
|
282
279
|
/**
|
|
283
|
-
*
|
|
284
|
-
*
|
|
285
|
-
*
|
|
280
|
+
* This handler is invoked when the parser encounter a set of tokens
|
|
281
|
+
* at a position that could be a symbol or function.
|
|
282
|
+
*
|
|
283
|
+
* The `symbol` argument is one or more tokens.
|
|
286
284
|
*
|
|
287
|
-
*
|
|
288
|
-
* or function, respectively.
|
|
285
|
+
* The handler can return:
|
|
289
286
|
*
|
|
290
|
-
*
|
|
291
|
-
* (typically, parentheses), parse them as arguments to the function.
|
|
287
|
+
* - `symbol` to indicate the string represent a constant or variable.
|
|
292
288
|
*
|
|
293
|
-
*
|
|
294
|
-
*
|
|
289
|
+
* - `function` to indicate the string is a function name. If an apply
|
|
290
|
+
* function operator (typically, parentheses) follow, parse them as arguments
|
|
291
|
+
* to the function.
|
|
295
292
|
*
|
|
296
|
-
*
|
|
293
|
+
* - `error`, an error condition is raised.
|
|
297
294
|
*/
|
|
298
|
-
|
|
295
|
+
parseUnknownSymbol: (symbol: string, parser: Parser) => 'symbol' | 'function' | 'unknown';
|
|
299
296
|
/**
|
|
300
297
|
* If true, the expression will be decorated with the LaTeX
|
|
301
298
|
* fragments corresponding to each elements of the expression.
|
|
@@ -515,16 +512,18 @@ export interface Parser {
|
|
|
515
512
|
/** If the next tokens correspond to an optional LaTeX argument,
|
|
516
513
|
* enclosed with `[` and `]` return the content of the argument
|
|
517
514
|
* as an expression and advance the index past the closing `]`.
|
|
515
|
+
*
|
|
518
516
|
* Otherwise, return `null`.
|
|
519
517
|
*/
|
|
520
518
|
matchOptionalLatexArgument(): Expression | null;
|
|
521
519
|
matchRequiredLatexArgument(): Expression | null;
|
|
522
520
|
/**
|
|
523
|
-
* '
|
|
524
|
-
* '
|
|
525
|
-
*
|
|
521
|
+
* - 'enclosure' : will look for an argument inside an enclosure (an open/close fence)
|
|
522
|
+
* - 'group': arguments follow directly the symbol, until an end of group token `<}>`
|
|
523
|
+
* - 'implicit': either an expression inside a pair of `()`, or just a primary
|
|
524
|
+
* (i.e. we interpret `\cos x + 1` as `\cos(x) + 1`)
|
|
526
525
|
*/
|
|
527
|
-
matchArguments(kind: '' | 'group' | 'implicit'): Expression[] | null;
|
|
526
|
+
matchArguments(kind: '' | 'group' | 'implicit' | 'enclosure'): Expression[] | null;
|
|
528
527
|
/** If matches the normalized open delimiter, returns the
|
|
529
528
|
* expected closing delimiter.
|
|
530
529
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.6.0 */
|
|
2
2
|
import { NumberFormattingOptions } from './public';
|
|
3
3
|
export declare function serializeNumber(expr: Expression | null, options: NumberFormattingOptions): string;
|
|
4
4
|
export declare function serializeEngineeringNotationNumber(value: number, options: NumberFormattingOptions): string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.6.0 */
|
|
2
2
|
export declare function getApplyFunctionStyle(_expr: Expression, _level: number): 'paren' | 'leftright' | 'big' | 'none';
|
|
3
3
|
export declare function getGroupStyle(_expr: Expression, _level: number): 'paren' | 'leftright' | 'big' | 'none';
|
|
4
4
|
export declare function getRootStyle(_expr: Expression | null, level: number): 'radical' | 'quotient' | 'solidus';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.6.0 */
|
|
2
2
|
export declare function isPrime(n: number): boolean | undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.6.0 */
|
|
2
2
|
* The most important classes are {@link ComputeEngine} and
|
|
3
3
|
* {@link BoxedExpression}.
|
|
4
4
|
*
|
|
@@ -122,13 +122,59 @@ export declare type BoxedRule = [
|
|
|
122
122
|
condition: undefined | ((wildcards: Substitution) => boolean)
|
|
123
123
|
];
|
|
124
124
|
export declare type BoxedRuleSet = Set<BoxedRule>;
|
|
125
|
+
export declare type ParametricDomainFunction = 'Function' | 'Union' | 'List' | 'Record' | 'Tuple' | 'Intersection' | 'Range' | 'Interval' | 'Optional' | 'Some' | 'Head' | 'Symbol' | 'Literal';
|
|
126
|
+
export declare type ParametricDomain = [
|
|
127
|
+
ParametricDomainFunction,
|
|
128
|
+
...DomainExpression[]
|
|
129
|
+
];
|
|
130
|
+
export declare type DomainExpression = string | ParametricDomain;
|
|
125
131
|
/**
|
|
126
132
|
* Domains can be defined as a union or intersection of domains:
|
|
127
133
|
* - `["Union", "Number", "Boolean"]` A number or a boolean.
|
|
128
134
|
* - `["SetMinus", "Number", 1]` Any number except "1".
|
|
129
135
|
*
|
|
130
136
|
*/
|
|
131
|
-
export
|
|
137
|
+
export interface Domain extends BoxedExpression {
|
|
138
|
+
isSubdomainOf(dom: Domain | string): boolean;
|
|
139
|
+
isMemberOf(expr: BoxedExpression): boolean;
|
|
140
|
+
readonly domainExpression: DomainExpression;
|
|
141
|
+
codomain: Domain | null;
|
|
142
|
+
readonly isNothing: boolean;
|
|
143
|
+
is(s: BoxedExpression): boolean;
|
|
144
|
+
readonly isBoolean: boolean;
|
|
145
|
+
readonly isNumeric: boolean;
|
|
146
|
+
readonly isFunction: boolean;
|
|
147
|
+
readonly isPredicate: boolean;
|
|
148
|
+
/**
|
|
149
|
+
* If true, when all the arguments are numeric, the result of the
|
|
150
|
+
* evaluation is numeric. Numeric is any value with a domain of `Number`.
|
|
151
|
+
*
|
|
152
|
+
* Example of numeric functions: `Add`, `Multiply`, `Power`, `Abs`
|
|
153
|
+
*
|
|
154
|
+
* Default: false
|
|
155
|
+
*/
|
|
156
|
+
readonly isNumericFunction: boolean;
|
|
157
|
+
readonly isRealFunction: boolean;
|
|
158
|
+
/**
|
|
159
|
+
* If true, when all the arguments are boolean, the result of the
|
|
160
|
+
* evaluation is a boolean. Boolean is any value with a domain of `MaybeBoolean`.
|
|
161
|
+
*
|
|
162
|
+
* Example of logic functions: `And`, `Or`, `Not`, `Implies`
|
|
163
|
+
*
|
|
164
|
+
* **Default:** false
|
|
165
|
+
*/
|
|
166
|
+
readonly isLogicOperator: boolean;
|
|
167
|
+
/**
|
|
168
|
+
* The function represent a relation between the first argument and
|
|
169
|
+
* the second argument, and evaluates to a boolean indicating if the relation
|
|
170
|
+
* is satisfied.
|
|
171
|
+
*
|
|
172
|
+
* For example, `Equal`, `Less`, `Approx`, etc...
|
|
173
|
+
*
|
|
174
|
+
* **Default:** false
|
|
175
|
+
*/
|
|
176
|
+
readonly isRelationalOperator: boolean;
|
|
177
|
+
}
|
|
132
178
|
/**
|
|
133
179
|
* Options to control the serialization to MathJSON when using `BoxedExpression.json`.
|
|
134
180
|
*/
|
|
@@ -216,7 +262,7 @@ export interface BoxedExpression {
|
|
|
216
262
|
* @category Object Methods
|
|
217
263
|
*
|
|
218
264
|
*/
|
|
219
|
-
is(rhs:
|
|
265
|
+
is(rhs: unknown): boolean;
|
|
220
266
|
/** @internal */
|
|
221
267
|
get hash(): number;
|
|
222
268
|
/** An optional short description of the symbol or function head.
|
|
@@ -468,12 +514,6 @@ export interface BoxedExpression {
|
|
|
468
514
|
*
|
|
469
515
|
*/
|
|
470
516
|
get string(): string | null;
|
|
471
|
-
/** True if this domain is a subset of domain `d`
|
|
472
|
-
*
|
|
473
|
-
* @category Expression Properties
|
|
474
|
-
*
|
|
475
|
-
*/
|
|
476
|
-
isSubsetOf(d: BoxedExpression | string): undefined | boolean;
|
|
477
517
|
/** True if the value of this expression is a number.
|
|
478
518
|
*
|
|
479
519
|
* `isExtendedComplex || isNaN` = `isReal || isImaginary || isInfinity || isNaN`
|
|
@@ -693,11 +733,17 @@ export interface BoxedExpression {
|
|
|
693
733
|
* first in commutative functions
|
|
694
734
|
*/
|
|
695
735
|
get complexity(): number;
|
|
696
|
-
/** The domain of this expression
|
|
697
|
-
|
|
698
|
-
get domain(): BoxedExpression;
|
|
736
|
+
/** The domain of this expression. */
|
|
737
|
+
get domain(): Domain;
|
|
699
738
|
/** Symbols that represent a variable, can have their domain modified */
|
|
700
|
-
set domain(domain:
|
|
739
|
+
set domain(domain: Domain | string);
|
|
740
|
+
/** The domain of the value of this expression, using the value of the expression,
|
|
741
|
+
* definitions associated with this expression and assumptions if necessary.
|
|
742
|
+
*
|
|
743
|
+
* For symbols, the `domain` and `valueDomain` are the same. For functions,
|
|
744
|
+
* the `valueDomain` is the codomain of the function.
|
|
745
|
+
*/
|
|
746
|
+
get valueDomain(): Domain;
|
|
701
747
|
/** For symbols and functions, a possible definition associated with the expression */
|
|
702
748
|
get functionDefinition(): BoxedFunctionDefinition | undefined;
|
|
703
749
|
get symbolDefinition(): BoxedSymbolDefinition | undefined;
|
|
@@ -975,9 +1021,14 @@ export declare type BaseDefinition = {
|
|
|
975
1021
|
*
|
|
976
1022
|
* For symbols, this is the domain of their value.
|
|
977
1023
|
*
|
|
978
|
-
* For functions, this is the
|
|
1024
|
+
* For functions, this is the signature of the function
|
|
1025
|
+
*
|
|
1026
|
+
* When `domain` is a handler, calculate the domain (or signature) based on
|
|
1027
|
+
* the arguments (for expressions others than functions, `args` is an empty
|
|
1028
|
+
* array). If the function cannot be applied to the arguments, return
|
|
1029
|
+
* `null`.
|
|
979
1030
|
*/
|
|
980
|
-
domain?: BoxedExpression |
|
|
1031
|
+
domain?: Domain | DomainExpression | string | ((ce: IComputeEngine, args: BoxedExpression[]) => Domain | DomainExpression);
|
|
981
1032
|
};
|
|
982
1033
|
export declare type BoxedBaseDefinition = {
|
|
983
1034
|
name: string;
|
|
@@ -990,7 +1041,7 @@ export declare type BoxedBaseDefinition = {
|
|
|
990
1041
|
* This field is usually undefined, but its value is set by `getDefinition()`
|
|
991
1042
|
*/
|
|
992
1043
|
scope: RuntimeScope | undefined;
|
|
993
|
-
domain?: BoxedExpression;
|
|
1044
|
+
domain?: Domain | ((ce: IComputeEngine, args: BoxedExpression[]) => Domain | DomainExpression);
|
|
994
1045
|
_purge(): undefined;
|
|
995
1046
|
};
|
|
996
1047
|
/**
|
|
@@ -1053,34 +1104,6 @@ export declare type FunctionDefinitionFlags = {
|
|
|
1053
1104
|
* **Default**: `false`
|
|
1054
1105
|
*/
|
|
1055
1106
|
involution: boolean;
|
|
1056
|
-
/**
|
|
1057
|
-
* If true, when all the arguments are numeric, the result of the
|
|
1058
|
-
* evaluation is numeric. Numeric is any value with a domain of `Number`.
|
|
1059
|
-
*
|
|
1060
|
-
* Example of numeric functions: `Add`, `Multiply`, `Power`, `Abs`
|
|
1061
|
-
*
|
|
1062
|
-
* Default: false
|
|
1063
|
-
*/
|
|
1064
|
-
numeric: boolean;
|
|
1065
|
-
/**
|
|
1066
|
-
* If true, when all the arguments are boolean, the result of the
|
|
1067
|
-
* evaluation is a boolean. Boolean is any value with a domain of `MaybeBoolean`.
|
|
1068
|
-
*
|
|
1069
|
-
* Example of logic functions: `And`, `Or`, `Not`, `Implies`
|
|
1070
|
-
*
|
|
1071
|
-
* **Default:** false
|
|
1072
|
-
*/
|
|
1073
|
-
logic: boolean;
|
|
1074
|
-
/**
|
|
1075
|
-
* The function represent a relation between the first argument and
|
|
1076
|
-
* the second argument, and evaluates to a boolean indicating if the relation
|
|
1077
|
-
* is satisfied.
|
|
1078
|
-
*
|
|
1079
|
-
* For example, `Equal`, `Less`, `Approx`, etc...
|
|
1080
|
-
*
|
|
1081
|
-
* **Default:** false
|
|
1082
|
-
*/
|
|
1083
|
-
relationalOperator: boolean;
|
|
1084
1107
|
/** If true, the value of this function is always the same for a given
|
|
1085
1108
|
* set of arguments and it has no side effects.
|
|
1086
1109
|
*
|
|
@@ -1252,31 +1275,6 @@ export declare type FunctionDefinition = BaseDefinition & Partial<FunctionDefini
|
|
|
1252
1275
|
*
|
|
1253
1276
|
*/
|
|
1254
1277
|
N?: (ce: IComputeEngine, args: BoxedExpression[]) => BoxedExpression | undefined;
|
|
1255
|
-
/**
|
|
1256
|
-
*
|
|
1257
|
-
* Calculate the domain of the result, based on the value of the arguments.
|
|
1258
|
-
*
|
|
1259
|
-
* If the domain of the result is always the same, use the `domain` property
|
|
1260
|
-
* instead.
|
|
1261
|
-
*
|
|
1262
|
-
* The argument `args` represent the arguments of the function.
|
|
1263
|
-
*
|
|
1264
|
-
* The return value is `null` if the input arguments cannot be handled by
|
|
1265
|
-
* this definition.
|
|
1266
|
-
*
|
|
1267
|
-
* Otherwise, the return value is the domain of the result.
|
|
1268
|
-
*
|
|
1269
|
-
* Return `"Nothing"` if the arguments are acceptable, but the evaluation
|
|
1270
|
-
* will fail, for example in some cases if there are missing arguments.
|
|
1271
|
-
*
|
|
1272
|
-
* This function is used to select the correct definition when there are
|
|
1273
|
-
* multiple definitions for the same function name.
|
|
1274
|
-
*
|
|
1275
|
-
* For example it allows to distinguish between a `Add` function that
|
|
1276
|
-
* applies to numbers and an `Add` function that applies to tensors.
|
|
1277
|
-
*
|
|
1278
|
-
*/
|
|
1279
|
-
evalDomain?: (ce: IComputeEngine, args: BoxedExpression[]) => BoxedExpression | string | null;
|
|
1280
1278
|
/** Dimensional analysis
|
|
1281
1279
|
* @experimental
|
|
1282
1280
|
*/
|
|
@@ -1295,7 +1293,6 @@ export declare type BoxedFunctionDefinition = BoxedBaseDefinition & FunctionDefi
|
|
|
1295
1293
|
simplify?: (ce: IComputeEngine, args: BoxedExpression[]) => BoxedExpression | undefined;
|
|
1296
1294
|
evaluate?: BoxedLambdaExpression | ((ce: IComputeEngine, args: BoxedExpression[]) => BoxedExpression | undefined);
|
|
1297
1295
|
N?: (ce: IComputeEngine, args: BoxedExpression[]) => BoxedExpression | undefined;
|
|
1298
|
-
evalDomain?: (ce: IComputeEngine, args: BoxedExpression[]) => BoxedExpression | string | null;
|
|
1299
1296
|
evalDimension?: (ce: IComputeEngine, args: BoxedExpression[]) => BoxedExpression;
|
|
1300
1297
|
sgn?: (ce: IComputeEngine, args: BoxedExpression[]) => -1 | 0 | 1 | undefined;
|
|
1301
1298
|
compile?: (expr: BoxedExpression) => CompiledExpression;
|
|
@@ -1361,7 +1358,7 @@ export declare type SymbolDefinition = BaseDefinition & Partial<SymbolFlags> & P
|
|
|
1361
1358
|
* `Pi`, the actual value depends on the `precision` setting of the
|
|
1362
1359
|
* `ComputeEngine` */
|
|
1363
1360
|
value?: LatexString | SemiBoxedExpression | ((ce: IComputeEngine) => SemiBoxedExpression | null);
|
|
1364
|
-
domain?: string |
|
|
1361
|
+
domain?: string | Domain;
|
|
1365
1362
|
};
|
|
1366
1363
|
export interface BoxedSymbolDefinition extends BoxedBaseDefinition, Partial<SymbolFlags>, SymbolDefinitionFlags {
|
|
1367
1364
|
get value(): BoxedExpression | undefined;
|
|
@@ -1427,7 +1424,7 @@ export interface IComputeEngine {
|
|
|
1427
1424
|
readonly iterationLimit: number;
|
|
1428
1425
|
/** @experimental */
|
|
1429
1426
|
readonly recursionLimit: number;
|
|
1430
|
-
defaultDomain: null |
|
|
1427
|
+
defaultDomain: null | Domain;
|
|
1431
1428
|
/** {@inheritDoc NumericMode} */
|
|
1432
1429
|
numericMode: NumericMode;
|
|
1433
1430
|
tolerance: number;
|
|
@@ -1452,7 +1449,7 @@ export interface IComputeEngine {
|
|
|
1452
1449
|
/**
|
|
1453
1450
|
* Return `undefined` if no definition exist for this `head.
|
|
1454
1451
|
*/
|
|
1455
|
-
getFunctionDefinition(head: string,
|
|
1452
|
+
getFunctionDefinition(head: string, args?: BoxedExpression[]): undefined | BoxedFunctionDefinition;
|
|
1456
1453
|
/**
|
|
1457
1454
|
* Returned a boxed expression from the input.
|
|
1458
1455
|
*
|
|
@@ -1466,7 +1463,7 @@ export interface IComputeEngine {
|
|
|
1466
1463
|
/** Return a canonical boxed string */
|
|
1467
1464
|
string(s: string, metadata?: Metadata): BoxedExpression;
|
|
1468
1465
|
/** Return a canonical boxed domain */
|
|
1469
|
-
domain(domain:
|
|
1466
|
+
domain(domain: SemiBoxedExpression | Domain | string, metadata?: Metadata): Domain;
|
|
1470
1467
|
/** Return a canonical expression.
|
|
1471
1468
|
*
|
|
1472
1469
|
* Note that the result may not be a function, or may have a different
|
|
@@ -1577,7 +1574,7 @@ export interface IComputeEngine {
|
|
|
1577
1574
|
*
|
|
1578
1575
|
*
|
|
1579
1576
|
*/
|
|
1580
|
-
assume(symbol: LatexString | SemiBoxedExpression, domain:
|
|
1577
|
+
assume(symbol: LatexString | SemiBoxedExpression, domain: Domain): AssumeResult;
|
|
1581
1578
|
assume(predicate: LatexString | SemiBoxedExpression): AssumeResult;
|
|
1582
1579
|
assume(arg1: LatexString | SemiBoxedExpression, arg2?: BoxedExpression): AssumeResult;
|
|
1583
1580
|
/** Remove all assumptions about one or more symbols */
|
|
@@ -1614,4 +1611,3 @@ export interface IComputeEngine {
|
|
|
1614
1611
|
/** @internal */
|
|
1615
1612
|
_unregister(expr: BoxedExpression): void;
|
|
1616
1613
|
}
|
|
1617
|
-
export declare function getVars(expr: BoxedExpression): string[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.6.0 */
|
|
2
2
|
/**
|
|
3
3
|
* These constants are the 'primitive' functions and constants that are used
|
|
4
4
|
* for some basic manipulations such as parsing, and transforming to canonical
|
|
@@ -53,6 +53,8 @@ export declare function headName(expr: Expression | null): string;
|
|
|
53
53
|
export declare function op(expr: Expression | null, n: number): Expression | null;
|
|
54
54
|
export declare function nops(expr: Expression): number;
|
|
55
55
|
export declare function symbol(expr: Expression | null): string | null;
|
|
56
|
+
export declare function string(expr: Expression | null): string | null;
|
|
57
|
+
export declare function dictionary(expr: Expression | null): null | Record<string, Expression>;
|
|
56
58
|
export declare function machineValue(expr: Expression | null): number | null;
|
|
57
59
|
/**
|
|
58
60
|
* Return a rational (numer over denom) representation of the expression,
|
|
@@ -77,9 +79,6 @@ export declare function applyRecursively(expr: Expression, fn: (x: Expression) =
|
|
|
77
79
|
* Apply a function to the arguments of a function and return an array of T
|
|
78
80
|
*/
|
|
79
81
|
export declare function mapArgs<T>(expr: Expression, fn: (x: Expression) => T): T[];
|
|
80
|
-
export declare function dictionary(expr: Expression): {
|
|
81
|
-
[key: string]: Expression;
|
|
82
|
-
} | null;
|
|
83
82
|
/**
|
|
84
83
|
* Return num as a number if it's a valid JSON number (that is
|
|
85
84
|
* a valid JavaScript number but not NaN or +/-Infinity) or
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.6.0 */
|
|
2
2
|
export { isAtomic, isSymbolObject, isStringObject, isFunctionObject, isDictionaryObject, stringValue as getStringValue, head, headName, symbol, tail, applyRecursively, mapArgs, op, nops, dictionary as getDictionary, asValidJSONNumber, } from './math-json/utils';
|
|
3
3
|
export type { LatexToken, ParseHandler, SerializeHandler, LatexDictionaryEntry, LatexDictionary, ParseLatexOptions, SerializeLatexOptions, NumberFormattingOptions, } from './compute-engine/latex-syntax/public';
|
|
4
|
-
export declare const version = "0.
|
|
4
|
+
export declare const version = "0.6.0";
|