@cortex-js/compute-engine 0.15.0 → 0.16.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 +3246 -1703
- package/dist/compute-engine.js +3246 -1703
- package/dist/compute-engine.min.esm.js +3246 -1705
- package/dist/compute-engine.min.js +3246 -1705
- 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/ansi-codes.d.ts +15 -0
- 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 +2 -2
- package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +9 -12
- package/dist/types/compute-engine/boxed-expression/box.d.ts +8 -3
- package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +3 -3
- package/dist/types/compute-engine/boxed-expression/boxed-domain.d.ts +6 -6
- package/dist/types/compute-engine/boxed-expression/boxed-function-definition.d.ts +27 -1
- package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +7 -19
- 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 +11 -10
- package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +17 -11
- 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 +30 -9
- package/dist/types/compute-engine/boxed-expression/validate.d.ts +1 -1
- package/dist/types/compute-engine/compile.d.ts +1 -1
- package/dist/types/compute-engine/compute-engine.d.ts +55 -23
- package/dist/types/compute-engine/cost-function.d.ts +1 -1
- package/dist/types/compute-engine/domain-utils.d.ts +4 -19
- package/dist/types/compute-engine/function-utils.d.ts +84 -0
- 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-complex.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-statistics.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-identifier.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/parse.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/public.d.ts +19 -5
- 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/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 +3 -2
- package/dist/types/compute-engine/library/calculus.d.ts +2 -2
- package/dist/types/compute-engine/library/collections.d.ts +2 -2
- package/dist/types/compute-engine/library/complex.d.ts +2 -2
- package/dist/types/compute-engine/library/control-structures.d.ts +2 -0
- package/dist/types/compute-engine/library/core.d.ts +2 -2
- package/dist/types/compute-engine/library/domains.d.ts +7 -8
- package/dist/types/compute-engine/library/library.d.ts +5 -5
- package/dist/types/compute-engine/library/linear-algebra.d.ts +2 -0
- package/dist/types/compute-engine/library/logic.d.ts +2 -2
- package/dist/types/compute-engine/library/polynomials.d.ts +2 -2
- package/dist/types/compute-engine/library/random-expression.d.ts +1 -1
- package/dist/types/compute-engine/library/relational-operator.d.ts +2 -2
- package/dist/types/compute-engine/library/sets.d.ts +2 -2
- package/dist/types/compute-engine/library/statistics.d.ts +2 -2
- package/dist/types/compute-engine/library/trigonometry.d.ts +2 -2
- package/dist/types/compute-engine/library/utils.d.ts +3 -3
- package/dist/types/compute-engine/numerics/numeric-bigint.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric-bignum.d.ts +3 -2
- package/dist/types/compute-engine/numerics/numeric-complex.d.ts +2 -2
- package/dist/types/compute-engine/numerics/numeric.d.ts +60 -2
- 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 +205 -91
- 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/derivative.d.ts +6 -0
- 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 +23 -21
package/dist/math-json.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** CortexJS Compute Engine 0.
|
|
1
|
+
/** CortexJS Compute Engine 0.16.0 */
|
|
2
2
|
|
|
3
3
|
// src/math-json/utils.ts
|
|
4
4
|
function isSymbolObject(expr) {
|
|
@@ -239,7 +239,7 @@ function mapArgs(expr, fn) {
|
|
|
239
239
|
}
|
|
240
240
|
|
|
241
241
|
// src/math-json.ts
|
|
242
|
-
var version = "0.
|
|
242
|
+
var version = "0.16.0";
|
|
243
243
|
export {
|
|
244
244
|
applyRecursively,
|
|
245
245
|
dictionary as getDictionary,
|
package/dist/math-json.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** CortexJS MathJSON 0.
|
|
1
|
+
/** CortexJS MathJSON 0.16.0 */
|
|
2
2
|
(function(global,factory){typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'],factory):(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.MathJson = {}));})(this, (function (exports) { 'use strict';
|
|
3
3
|
var MathJson = (() => {
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
@@ -277,7 +277,7 @@ var MathJson = (() => {
|
|
|
277
277
|
}
|
|
278
278
|
|
|
279
279
|
// src/math-json.ts
|
|
280
|
-
var version = "0.
|
|
280
|
+
var version = "0.16.0";
|
|
281
281
|
return __toCommonJS(math_json_exports);
|
|
282
282
|
})();
|
|
283
283
|
Object.assign(exports, MathJson); Object.defineProperty(exports, '__esModule', { value: true });}));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** CortexJS Compute Engine 0.
|
|
1
|
+
/** CortexJS Compute Engine 0.16.0 */
|
|
2
2
|
|
|
3
3
|
// src/math-json/utils.ts
|
|
4
4
|
function isSymbolObject(expr) {
|
|
@@ -239,7 +239,7 @@ function mapArgs(expr, fn) {
|
|
|
239
239
|
}
|
|
240
240
|
|
|
241
241
|
// src/math-json.ts
|
|
242
|
-
var version = "0.
|
|
242
|
+
var version = "0.16.0";
|
|
243
243
|
export {
|
|
244
244
|
applyRecursively,
|
|
245
245
|
dictionary as getDictionary,
|
package/dist/math-json.min.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** CortexJS MathJSON 0.
|
|
1
|
+
/** CortexJS MathJSON 0.16.0 */
|
|
2
2
|
(function(global,factory){typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'],factory):(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.MathJson = {}));})(this, (function (exports) { 'use strict';
|
|
3
3
|
var MathJson = (() => {
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
@@ -277,7 +277,7 @@ var MathJson = (() => {
|
|
|
277
277
|
}
|
|
278
278
|
|
|
279
279
|
// src/math-json.ts
|
|
280
|
-
var version = "0.
|
|
280
|
+
var version = "0.16.0";
|
|
281
281
|
return __toCommonJS(math_json_exports);
|
|
282
282
|
})();
|
|
283
283
|
Object.assign(exports, MathJson); Object.defineProperty(exports, '__esModule', { value: true });}));
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/* 0.16.0 */
|
|
2
|
+
export declare const BLACK = "\u001B[30;1m${s}";
|
|
3
|
+
export declare const GREY = "\u001B[30;1m${s}";
|
|
4
|
+
export declare const GREEN = "\u001B[32;1m";
|
|
5
|
+
export declare const RED = "\u001B[31;1m";
|
|
6
|
+
export declare const YELLOW = "\u001B[33m";
|
|
7
|
+
export declare const BLUE = "\u001B[34;1m";
|
|
8
|
+
export declare const MAGENTA = "\u001B[35;1m";
|
|
9
|
+
export declare const CYAN = "\u001B[36;1m";
|
|
10
|
+
export declare const INVERSE_RED = "\u001B[101;97m";
|
|
11
|
+
export declare const INVERSE_GREEN = "\u001B[102;97m";
|
|
12
|
+
export declare const INVERSE_YELLOW = "\u001B[103;97m";
|
|
13
|
+
export declare const INVERSE_BLUE = "\u001B[104;97m";
|
|
14
|
+
export declare const BOLD = "\u001B[1m";
|
|
15
|
+
export declare const GREY_BG = "\u001B[40;1m";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.16.0 */
|
|
2
2
|
export type SignalCode = RuntimeSignalCode | ('invalid-name' | 'expected-predicate' | 'expected-symbol' | 'operator-requires-one-operand' | 'postfix-operator-requires-one-operand' | 'prefix-operator-requires-one-operand' | 'unbalanced-symbols' | 'expected-argument' | 'unexpected-command' | 'cyclic-definition' | 'invalid-supersets' | 'expected-supersets' | 'unknown-domain' | 'duplicate-wikidata' | 'invalid-dictionary-entry' | 'syntax-error');
|
|
3
3
|
export type SignalMessage = SignalCode | [SignalCode, ...any[]];
|
|
4
4
|
export type SignalOrigin = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.16.0 */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.16.0 */
|
|
2
2
|
/**
|
|
3
3
|
* Add an assumption, in the form of a predicate, for example:
|
|
4
4
|
*
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*
|
|
10
10
|
* Some assumptions are handled separately, specifically, those that can
|
|
11
11
|
* be represented as a symbol definition (equality to an expression,
|
|
12
|
-
* membership to
|
|
12
|
+
* membership to Integers, RealNumbers, etc..., >0, <=0, etc...). The result
|
|
13
13
|
* of these are stored directly in the current scope's symbols dictionary
|
|
14
14
|
* (and an entry for the symbol is created if necessary).
|
|
15
15
|
*
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.16.0 */
|
|
2
2
|
import { Complex } from 'complex.js';
|
|
3
3
|
import { Expression } from '../../math-json/math-json-format';
|
|
4
4
|
import { BoxedExpression, BoxedFunctionDefinition, BoxedRuleSet, BoxedSymbolDefinition, BoxedDomain, EvaluateOptions, IComputeEngine, LatexString, Metadata, NOptions, PatternMatchOptions, SemiBoxedExpression, SimplifyOptions, Substitution, RuntimeScope, DomainCompatibility, DomainLiteral, BoxedBaseDefinition, Rational, BoxedSubstitution } from '../public';
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* _BoxedExpression
|
|
7
7
|
*/
|
|
8
|
-
export declare abstract class
|
|
8
|
+
export declare abstract class _BoxedExpression implements BoxedExpression {
|
|
9
9
|
abstract readonly hash: number;
|
|
10
10
|
abstract readonly json: Expression;
|
|
11
11
|
abstract readonly head: BoxedExpression | string;
|
|
@@ -15,11 +15,10 @@ export declare abstract class AbstractBoxedExpression implements BoxedExpression
|
|
|
15
15
|
abstract isEqual(rhs: BoxedExpression): boolean;
|
|
16
16
|
abstract match(rhs: BoxedExpression, options?: PatternMatchOptions): BoxedSubstitution | null;
|
|
17
17
|
readonly engine: IComputeEngine;
|
|
18
|
-
/** Verbatim LaTeX, obtained from a source, i.e. from parsing,
|
|
19
|
-
* synthetically
|
|
18
|
+
/** Verbatim LaTeX, obtained from a source, i.e. from parsing,
|
|
19
|
+
* not generated synthetically
|
|
20
20
|
*/
|
|
21
21
|
protected _latex?: string;
|
|
22
|
-
protected _wikidata: string | undefined;
|
|
23
22
|
constructor(ce: IComputeEngine, metadata?: Metadata);
|
|
24
23
|
/** `Object.valueOf()`: return a primitive value for the object
|
|
25
24
|
*
|
|
@@ -43,7 +42,8 @@ export declare abstract class AbstractBoxedExpression implements BoxedExpression
|
|
|
43
42
|
getSubexpressions(head: string): BoxedExpression[];
|
|
44
43
|
get subexpressions(): BoxedExpression[];
|
|
45
44
|
get symbols(): string[];
|
|
46
|
-
get
|
|
45
|
+
get unknowns(): string[];
|
|
46
|
+
get freeVariables(): string[];
|
|
47
47
|
get errors(): BoxedExpression[];
|
|
48
48
|
get ops(): null | BoxedExpression[];
|
|
49
49
|
get nops(): number;
|
|
@@ -53,8 +53,6 @@ export declare abstract class AbstractBoxedExpression implements BoxedExpression
|
|
|
53
53
|
get isValid(): boolean;
|
|
54
54
|
get isPure(): boolean;
|
|
55
55
|
get isExact(): boolean;
|
|
56
|
-
/** For a symbol, true if the symbol is a free variable (no value) */
|
|
57
|
-
get isFree(): boolean;
|
|
58
56
|
/** For a symbol, true if the symbol is a constant (unchangeable value) */
|
|
59
57
|
get isConstant(): boolean;
|
|
60
58
|
get canonical(): BoxedExpression;
|
|
@@ -90,11 +88,11 @@ export declare abstract class AbstractBoxedExpression implements BoxedExpression
|
|
|
90
88
|
get description(): string[] | undefined;
|
|
91
89
|
get url(): string | undefined;
|
|
92
90
|
get wikidata(): string | undefined;
|
|
93
|
-
set wikidata(val: string | undefined);
|
|
94
91
|
get complexity(): number | undefined;
|
|
95
|
-
get
|
|
92
|
+
get baseDefinition(): BoxedBaseDefinition | undefined;
|
|
96
93
|
get symbolDefinition(): BoxedSymbolDefinition | undefined;
|
|
97
94
|
get functionDefinition(): BoxedFunctionDefinition | undefined;
|
|
95
|
+
infer(_domain: BoxedDomain): boolean;
|
|
98
96
|
bind(_scope: RuntimeScope | null): void;
|
|
99
97
|
unbind(): void;
|
|
100
98
|
get keys(): IterableIterator<string> | null;
|
|
@@ -105,7 +103,6 @@ export declare abstract class AbstractBoxedExpression implements BoxedExpression
|
|
|
105
103
|
set value(_value: BoxedExpression | number | undefined);
|
|
106
104
|
get domain(): BoxedDomain;
|
|
107
105
|
set domain(_domain: BoxedDomain);
|
|
108
|
-
get explicitDomain(): BoxedDomain | undefined;
|
|
109
106
|
get isNumber(): boolean | undefined;
|
|
110
107
|
get isInteger(): boolean | undefined;
|
|
111
108
|
get isRational(): boolean | undefined;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.16.0 */
|
|
2
2
|
import { Decimal } from 'decimal.js';
|
|
3
3
|
import { IComputeEngine, SemiBoxedExpression, BoxedExpression, Metadata, Rational } from '../public';
|
|
4
4
|
import { MathJsonNumber } from '../../math-json/math-json-format';
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* ## THEORY OF OPERATIONS
|
|
7
7
|
*
|
|
8
8
|
* 1/ Boxing does not depend on the numeric mode. The numeric mode could be
|
|
9
9
|
* changed later, but the previously boxed numbers could not be retroactively
|
|
@@ -20,7 +20,12 @@ import { MathJsonNumber } from '../../math-json/math-json-format';
|
|
|
20
20
|
* which is canonical from the start avoid going through an intermediary step
|
|
21
21
|
* with a non-canonical expression.
|
|
22
22
|
*
|
|
23
|
-
* 3/ When
|
|
23
|
+
* 3/ When boxing (and canonicalizing), if the function is "scoped", a new
|
|
24
|
+
* scope is created before the canonicalization, so that any declaration
|
|
25
|
+
* are done within that scope. Example of scoped functions include `Block`
|
|
26
|
+
* and `Sum`.
|
|
27
|
+
*
|
|
28
|
+
* 4/ When implementing an `evaluate()`:
|
|
24
29
|
* - if `bignumPreferred()` all operations should be done in bignum and complex,
|
|
25
30
|
* otherwise, they should all be done in machine numbers and complex.
|
|
26
31
|
* - if not `complexAllowed()`, return `NaN` if a complex value is encountered
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.16.0 */
|
|
2
2
|
import { BoxedExpression, IComputeEngine, EvaluateOptions, NOptions, BoxedRuleSet, SemiBoxedExpression, SimplifyOptions, ReplaceOptions, Substitution, Metadata, PatternMatchOptions, BoxedDomain, BoxedSubstitution } from '../public';
|
|
3
|
-
import {
|
|
3
|
+
import { _BoxedExpression } from './abstract-boxed-expression';
|
|
4
4
|
/**
|
|
5
5
|
* BoxedDictionary
|
|
6
6
|
*/
|
|
7
|
-
export declare class BoxedDictionary extends
|
|
7
|
+
export declare class BoxedDictionary extends _BoxedExpression {
|
|
8
8
|
private _value;
|
|
9
9
|
private _isCanonical;
|
|
10
10
|
constructor(ce: IComputeEngine, dict: {
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.16.0 */
|
|
2
2
|
import { BoxedDomain, BoxedExpression, BoxedSubstitution, DomainCompatibility, DomainConstructor, DomainExpression, DomainLiteral, IComputeEngine, Metadata, PatternMatchOptions } from '../public';
|
|
3
|
-
import {
|
|
3
|
+
import { _BoxedExpression } from './abstract-boxed-expression';
|
|
4
4
|
/**
|
|
5
5
|
* A `_BoxedDomain` is a wrapper around a boxed, canonical, domain expression.
|
|
6
6
|
*
|
|
7
7
|
* If could also be an error, in which case, `isValid` is `false`.
|
|
8
8
|
*
|
|
9
9
|
*/
|
|
10
|
-
export declare class _BoxedDomain extends
|
|
10
|
+
export declare class _BoxedDomain extends _BoxedExpression implements BoxedDomain {
|
|
11
11
|
/** The value of a boxed domain is either a string if a domain literal, or a
|
|
12
12
|
* domain constructor function.
|
|
13
13
|
* Since the domains are alway canonicalized when boxed, their value can
|
|
14
14
|
* be represented by a simple array, without the need for extra boxing.
|
|
15
15
|
*/
|
|
16
|
-
_value: DomainExpression<BoxedExpression>;
|
|
16
|
+
_value: DomainLiteral | DomainExpression<BoxedExpression>;
|
|
17
17
|
private _hash;
|
|
18
18
|
constructor(ce: IComputeEngine, dom: DomainExpression, metadata?: Metadata);
|
|
19
19
|
get isCanonical(): boolean;
|
|
@@ -24,7 +24,6 @@ export declare class _BoxedDomain extends AbstractBoxedExpression implements Box
|
|
|
24
24
|
get literal(): string | null;
|
|
25
25
|
get ctor(): DomainConstructor | null;
|
|
26
26
|
get domainArgs(): (string | BoxedExpression | DomainExpression<BoxedExpression>)[] | null;
|
|
27
|
-
get domainArg1(): string | BoxedExpression | DomainExpression<BoxedExpression> | null;
|
|
28
27
|
get codomain(): BoxedDomain | null;
|
|
29
28
|
get hash(): number;
|
|
30
29
|
isEqual(rhs: BoxedExpression): boolean;
|
|
@@ -48,4 +47,5 @@ export declare function boxDomain(ce: IComputeEngine, dom: BoxedExpression | Dom
|
|
|
48
47
|
export declare function isDomain(expr: Expression | BoxedExpression | BoxedDomain | DomainExpression): expr is BoxedDomain | DomainExpression;
|
|
49
48
|
export declare function isValidDomain(expr: any): expr is BoxedDomain | DomainExpression;
|
|
50
49
|
/** Return the ancestor domain that is shared by both `a` and `b` */
|
|
51
|
-
export declare function
|
|
50
|
+
export declare function widen(a: BoxedDomain | undefined | null, b: BoxedDomain | undefined | null): BoxedDomain;
|
|
51
|
+
export declare function narrow(a: BoxedDomain | undefined, b: BoxedDomain | undefined): BoxedDomain;
|
|
@@ -1,2 +1,28 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.16.0 */
|
|
2
|
+
export declare class _BoxedFunctionDefinition implements BoxedFunctionDefinition {
|
|
3
|
+
engine: IComputeEngine;
|
|
4
|
+
scope: RuntimeScope;
|
|
5
|
+
name: string;
|
|
6
|
+
description?: string | string[];
|
|
7
|
+
wikidata?: string;
|
|
8
|
+
threadable: boolean;
|
|
9
|
+
associative: boolean;
|
|
10
|
+
commutative: boolean;
|
|
11
|
+
idempotent: boolean;
|
|
12
|
+
involution: boolean;
|
|
13
|
+
pure: boolean;
|
|
14
|
+
inert: boolean;
|
|
15
|
+
numeric: boolean;
|
|
16
|
+
complexity: number;
|
|
17
|
+
hold: 'none' | 'all' | 'first' | 'rest' | 'last' | 'most';
|
|
18
|
+
dynamic: boolean;
|
|
19
|
+
signature: BoxedFunctionSignature;
|
|
20
|
+
iterator?: (expr: BoxedExpression, start?: number, count?: number) => Iterator<BoxedExpression>;
|
|
21
|
+
at?: (expr: BoxedExpression, index: number | string) => undefined | BoxedExpression;
|
|
22
|
+
size?: (expr: BoxedExpression) => number;
|
|
23
|
+
keys?: (expr: BoxedExpression) => undefined | Iterator<string>;
|
|
24
|
+
indexOf?: (expr: BoxedExpression, target: BoxedExpression, from?: number) => number | string | undefined;
|
|
25
|
+
constructor(ce: IComputeEngine, name: string, def: FunctionDefinition);
|
|
26
|
+
reset(): void;
|
|
27
|
+
}
|
|
2
28
|
export declare function makeFunctionDefinition(engine: IComputeEngine, name: string, def: FunctionDefinition | BoxedFunctionDefinition): BoxedFunctionDefinition;
|
|
@@ -1,28 +1,23 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.16.0 */
|
|
2
2
|
import { Expression } from '../../math-json/math-json-format';
|
|
3
|
-
import { BoxedExpression, BoxedFunctionDefinition, IComputeEngine, NOptions, BoxedRuleSet, SemiBoxedExpression, SimplifyOptions, Substitution, ReplaceOptions, Metadata, PatternMatchOptions, BoxedDomain, RuntimeScope, BoxedSubstitution, EvaluateOptions } from '../public';
|
|
3
|
+
import { BoxedExpression, BoxedFunctionDefinition, IComputeEngine, NOptions, BoxedRuleSet, SemiBoxedExpression, SimplifyOptions, Substitution, ReplaceOptions, Metadata, PatternMatchOptions, BoxedDomain, RuntimeScope, BoxedSubstitution, EvaluateOptions, BoxedBaseDefinition } from '../public';
|
|
4
4
|
/**
|
|
5
5
|
* BoxedFunction
|
|
6
6
|
*/
|
|
7
|
-
export declare class BoxedFunction extends
|
|
8
|
-
private _scope;
|
|
7
|
+
export declare class BoxedFunction extends _BoxedExpression {
|
|
9
8
|
private readonly _head;
|
|
10
9
|
private readonly _ops;
|
|
11
10
|
private _canonical;
|
|
11
|
+
private _scope;
|
|
12
12
|
private _def;
|
|
13
13
|
private _isPure;
|
|
14
|
-
/** The domain of the value of the function applied to its arguments */
|
|
15
14
|
private _codomain;
|
|
16
|
-
/** The cached values of applying the tail to the head.
|
|
17
|
-
* If the function is not pure, it is never cached.
|
|
18
|
-
*/
|
|
19
15
|
private _value;
|
|
20
16
|
private _numericValue;
|
|
21
17
|
private _hash;
|
|
22
18
|
constructor(ce: IComputeEngine, head: string | BoxedExpression, ops: BoxedExpression[], options?: {
|
|
23
19
|
metadata?: Metadata;
|
|
24
20
|
canonical?: boolean;
|
|
25
|
-
def?: BoxedFunctionDefinition;
|
|
26
21
|
});
|
|
27
22
|
get hash(): number;
|
|
28
23
|
get isCanonical(): boolean;
|
|
@@ -48,13 +43,11 @@ export declare class BoxedFunction extends AbstractBoxedExpression {
|
|
|
48
43
|
/** `isSame` is structural/symbolic equality */
|
|
49
44
|
isSame(rhs: BoxedExpression): boolean;
|
|
50
45
|
match(rhs: BoxedExpression, options?: PatternMatchOptions): BoxedSubstitution | null;
|
|
51
|
-
unbind(): void;
|
|
52
|
-
get wikidata(): string | undefined;
|
|
53
|
-
get description(): string[] | undefined;
|
|
54
|
-
get url(): string | undefined;
|
|
55
46
|
get complexity(): number | undefined;
|
|
47
|
+
get baseDefinition(): BoxedBaseDefinition | undefined;
|
|
56
48
|
get functionDefinition(): BoxedFunctionDefinition | undefined;
|
|
57
|
-
bind(_scope
|
|
49
|
+
bind(_scope?: RuntimeScope | null): void;
|
|
50
|
+
unbind(): void;
|
|
58
51
|
get value(): BoxedExpression | undefined;
|
|
59
52
|
/** `isEqual` is mathematical equality */
|
|
60
53
|
isEqual(rhs: BoxedExpression): boolean;
|
|
@@ -86,11 +79,6 @@ export declare class BoxedFunction extends AbstractBoxedExpression {
|
|
|
86
79
|
solve(vars: string[]): null | BoxedExpression[];
|
|
87
80
|
}
|
|
88
81
|
export declare function makeCanonicalFunction(ce: IComputeEngine, head: string | BoxedExpression, ops: SemiBoxedExpression[], metadata?: Metadata): BoxedExpression;
|
|
89
|
-
/** Apply arguments to an expression. If the expression is a lambda expression
|
|
90
|
-
* its wildcard arguments are substituted before being evaluated. Otherwise
|
|
91
|
-
* the expression is just evaluated.
|
|
92
|
-
*/
|
|
93
|
-
export declare function apply(fn: BoxedExpression, args: BoxedExpression[]): BoxedExpression;
|
|
94
82
|
/** Apply the function `f` to elements of `xs`, except to the elements
|
|
95
83
|
* described by `skip`:
|
|
96
84
|
* - `all`: don't apply f to any elements
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.16.0 */
|
|
2
2
|
import { Complex } from 'complex.js';
|
|
3
3
|
import { Expression } from '../../math-json/math-json-format';
|
|
4
4
|
import { BoxedExpression, BoxedDomain, IComputeEngine, Metadata, NOptions, PatternMatchOptions, Rational, SimplifyOptions, BoxedSubstitution } from '../public';
|
|
5
|
-
import {
|
|
5
|
+
import { _BoxedExpression } from './abstract-boxed-expression';
|
|
6
6
|
/**
|
|
7
7
|
* BoxedNumber
|
|
8
8
|
*/
|
|
9
|
-
export declare class BoxedNumber extends
|
|
9
|
+
export declare class BoxedNumber extends _BoxedExpression {
|
|
10
10
|
protected readonly _value: number | Decimal | Complex | Rational;
|
|
11
11
|
private _domain;
|
|
12
12
|
private _hash;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/* 0.
|
|
2
|
-
import {
|
|
1
|
+
/* 0.16.0 */
|
|
2
|
+
import { _BoxedExpression } from './abstract-boxed-expression';
|
|
3
3
|
import { BoxedExpression, BoxedSubstitution, BoxedDomain, IComputeEngine, LatexString, Metadata, Pattern, PatternMatchOptions, SemiBoxedExpression, Substitution } from '../public';
|
|
4
|
-
export declare class BoxedPattern extends
|
|
4
|
+
export declare class BoxedPattern extends _BoxedExpression implements Pattern {
|
|
5
5
|
_pattern: BoxedExpression;
|
|
6
6
|
constructor(ce: IComputeEngine, pattern: LatexString | SemiBoxedExpression, metadata?: Metadata);
|
|
7
7
|
get hash(): number;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
/* 0.
|
|
2
|
-
import {
|
|
1
|
+
/* 0.16.0 */
|
|
2
|
+
import { _BoxedExpression } from './abstract-boxed-expression';
|
|
3
3
|
import { BoxedExpression, BoxedDomain, IComputeEngine, Metadata, PatternMatchOptions, BoxedSubstitution } from '../public';
|
|
4
4
|
/**
|
|
5
5
|
* BoxedString
|
|
6
6
|
*/
|
|
7
|
-
export declare class BoxedString extends
|
|
7
|
+
export declare class BoxedString extends _BoxedExpression {
|
|
8
8
|
private readonly _string;
|
|
9
9
|
constructor(ce: IComputeEngine, expr: string, metadata?: Metadata);
|
|
10
10
|
get hash(): number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.16.0 */
|
|
2
2
|
/**
|
|
3
|
-
* THEORY OF OPERATIONS
|
|
3
|
+
* ## THEORY OF OPERATIONS
|
|
4
4
|
*
|
|
5
5
|
* - The value or domain of a constant cannot be changed.
|
|
6
6
|
* - If set explicitly, the value is the source of truth: it overrides any
|
|
@@ -18,24 +18,25 @@
|
|
|
18
18
|
* Otherwise, the stored flags are (the stored flags are also set when the domain is changed)
|
|
19
19
|
*
|
|
20
20
|
*/
|
|
21
|
-
export declare class
|
|
21
|
+
export declare class _BoxedSymbolDefinition implements BoxedSymbolDefinition {
|
|
22
22
|
readonly name: string;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
wikidata?: string;
|
|
24
|
+
description?: string | string[];
|
|
25
|
+
url?: string;
|
|
26
26
|
private _engine;
|
|
27
27
|
readonly scope: RuntimeScope | undefined;
|
|
28
28
|
private _defValue?;
|
|
29
29
|
private _value;
|
|
30
30
|
private _domain;
|
|
31
|
+
inferredDomain: boolean;
|
|
31
32
|
private _flags;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
private _at;
|
|
35
|
-
at?: (index: string | number) => undefined | BoxedExpression;
|
|
33
|
+
constant: boolean;
|
|
34
|
+
holdUntil: 'never' | 'simplify' | 'evaluate' | 'N';
|
|
36
35
|
prototype?: BoxedFunctionDefinition;
|
|
37
36
|
self?: unknown;
|
|
38
37
|
constructor(ce: IComputeEngine, name: string, def: SymbolDefinition);
|
|
38
|
+
/** The symbol was previously inferred, but now it has a declaration. Update the def accordingly (we can't replace defs, as other expressions may be referencing them) */
|
|
39
|
+
update(def: SymbolDefinition): void;
|
|
39
40
|
reset(): void;
|
|
40
41
|
get value(): BoxedExpression | undefined;
|
|
41
42
|
set value(val: SemiBoxedExpression | number | undefined);
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
/* 0.
|
|
2
|
-
import {
|
|
1
|
+
/* 0.16.0 */
|
|
2
|
+
import { _BoxedExpression } from './abstract-boxed-expression';
|
|
3
3
|
import { BoxedExpression, BoxedRuleSet, BoxedSymbolDefinition, IComputeEngine, EvaluateOptions, NOptions, ReplaceOptions, SimplifyOptions, Substitution, Metadata, PatternMatchOptions, BoxedDomain, RuntimeScope, BoxedFunctionDefinition, BoxedBaseDefinition, DomainExpression, BoxedSubstitution } from '../public';
|
|
4
|
+
import Complex from 'complex.js';
|
|
5
|
+
import Decimal from 'decimal.js';
|
|
4
6
|
/**
|
|
5
7
|
* BoxedSymbol
|
|
6
8
|
*
|
|
@@ -14,7 +16,7 @@ import { BoxedExpression, BoxedRuleSet, BoxedSymbolDefinition, IComputeEngine, E
|
|
|
14
16
|
* not a function expression, i.e. `Sin`, not `["Sin", "Pi"]`. This is used
|
|
15
17
|
* for example in `["InverseFunction", "Sin"]`
|
|
16
18
|
*/
|
|
17
|
-
export declare class BoxedSymbol extends
|
|
19
|
+
export declare class BoxedSymbol extends _BoxedExpression {
|
|
18
20
|
private _scope;
|
|
19
21
|
protected _name: string;
|
|
20
22
|
private _hash;
|
|
@@ -29,15 +31,10 @@ export declare class BoxedSymbol extends AbstractBoxedExpression {
|
|
|
29
31
|
get isPure(): boolean;
|
|
30
32
|
get json(): Expression;
|
|
31
33
|
get scope(): RuntimeScope | null;
|
|
32
|
-
/** A free variable either has no definition, or it has a definition, but no value */
|
|
33
|
-
get isFree(): boolean;
|
|
34
34
|
get isConstant(): boolean;
|
|
35
35
|
get isCanonical(): boolean;
|
|
36
36
|
set isCanonical(val: boolean);
|
|
37
37
|
get canonical(): BoxedExpression;
|
|
38
|
-
get wikidata(): string | undefined;
|
|
39
|
-
get description(): string[] | undefined;
|
|
40
|
-
get url(): string | undefined;
|
|
41
38
|
get complexity(): number;
|
|
42
39
|
get head(): string;
|
|
43
40
|
get symbol(): string;
|
|
@@ -45,12 +42,21 @@ export declare class BoxedSymbol extends AbstractBoxedExpression {
|
|
|
45
42
|
get baseDefinition(): BoxedBaseDefinition | undefined;
|
|
46
43
|
get symbolDefinition(): BoxedSymbolDefinition | undefined;
|
|
47
44
|
get functionDefinition(): BoxedFunctionDefinition | undefined;
|
|
48
|
-
|
|
45
|
+
/**
|
|
46
|
+
* Subsequence inferences will narrow the domain of the symbol.
|
|
47
|
+
* f(:integer), g(:real)
|
|
48
|
+
* g(x) => x:real
|
|
49
|
+
* f(x) => x:integer narrowed from integer to real
|
|
50
|
+
*/
|
|
51
|
+
infer(domain: BoxedDomain): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Associate a definition with this symbol, if one is not already available
|
|
54
|
+
*/
|
|
55
|
+
bind(scope?: RuntimeScope | null): void;
|
|
49
56
|
get value(): BoxedExpression | undefined;
|
|
50
|
-
set value(value: BoxedExpression | number | undefined);
|
|
57
|
+
set value(value: boolean | string | Decimal | Complex | [num: number, denom: number] | BoxedExpression | number | undefined);
|
|
51
58
|
get domain(): BoxedDomain;
|
|
52
59
|
set domain(inDomain: BoxedExpression | DomainExpression | BoxedDomain);
|
|
53
|
-
get explicitDomain(): BoxedDomain | undefined;
|
|
54
60
|
get sgn(): -1 | 0 | 1 | undefined | null;
|
|
55
61
|
has(x: string | string[]): boolean;
|
|
56
62
|
isSame(rhs: BoxedExpression): boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.16.0 */
|
|
2
2
|
import { Expression } from '../../math-json/math-json-format';
|
|
3
3
|
import { BoxedExpression, IComputeEngine } from '../public';
|
|
4
4
|
export declare function isLatexString(s: unknown): s is string;
|
|
@@ -12,15 +12,36 @@ export declare function latexString(s: unknown): string | null;
|
|
|
12
12
|
* - ['Multiply', 'ImaginaryUnit', 5]
|
|
13
13
|
*/
|
|
14
14
|
export declare function getImaginaryCoef(expr: BoxedExpression): number | null;
|
|
15
|
+
export declare function getSymbols(expr: BoxedExpression, result: Set<string>): void;
|
|
15
16
|
/**
|
|
16
|
-
* Return the
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*/
|
|
22
|
-
export declare function
|
|
23
|
-
|
|
17
|
+
* Return the unknowns in the expression, recursively.
|
|
18
|
+
*
|
|
19
|
+
* An unknown is an identifier (symbol or function) that is not bound
|
|
20
|
+
* to a value.
|
|
21
|
+
*
|
|
22
|
+
*/
|
|
23
|
+
export declare function getUnknowns(expr: BoxedExpression, result: Set<string>): void;
|
|
24
|
+
/**
|
|
25
|
+
* Return the free variables (non local variable) in the expression,
|
|
26
|
+
* recursively.
|
|
27
|
+
*
|
|
28
|
+
* A free variable is an identifier that is not an argument to a function,
|
|
29
|
+
* or a local variable.
|
|
30
|
+
*
|
|
31
|
+
*/
|
|
32
|
+
export declare function getFreeVariables(expr: BoxedExpression, result: Set<string>): void;
|
|
33
|
+
/** Return the local variables in the expression.
|
|
34
|
+
*
|
|
35
|
+
* A local variable is an identifier that is declared with a `Declare`
|
|
36
|
+
* expression in a `Block` expression.
|
|
37
|
+
*
|
|
38
|
+
* Note that the canonical form of a `Block` expression will hoist all
|
|
39
|
+
* `Declare` expressions to the top of the block. `Assign` expressions
|
|
40
|
+
* of undeclared variables will also have a matching `Declare` expressions
|
|
41
|
+
* hoisted.
|
|
42
|
+
*
|
|
43
|
+
*/
|
|
44
|
+
export declare function getLocalVariables(expr: BoxedExpression, result: Set<string>): void;
|
|
24
45
|
export declare function getSubexpressions(expr: BoxedExpression, head: string): BoxedExpression[];
|
|
25
46
|
/**
|
|
26
47
|
* For any numeric result, if `bignumPreferred()` is true, calculate using
|