@cortex-js/compute-engine 0.4.3 → 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 +2 -3
- package/dist/compute-engine.esm.js +63 -44
- package/dist/compute-engine.min.esm.js +2 -2
- package/dist/compute-engine.min.js +2 -2
- package/dist/math-json.esm.js +23 -16
- 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 +3 -3
- 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 +2 -2
- package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +3 -3
- package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/order.d.ts +2 -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/compute-engine.d.ts +12 -7
- package/dist/types/compute-engine/cost-function.d.ts +1 -1
- package/dist/types/compute-engine/dictionary/arithmetic-add.d.ts +1 -1
- 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 -1
- package/dist/types/compute-engine/latex-syntax/latex-syntax.d.ts +2 -2
- package/dist/types/compute-engine/latex-syntax/parse.d.ts +5 -5
- package/dist/types/compute-engine/latex-syntax/public.d.ts +2 -2
- package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +3 -3
- package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/serializer.d.ts +3 -3
- 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 +68 -35
- 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 +2 -2
- package/dist/types/math-json/math-json-format.d.ts +1 -1
- package/dist/types/math-json/utils.d.ts +1 -1
- package/dist/types/math-json.d.ts +2 -2
- package/package.json +3 -3
- package/dist/compute-engine.js +0 -23523
- package/dist/math-json.js +0 -6339
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/* 0.4.
|
|
1
|
+
/* 0.4.4 */
|
|
2
2
|
import { AbstractBoxedExpression } from './abstract-boxed-expression';
|
|
3
|
-
import { BoxedExpression, BoxedRuleSet, BoxedSymbolDefinition, IComputeEngine, EvaluateOptions, NOptions, ReplaceOptions,
|
|
3
|
+
import { BoxedExpression, BoxedRuleSet, BoxedSymbolDefinition, IComputeEngine, EvaluateOptions, NOptions, ReplaceOptions, SimplifyOptions, Substitution, Metadata, PatternMatchOption } from '../public';
|
|
4
4
|
/**
|
|
5
5
|
* BoxedSymbol
|
|
6
6
|
*
|
|
@@ -29,7 +29,7 @@ export declare class BoxedSymbol extends AbstractBoxedExpression {
|
|
|
29
29
|
get symbolDefinition(): BoxedSymbolDefinition | undefined;
|
|
30
30
|
_repairDefinition(): void;
|
|
31
31
|
get value(): BoxedExpression | undefined;
|
|
32
|
-
set value(value:
|
|
32
|
+
set value(value: BoxedExpression | number | undefined);
|
|
33
33
|
get numericValue(): BoxedExpression | undefined;
|
|
34
34
|
get domain(): BoxedExpression;
|
|
35
35
|
set domain(d: BoxedExpression);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/* 0.4.
|
|
2
|
-
import { DictionaryCategory, LatexString, NumberFormattingOptions, ParseLatexOptions, SerializeLatexOptions } from './latex-syntax/public';
|
|
1
|
+
/* 0.4.4 */
|
|
2
|
+
import { DictionaryCategory, LatexDictionaryEntry, LatexString, NumberFormattingOptions, ParseLatexOptions, SerializeLatexOptions } from './latex-syntax/public';
|
|
3
3
|
import { Decimal } from 'decimal.js';
|
|
4
4
|
import { Complex } from 'complex.js';
|
|
5
5
|
import { SignalMessage, WarningSignal } from '../common/signals';
|
|
@@ -45,6 +45,7 @@ export declare class ComputeEngine implements IComputeEngine {
|
|
|
45
45
|
private _commonSymbols;
|
|
46
46
|
private _commonNumbers;
|
|
47
47
|
private _commonDomains;
|
|
48
|
+
private _latexDictionary?;
|
|
48
49
|
/**
|
|
49
50
|
* The current scope.
|
|
50
51
|
*
|
|
@@ -70,8 +71,11 @@ export declare class ComputeEngine implements IComputeEngine {
|
|
|
70
71
|
* Construct a new `ComputeEngine` environment.
|
|
71
72
|
*
|
|
72
73
|
* If no `options.dictionaries` is provided a default set of dictionaries
|
|
73
|
-
* is used.
|
|
74
|
-
*
|
|
74
|
+
* is used.
|
|
75
|
+
*
|
|
76
|
+
* The `ComputeEngine.getDictionaries()` method can be called
|
|
77
|
+
* to access a subset of dictionaries, e.g. for arithmetic, calculus, etc...
|
|
78
|
+
*
|
|
75
79
|
* The order of the dictionaries matter: the definitions from the later ones
|
|
76
80
|
* override the definitions from earlier ones. The first dictionary should
|
|
77
81
|
* be the `'core'` dictionary which include some basic definitions such
|
|
@@ -79,10 +83,11 @@ export declare class ComputeEngine implements IComputeEngine {
|
|
|
79
83
|
*/
|
|
80
84
|
constructor(options?: {
|
|
81
85
|
dictionaries?: Readonly<Dictionary>[];
|
|
86
|
+
latexDictionary?: readonly LatexDictionaryEntry[];
|
|
82
87
|
numericMode?: NumericMode;
|
|
83
|
-
assumptions?: (LatexString | Expression)[];
|
|
84
88
|
numericPrecision?: number;
|
|
85
89
|
tolerance?: number;
|
|
90
|
+
assumptions?: (LatexString | Expression)[];
|
|
86
91
|
defaultDomain?: string;
|
|
87
92
|
});
|
|
88
93
|
/** After the configuration of the engine has changed, clear the caches
|
|
@@ -219,8 +224,8 @@ export declare class ComputeEngine implements IComputeEngine {
|
|
|
219
224
|
parse(s: LatexString | string): BoxedExpression;
|
|
220
225
|
parse(s: LatexString | string | null): null | BoxedExpression;
|
|
221
226
|
serialize(x: Expression | BoxedExpression): string;
|
|
222
|
-
get latexOptions():
|
|
223
|
-
set latexOptions(opts: NumberFormattingOptions & ParseLatexOptions & SerializeLatexOptions);
|
|
227
|
+
get latexOptions(): NumberFormattingOptions & ParseLatexOptions & SerializeLatexOptions;
|
|
228
|
+
set latexOptions(opts: Partial<NumberFormattingOptions> & Partial<ParseLatexOptions> & Partial<SerializeLatexOptions>);
|
|
224
229
|
get jsonSerializationOptions(): JsonSerializationOptions;
|
|
225
230
|
set jsonSerializationOptions(val: Partial<JsonSerializationOptions>);
|
|
226
231
|
/**
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.4.
|
|
1
|
+
/* 0.4.4 */
|
|
2
2
|
export declare const ARITHMETIC_DICTIONARY: Dictionary[];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.4.
|
|
1
|
+
/* 0.4.4 */
|
|
2
2
|
export declare const COLLECTIONS_DICTIONARY: Dictionary;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.4.
|
|
1
|
+
/* 0.4.4 */
|
|
2
2
|
export declare const CORE_DICTIONARY: Dictionary[];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.4.
|
|
1
|
+
/* 0.4.4 */
|
|
2
2
|
export declare const LOGIC_DICTIONARY: Dictionary;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.4.
|
|
1
|
+
/* 0.4.4 */
|
|
2
2
|
export declare const POLYNOMIALS_DICTIONARY: Dictionary[];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.4.
|
|
1
|
+
/* 0.4.4 */
|
|
2
2
|
export declare const RELOP_DICTIONARY: Dictionary;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.4.
|
|
1
|
+
/* 0.4.4 */
|
|
2
2
|
export declare const SETS_DICTIONARY: Dictionary;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.4.
|
|
1
|
+
/* 0.4.4 */
|
|
2
2
|
export declare const TRIGONOMETRY_DICTIONARY: Dictionary[];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.4.
|
|
1
|
+
/* 0.4.4 */
|
|
2
2
|
export declare const DEFINITIONS_ALGEBRA: LatexDictionary;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.4.
|
|
1
|
+
/* 0.4.4 */
|
|
2
2
|
export declare const DEFINITIONS_ARITHMETIC: LatexDictionary;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.4.
|
|
1
|
+
/* 0.4.4 */
|
|
2
2
|
export declare const DEFINITIONS_CALCULUS: LatexDictionary;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.4.
|
|
1
|
+
/* 0.4.4 */
|
|
2
2
|
export declare const DEFINITIONS_INEQUALITIES: LatexDictionary;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.4.
|
|
1
|
+
/* 0.4.4 */
|
|
2
2
|
export declare const DEFINITIONS_LOGIC: LatexDictionary;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.4.
|
|
1
|
+
/* 0.4.4 */
|
|
2
2
|
export declare const DEFINITIONS_OTHERS: LatexDictionary;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.4.
|
|
1
|
+
/* 0.4.4 */
|
|
2
2
|
export declare const DEFINITIONS_SETS: LatexDictionary;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.4.
|
|
1
|
+
/* 0.4.4 */
|
|
2
2
|
export declare const DEFINITIONS_SYMBOLS: LatexDictionary;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.4.
|
|
1
|
+
/* 0.4.4 */
|
|
2
2
|
export declare const DEFINITIONS_TRIGONOMETRY: LatexDictionary;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.4.
|
|
1
|
+
/* 0.4.4 */
|
|
2
2
|
import { Serializer } from './serializer';
|
|
3
3
|
import { Expression } from '../../math-json/math-json-format';
|
|
4
4
|
import { WarningSignalHandler } from '../../common/signals';
|
|
@@ -6,7 +6,7 @@ import { IComputeEngine } from '../public';
|
|
|
6
6
|
export declare const DEFAULT_SERIALIZE_LATEX_OPTIONS: Required<SerializeLatexOptions>;
|
|
7
7
|
export declare class LatexSyntax {
|
|
8
8
|
onError: WarningSignalHandler;
|
|
9
|
-
options:
|
|
9
|
+
options: NumberFormattingOptions & ParseLatexOptions & SerializeLatexOptions;
|
|
10
10
|
readonly computeEngine: IComputeEngine;
|
|
11
11
|
private dictionary;
|
|
12
12
|
private _serializer?;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
/* 0.4.
|
|
1
|
+
/* 0.4.4 */
|
|
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';
|
|
5
5
|
import { IComputeEngine } from '../public';
|
|
6
|
-
export declare const DEFAULT_LATEX_NUMBER_OPTIONS:
|
|
7
|
-
export declare const DEFAULT_PARSE_LATEX_OPTIONS:
|
|
6
|
+
export declare const DEFAULT_LATEX_NUMBER_OPTIONS: NumberFormattingOptions;
|
|
7
|
+
export declare const DEFAULT_PARSE_LATEX_OPTIONS: ParseLatexOptions;
|
|
8
8
|
export declare class _Parser implements Parser {
|
|
9
9
|
readonly onError: WarningSignalHandler;
|
|
10
|
-
readonly options:
|
|
10
|
+
readonly options: NumberFormattingOptions & ParseLatexOptions;
|
|
11
11
|
readonly engine: IComputeEngine;
|
|
12
12
|
readonly _dictionary: IndexedLatexDictionary;
|
|
13
13
|
index: number;
|
|
14
14
|
_lastPeek: string;
|
|
15
15
|
_peekCounter: number;
|
|
16
16
|
readonly _tokens: LatexToken[];
|
|
17
|
-
constructor(tokens: LatexToken[], options:
|
|
17
|
+
constructor(tokens: LatexToken[], options: NumberFormattingOptions & ParseLatexOptions, dictionary: IndexedLatexDictionary, computeEngine: IComputeEngine, onError: WarningSignalHandler);
|
|
18
18
|
updateOptions(opt: Partial<NumberFormattingOptions> & Partial<ParseLatexOptions>): void;
|
|
19
19
|
clone(start: number, end: number): Parser;
|
|
20
20
|
get atEnd(): boolean;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/* 0.4.
|
|
1
|
+
/* 0.4.4 */
|
|
2
2
|
import { NumberFormattingOptions } from './public';
|
|
3
|
-
export declare function serializeNumber(expr: Expression | null, options:
|
|
4
|
-
export declare function serializeEngineeringNotationNumber(value: number, options:
|
|
3
|
+
export declare function serializeNumber(expr: Expression | null, options: NumberFormattingOptions): string;
|
|
4
|
+
export declare function serializeEngineeringNotationNumber(value: number, options: NumberFormattingOptions): string;
|
|
5
5
|
/**
|
|
6
6
|
* `value` is a base-10 number, possibly a floating point number with an
|
|
7
7
|
* exponent, i.e. "0.31415e1"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.4.
|
|
1
|
+
/* 0.4.4 */
|
|
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,15 +1,15 @@
|
|
|
1
|
-
/* 0.4.
|
|
1
|
+
/* 0.4.4 */
|
|
2
2
|
import { NumberFormattingOptions, LatexString, SerializeLatexOptions } from './public';
|
|
3
3
|
import { IndexedLatexDictionary, SymbolEntry } from './dictionary/definitions';
|
|
4
4
|
import { WarningSignalHandler } from '../../common/signals';
|
|
5
5
|
import { IComputeEngine } from '../public';
|
|
6
6
|
export declare class Serializer {
|
|
7
7
|
readonly onError: WarningSignalHandler;
|
|
8
|
-
options:
|
|
8
|
+
options: NumberFormattingOptions & SerializeLatexOptions;
|
|
9
9
|
readonly computeEngine?: IComputeEngine;
|
|
10
10
|
readonly dictionary: IndexedLatexDictionary;
|
|
11
11
|
level: number;
|
|
12
|
-
constructor(options:
|
|
12
|
+
constructor(options: NumberFormattingOptions & SerializeLatexOptions, dictionary: IndexedLatexDictionary, computeEngine: undefined | IComputeEngine, onError: WarningSignalHandler);
|
|
13
13
|
updateOptions(opt: Partial<NumberFormattingOptions> & Partial<SerializeLatexOptions>): void;
|
|
14
14
|
/**
|
|
15
15
|
* Serialize the expression, and if the expression is an operator
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.4.
|
|
1
|
+
/* 0.4.4 */
|
|
2
2
|
export declare function isPrime(n: number): boolean | undefined;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
/* 0.4.
|
|
1
|
+
/* 0.4.4 */
|
|
2
2
|
import type { Complex } from 'complex.js';
|
|
3
|
-
import { SignalMessage, WarningSignal, WarningSignalHandler } from '../common/signals';
|
|
4
|
-
import { Expression, MathJsonDictionary, MathJsonFunction, MathJsonNumber, MathJsonString, MathJsonSymbol } from '../math-json/math-json-format';
|
|
5
|
-
import { NumberFormattingOptions, ParseLatexOptions, SerializeLatexOptions } from '
|
|
6
|
-
export
|
|
7
|
-
export declare const DEBUG = true;
|
|
3
|
+
import type { SignalMessage, WarningSignal, WarningSignalHandler } from '../common/signals';
|
|
4
|
+
import type { Expression, MathJsonDictionary, MathJsonFunction, MathJsonNumber, MathJsonString, MathJsonSymbol } from '../math-json/math-json-format';
|
|
5
|
+
import type { NumberFormattingOptions, ParseLatexOptions, SerializeLatexOptions } from './latex-syntax/public';
|
|
6
|
+
export type { Parser } from './latex-syntax/public';
|
|
8
7
|
/**
|
|
9
8
|
* Metadata that can be associated with a BoxedExpression
|
|
10
9
|
*/
|
|
@@ -146,12 +145,12 @@ export declare type JsonSerializationOptions = {
|
|
|
146
145
|
/**
|
|
147
146
|
* **Theory of Operations**
|
|
148
147
|
*
|
|
149
|
-
* The `BoxedExpression` interface includes most of the
|
|
150
|
-
* to any kind of expression, for example `get
|
|
151
|
-
* `get
|
|
148
|
+
* The `BoxedExpression` interface includes most of the member functions
|
|
149
|
+
* applicable to any kind of expression, for example `get symbol()` or
|
|
150
|
+
* `get ops()`.
|
|
152
151
|
*
|
|
153
|
-
* When
|
|
154
|
-
* `BoxedNumber`,
|
|
152
|
+
* When a member function is not applicable to this `BoxedExpression`,
|
|
153
|
+
* for example `get symbol()` on a `BoxedNumber`, it returns `null`.
|
|
155
154
|
*
|
|
156
155
|
* This convention makes it convenient to manipulate expressions without
|
|
157
156
|
* having to check what kind of instance they are before manipulating them.
|
|
@@ -163,19 +162,31 @@ export interface BoxedExpression {
|
|
|
163
162
|
* and functions.
|
|
164
163
|
*/
|
|
165
164
|
readonly engine: IComputeEngine;
|
|
166
|
-
/** From Object.valueOf()
|
|
165
|
+
/** From `Object.valueOf()`, return a primitive value for the expression.
|
|
166
|
+
*
|
|
167
|
+
* If the expression is a machine number, or a Decimal that can be
|
|
168
|
+
* converted to a machine number, return a `number`.
|
|
169
|
+
*
|
|
170
|
+
* If the expression is a rational number, return `[number, number]`.
|
|
171
|
+
*
|
|
172
|
+
* If the expression is a symbol, return the name of the symbol as a `string`.
|
|
173
|
+
*
|
|
174
|
+
* Otherwise return a LaTeX representation of the expression.
|
|
175
|
+
*
|
|
176
|
+
*/
|
|
167
177
|
valueOf(): number | string | [number, number];
|
|
168
|
-
/** From Object.toString() */
|
|
178
|
+
/** From `Object.toString()`, return a LaTeX representation of the expression. */
|
|
169
179
|
toString(): string;
|
|
170
|
-
/** From Object.toJSON()
|
|
180
|
+
/** From `Object.toJSON()`, equivalent to `JSON.stringify(this.json)` */
|
|
171
181
|
toJSON(): string;
|
|
172
|
-
/** From Object.is()
|
|
182
|
+
/** From `Object.is()`. Equivalent to `expr.isSame()` */
|
|
173
183
|
is(rhs: any): boolean;
|
|
174
184
|
get hash(): number;
|
|
175
|
-
/**
|
|
176
|
-
*
|
|
185
|
+
/** An optional short description of the symbol or function head.
|
|
186
|
+
*
|
|
187
|
+
* May include markdown. Each string is a paragraph. */
|
|
177
188
|
readonly description: string[];
|
|
178
|
-
/**
|
|
189
|
+
/** An optional URL pointing to more information about the symbol or function head */
|
|
179
190
|
readonly url: string;
|
|
180
191
|
/** All boxed expressions have a head.
|
|
181
192
|
*
|
|
@@ -191,7 +202,7 @@ export interface BoxedExpression {
|
|
|
191
202
|
*/
|
|
192
203
|
get value(): BoxedExpression | undefined;
|
|
193
204
|
/** Only the value of variables can be changed (symbols that are not constants) */
|
|
194
|
-
set value(value: BoxedExpression | undefined);
|
|
205
|
+
set value(value: BoxedExpression | number | undefined);
|
|
195
206
|
/** Return an approximation of the value of this expression. Floating-point
|
|
196
207
|
* operations may be performed.
|
|
197
208
|
*
|
|
@@ -233,10 +244,19 @@ export interface BoxedExpression {
|
|
|
233
244
|
get op2(): BoxedExpression;
|
|
234
245
|
/** Third operand, i.e. third element of `this.tail` */
|
|
235
246
|
get op3(): BoxedExpression;
|
|
236
|
-
/** The keys of the dictionary.
|
|
247
|
+
/** The keys of the dictionary.
|
|
248
|
+
*
|
|
249
|
+
* If this expression not a dictionary, return `null` */
|
|
237
250
|
get keys(): IterableIterator<string> | null;
|
|
238
251
|
get keysCount(): number;
|
|
252
|
+
/**
|
|
253
|
+
* If this expression is a dictionary, return the value of the `key` entry.
|
|
254
|
+
*/
|
|
239
255
|
getKey(key: string): BoxedExpression | undefined;
|
|
256
|
+
/**
|
|
257
|
+
* If this expression is a dictionary, return true if the dictionary has a
|
|
258
|
+
* `key` entry.
|
|
259
|
+
*/
|
|
240
260
|
hasKey(key: string): boolean;
|
|
241
261
|
/**
|
|
242
262
|
* Return the value of this number or symbol, if stored as a machine number.
|
|
@@ -335,7 +355,7 @@ export interface BoxedExpression {
|
|
|
335
355
|
* Otherwise, return `null`.
|
|
336
356
|
*/
|
|
337
357
|
get string(): string | null;
|
|
338
|
-
/** True if this domain is a subset of domain d */
|
|
358
|
+
/** True if this domain is a subset of domain `d` */
|
|
339
359
|
isSubsetOf(d: BoxedExpression | string): undefined | boolean;
|
|
340
360
|
/** True if the value of this expression is a number.
|
|
341
361
|
*
|
|
@@ -409,20 +429,25 @@ export interface BoxedExpression {
|
|
|
409
429
|
get isComposite(): boolean | undefined;
|
|
410
430
|
/** Structural/symbolic equality (weak equality).
|
|
411
431
|
*
|
|
412
|
-
* `ce.parse('1+x').isSame(ce.parse('x+1'))` is `
|
|
432
|
+
* `ce.parse('1+x').isSame(ce.parse('x+1'))` is `false`
|
|
413
433
|
*
|
|
414
434
|
*/
|
|
415
435
|
isSame(rhs: BoxedExpression): boolean;
|
|
416
436
|
/**
|
|
417
|
-
* True if the expression includes a symbol `v
|
|
437
|
+
* True if the expression includes a symbol `v` or a function head `v`.
|
|
418
438
|
*/
|
|
419
439
|
has(v: string | string[]): boolean;
|
|
420
|
-
/** Attempt to match this
|
|
440
|
+
/** Attempt to match this expression to the `rhs` expression.
|
|
421
441
|
*
|
|
422
442
|
* If `rhs` does not match, return `null`.
|
|
423
|
-
*
|
|
424
|
-
*
|
|
425
|
-
*
|
|
443
|
+
*
|
|
444
|
+
* Otherwise return an object literal.
|
|
445
|
+
*
|
|
446
|
+
* If this expression includes wildcards (symbols with a name that starts
|
|
447
|
+
* with `_`), the object literal will include a prop for each matching named
|
|
448
|
+
* wildcard.
|
|
449
|
+
*
|
|
450
|
+
* If `rhs` matches this pattern but there are no named wildcards, return
|
|
426
451
|
* the empty object literal, `{}`.
|
|
427
452
|
*/
|
|
428
453
|
match(rhs: BoxedExpression, options?: PatternMatchOption): Substitution | null;
|
|
@@ -432,7 +457,7 @@ export interface BoxedExpression {
|
|
|
432
457
|
* Both expressions are numerically evaluated.
|
|
433
458
|
*
|
|
434
459
|
* Numbers whose difference is less than `engine.tolerance` are
|
|
435
|
-
* considered equal. This
|
|
460
|
+
* considered equal. This tolerance is set when the `engine.precision` is
|
|
436
461
|
* changed to be such that the last two digits are ignored.
|
|
437
462
|
*/
|
|
438
463
|
isEqual(rhs: BoxedExpression): boolean;
|
|
@@ -526,7 +551,7 @@ export interface BoxedExpression {
|
|
|
526
551
|
* example modifying the `ComputeEngine` environment, such as its set of assumptions.
|
|
527
552
|
*
|
|
528
553
|
* Only exact calculations are performed, no floating point calculations.
|
|
529
|
-
* To perform approximate floating point calculations, use `N()` instead.
|
|
554
|
+
* To perform approximate floating point calculations, use `expr.N()` instead.
|
|
530
555
|
*
|
|
531
556
|
* The result of `expr.evaluate()` may be the same as `expr.simplify()`.
|
|
532
557
|
*
|
|
@@ -542,7 +567,10 @@ export interface BoxedExpression {
|
|
|
542
567
|
* are performed. The calculations are performed according
|
|
543
568
|
* to the `numericMode` and `precision` properties of the `ComputeEngine`.
|
|
544
569
|
*
|
|
545
|
-
*
|
|
570
|
+
* To only perform exact calculations, use `expr.evaluate()` instead.
|
|
571
|
+
*
|
|
572
|
+
* If the function is not numeric, the result of `expr.N()` is the same as
|
|
573
|
+
* `expr.evaluate()`.
|
|
546
574
|
*
|
|
547
575
|
* The result is in canonical form.
|
|
548
576
|
*/
|
|
@@ -564,13 +592,15 @@ export interface BoxedExpression {
|
|
|
564
592
|
* the matching `lhs` of a rule is replaced by its `rhs`.
|
|
565
593
|
*
|
|
566
594
|
* If no rules apply, return `null`.
|
|
595
|
+
*
|
|
596
|
+
* See also `subs` for a simple substitution.
|
|
567
597
|
*/
|
|
568
598
|
replace(rules: BoxedRuleSet, options?: ReplaceOptions): null | BoxedExpression;
|
|
569
599
|
/**
|
|
570
600
|
* Replace all the symbols in the expression as indicated.
|
|
571
601
|
*
|
|
572
602
|
* Note the same effect can be achieved with `expr.replace()`, but
|
|
573
|
-
*
|
|
603
|
+
* using `expr.subs()` is more efficient, and simpler.
|
|
574
604
|
*
|
|
575
605
|
*/
|
|
576
606
|
subs(sub: Substitution): BoxedExpression;
|
|
@@ -581,7 +611,10 @@ export interface BoxedExpression {
|
|
|
581
611
|
* For internal use only.
|
|
582
612
|
*/
|
|
583
613
|
_repairDefinition(): void;
|
|
584
|
-
/** Purge any cached values
|
|
614
|
+
/** Purge any cached values.
|
|
615
|
+
*
|
|
616
|
+
* For internal use only.
|
|
617
|
+
*/
|
|
585
618
|
_purge(): undefined;
|
|
586
619
|
}
|
|
587
620
|
/** A semi boxed expression is an MathJSON expression which can include some
|
|
@@ -870,7 +903,7 @@ export declare type FunctionDefinition = BaseDefinition & Partial<FunctionDefini
|
|
|
870
903
|
* Logic: 10000-10999
|
|
871
904
|
* Relational: 11000-11999
|
|
872
905
|
*
|
|
873
|
-
* **Default**: 100,000
|
|
906
|
+
* **Default**: 100,000
|
|
874
907
|
*/
|
|
875
908
|
complexity?: number;
|
|
876
909
|
/**
|
|
@@ -1260,8 +1293,8 @@ export interface IComputeEngine {
|
|
|
1260
1293
|
* a LaTeX string
|
|
1261
1294
|
*/
|
|
1262
1295
|
serialize(expr: SemiBoxedExpression): LatexString;
|
|
1263
|
-
get latexOptions():
|
|
1264
|
-
set latexOptions(opts: NumberFormattingOptions & ParseLatexOptions & SerializeLatexOptions);
|
|
1296
|
+
get latexOptions(): NumberFormattingOptions & ParseLatexOptions & SerializeLatexOptions;
|
|
1297
|
+
set latexOptions(opts: Partial<NumberFormattingOptions> & Partial<ParseLatexOptions> & Partial<SerializeLatexOptions>);
|
|
1265
1298
|
get jsonSerializationOptions(): JsonSerializationOptions;
|
|
1266
1299
|
set jsonSerializationOptions(val: Partial<JsonSerializationOptions>);
|
|
1267
1300
|
assume(symbol: LatexString | SemiBoxedExpression, domain: BoxedExpression): AssumeResult;
|