@cortex-js/compute-engine 0.30.2 → 0.32.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.
Files changed (143) hide show
  1. package/package.json +10 -10
  2. package/dist/compute-engine.esm.js +0 -38978
  3. package/dist/compute-engine.min.esm.js +0 -129
  4. package/dist/compute-engine.min.umd.js +0 -131
  5. package/dist/compute-engine.umd.js +0 -39003
  6. package/dist/math-json.esm.js +0 -116
  7. package/dist/math-json.min.esm.js +0 -116
  8. package/dist/math-json.min.umd.js +0 -4
  9. package/dist/math-json.umd.js +0 -141
  10. package/dist/types/common/ansi-codes.d.ts +0 -41
  11. package/dist/types/common/configuration-change.d.ts +0 -28
  12. package/dist/types/common/fuzzy-string-match.d.ts +0 -2
  13. package/dist/types/common/grapheme-splitter.d.ts +0 -15
  14. package/dist/types/common/interruptible.d.ts +0 -20
  15. package/dist/types/common/one-of.d.ts +0 -10
  16. package/dist/types/common/signals.d.ts +0 -96
  17. package/dist/types/common/type/boxed-type.d.ts +0 -30
  18. package/dist/types/common/type/parse.d.ts +0 -4
  19. package/dist/types/common/type/primitive.d.ts +0 -10
  20. package/dist/types/common/type/serialize.d.ts +0 -2
  21. package/dist/types/common/type/subtype.d.ts +0 -6
  22. package/dist/types/common/type/types.d.ts +0 -300
  23. package/dist/types/common/type/utils.d.ts +0 -36
  24. package/dist/types/common/utils.d.ts +0 -2
  25. package/dist/types/compute-engine/assume.d.ts +0 -26
  26. package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +0 -165
  27. package/dist/types/compute-engine/boxed-expression/apply.d.ts +0 -5
  28. package/dist/types/compute-engine/boxed-expression/arithmetic-add.d.ts +0 -16
  29. package/dist/types/compute-engine/boxed-expression/arithmetic-mul-div.d.ts +0 -27
  30. package/dist/types/compute-engine/boxed-expression/arithmetic-power.d.ts +0 -38
  31. package/dist/types/compute-engine/boxed-expression/ascii-math.d.ts +0 -11
  32. package/dist/types/compute-engine/boxed-expression/box.d.ts +0 -47
  33. package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +0 -42
  34. package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +0 -136
  35. package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +0 -103
  36. package/dist/types/compute-engine/boxed-expression/boxed-operator-definition.d.ts +0 -53
  37. package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +0 -4
  38. package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +0 -27
  39. package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +0 -170
  40. package/dist/types/compute-engine/boxed-expression/boxed-tensor.d.ts +0 -83
  41. package/dist/types/compute-engine/boxed-expression/boxed-value-definition.d.ts +0 -46
  42. package/dist/types/compute-engine/boxed-expression/cache.d.ts +0 -7
  43. package/dist/types/compute-engine/boxed-expression/canonical-utils.d.ts +0 -5
  44. package/dist/types/compute-engine/boxed-expression/canonical.d.ts +0 -2
  45. package/dist/types/compute-engine/boxed-expression/compare.d.ts +0 -13
  46. package/dist/types/compute-engine/boxed-expression/expand.d.ts +0 -20
  47. package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +0 -12
  48. package/dist/types/compute-engine/boxed-expression/factor.d.ts +0 -10
  49. package/dist/types/compute-engine/boxed-expression/flatten.d.ts +0 -25
  50. package/dist/types/compute-engine/boxed-expression/hold.d.ts +0 -10
  51. package/dist/types/compute-engine/boxed-expression/match.d.ts +0 -12
  52. package/dist/types/compute-engine/boxed-expression/negate.d.ts +0 -11
  53. package/dist/types/compute-engine/boxed-expression/numerics.d.ts +0 -34
  54. package/dist/types/compute-engine/boxed-expression/order.d.ts +0 -71
  55. package/dist/types/compute-engine/boxed-expression/polynomials.d.ts +0 -48
  56. package/dist/types/compute-engine/boxed-expression/product.d.ts +0 -66
  57. package/dist/types/compute-engine/boxed-expression/rules.d.ts +0 -129
  58. package/dist/types/compute-engine/boxed-expression/serialize.d.ts +0 -3
  59. package/dist/types/compute-engine/boxed-expression/sgn.d.ts +0 -46
  60. package/dist/types/compute-engine/boxed-expression/simplify.d.ts +0 -6
  61. package/dist/types/compute-engine/boxed-expression/solve.d.ts +0 -20
  62. package/dist/types/compute-engine/boxed-expression/terms.d.ts +0 -10
  63. package/dist/types/compute-engine/boxed-expression/trigonometry.d.ts +0 -9
  64. package/dist/types/compute-engine/boxed-expression/utils.d.ts +0 -54
  65. package/dist/types/compute-engine/boxed-expression/validate.d.ts +0 -49
  66. package/dist/types/compute-engine/collection-utils.d.ts +0 -35
  67. package/dist/types/compute-engine/compile.d.ts +0 -80
  68. package/dist/types/compute-engine/cost-function.d.ts +0 -13
  69. package/dist/types/compute-engine/function-utils.d.ts +0 -120
  70. package/dist/types/compute-engine/global-types.d.ts +0 -2872
  71. package/dist/types/compute-engine/index.d.ts +0 -657
  72. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +0 -2
  73. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +0 -2
  74. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +0 -2
  75. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-complex.d.ts +0 -2
  76. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +0 -27
  77. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-linear-algebra.d.ts +0 -2
  78. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +0 -2
  79. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +0 -2
  80. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-relational-operators.d.ts +0 -2
  81. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +0 -2
  82. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-statistics.d.ts +0 -2
  83. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +0 -3
  84. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +0 -2
  85. package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +0 -88
  86. package/dist/types/compute-engine/latex-syntax/parse-symbol.d.ts +0 -21
  87. package/dist/types/compute-engine/latex-syntax/parse.d.ts +0 -303
  88. package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +0 -29
  89. package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +0 -10
  90. package/dist/types/compute-engine/latex-syntax/serializer.d.ts +0 -37
  91. package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +0 -18
  92. package/dist/types/compute-engine/latex-syntax/types.d.ts +0 -845
  93. package/dist/types/compute-engine/latex-syntax/utils.d.ts +0 -5
  94. package/dist/types/compute-engine/library/arithmetic.d.ts +0 -4
  95. package/dist/types/compute-engine/library/calculus.d.ts +0 -2
  96. package/dist/types/compute-engine/library/collections.d.ts +0 -27
  97. package/dist/types/compute-engine/library/combinatorics.d.ts +0 -2
  98. package/dist/types/compute-engine/library/complex.d.ts +0 -2
  99. package/dist/types/compute-engine/library/control-structures.d.ts +0 -2
  100. package/dist/types/compute-engine/library/core.d.ts +0 -2
  101. package/dist/types/compute-engine/library/invisible-operator.d.ts +0 -4
  102. package/dist/types/compute-engine/library/library.d.ts +0 -17
  103. package/dist/types/compute-engine/library/linear-algebra.d.ts +0 -2
  104. package/dist/types/compute-engine/library/logic.d.ts +0 -6
  105. package/dist/types/compute-engine/library/number-theory.d.ts +0 -2
  106. package/dist/types/compute-engine/library/polynomials.d.ts +0 -2
  107. package/dist/types/compute-engine/library/random-expression.d.ts +0 -2
  108. package/dist/types/compute-engine/library/relational-operator.d.ts +0 -2
  109. package/dist/types/compute-engine/library/sets.d.ts +0 -2
  110. package/dist/types/compute-engine/library/statistics.d.ts +0 -2
  111. package/dist/types/compute-engine/library/trigonometry.d.ts +0 -2
  112. package/dist/types/compute-engine/library/utils.d.ts +0 -77
  113. package/dist/types/compute-engine/numeric-value/big-numeric-value.d.ts +0 -57
  114. package/dist/types/compute-engine/numeric-value/exact-numeric-value.d.ts +0 -75
  115. package/dist/types/compute-engine/numeric-value/machine-numeric-value.d.ts +0 -56
  116. package/dist/types/compute-engine/numeric-value/types.d.ts +0 -116
  117. package/dist/types/compute-engine/numerics/bigint.d.ts +0 -2
  118. package/dist/types/compute-engine/numerics/expression.d.ts +0 -4
  119. package/dist/types/compute-engine/numerics/interval.d.ts +0 -12
  120. package/dist/types/compute-engine/numerics/monte-carlo.d.ts +0 -4
  121. package/dist/types/compute-engine/numerics/numeric-bigint.d.ts +0 -18
  122. package/dist/types/compute-engine/numerics/numeric-bignum.d.ts +0 -9
  123. package/dist/types/compute-engine/numerics/numeric-complex.d.ts +0 -3
  124. package/dist/types/compute-engine/numerics/numeric.d.ts +0 -60
  125. package/dist/types/compute-engine/numerics/primes.d.ts +0 -7
  126. package/dist/types/compute-engine/numerics/rationals.d.ts +0 -43
  127. package/dist/types/compute-engine/numerics/richardson.d.ts +0 -80
  128. package/dist/types/compute-engine/numerics/special-functions.d.ts +0 -28
  129. package/dist/types/compute-engine/numerics/statistics.d.ts +0 -24
  130. package/dist/types/compute-engine/numerics/strings.d.ts +0 -2
  131. package/dist/types/compute-engine/numerics/types.d.ts +0 -30
  132. package/dist/types/compute-engine/symbolic/antiderivative.d.ts +0 -3
  133. package/dist/types/compute-engine/symbolic/derivative.d.ts +0 -18
  134. package/dist/types/compute-engine/symbolic/distribute.d.ts +0 -5
  135. package/dist/types/compute-engine/symbolic/simplify-rules.d.ts +0 -27
  136. package/dist/types/compute-engine/tensor/tensor-fields.d.ts +0 -128
  137. package/dist/types/compute-engine/tensor/tensors.d.ts +0 -93
  138. package/dist/types/compute-engine/types.d.ts +0 -8
  139. package/dist/types/compute-engine.d.ts +0 -3
  140. package/dist/types/math-json/symbols.d.ts +0 -11
  141. package/dist/types/math-json/types.d.ts +0 -120
  142. package/dist/types/math-json/utils.d.ts +0 -81
  143. package/dist/types/math-json.d.ts +0 -3
@@ -1,47 +0,0 @@
1
- /* 0.30.2 */
2
- import { MathJsonSymbol } from '../../math-json/types';
3
- import { NumericValue } from '../numeric-value/types';
4
- /**
5
- * Given a name and a set of arguments, return a boxed function expression.
6
- *
7
- * If available, preserve LaTeX and wikidata metadata in the boxed expression.
8
- *
9
- * Note that `boxFunction()` should only be called from `ce.function()`
10
- */
11
- export declare function boxFunction(ce: ComputeEngine, name: MathJsonSymbol, ops: readonly SemiBoxedExpression[], options?: {
12
- metadata?: Metadata;
13
- canonical?: CanonicalOptions;
14
- structural?: boolean;
15
- scope?: Scope;
16
- }): BoxedExpression;
17
- /**
18
- * Notes about the boxed form:
19
- *
20
- * [1] Expression with an operator of `Number`, `String`, `Symbol` and `Dictionary`
21
- * are converted to the corresponding atomic expression.
22
- *
23
- * [2] Expressions with an operator of `Complex` are converted to a (complex) number
24
- * or a `Add`/`Multiply` expression.
25
- *
26
- * The precedence of `Complex` (for serialization) is sometimes the
27
- * precedence of `Add` (when re and im != 0), sometimes the precedence of
28
- * `Multiply` (when im or re === 0). Using a number or an explicit
29
- * `Add`/`Multiply` expression avoids this ambiguity.
30
- *
31
- * [3] An expression with a `Rational` operator is converted to a rational
32
- * number if possible, to a `Divide` otherwise.
33
- *
34
- * [4] A `Negate` function applied to a number literal is converted to a number.
35
- *
36
- * Note that `Negate` is only distributed over addition. In practice, having
37
- * `Negate` factored on multiply/divide is more useful to detect patterns.
38
- *
39
- * Note that this function should only be called from `ce.box()`
40
- *
41
- */
42
- export declare function box(ce: ComputeEngine, expr: null | undefined | NumericValue | SemiBoxedExpression, options?: {
43
- canonical?: CanonicalOptions;
44
- structural?: boolean;
45
- scope?: Scope;
46
- }): BoxedExpression;
47
- export declare function semiCanonical(ce: ComputeEngine, xs: ReadonlyArray<SemiBoxedExpression>, scope?: Scope): ReadonlyArray<BoxedExpression>;
@@ -1,42 +0,0 @@
1
- /* 0.30.2 */
2
- import { _BoxedExpression } from './abstract-boxed-expression';
3
- import { BoxedType } from '../../common/type/boxed-type';
4
- import { Expression } from '../../math-json/types';
5
- /**
6
- * BoxedDictionary
7
- *
8
- */
9
- export declare class BoxedDictionary extends _BoxedExpression implements DictionaryInterface {
10
- [Symbol.toStringTag]: string;
11
- private readonly _keyValues;
12
- private _type;
13
- constructor(ce: ComputeEngine, keyValues: Record<string, SemiBoxedExpression> | BoxedExpression, options?: {
14
- metadata?: Metadata;
15
- canonical?: boolean;
16
- });
17
- private _initFromRecord;
18
- private _initFromExpression;
19
- get json(): Expression;
20
- get hash(): number;
21
- get operator(): string;
22
- get type(): BoxedType;
23
- get isPure(): boolean;
24
- get isCanonical(): boolean;
25
- set isCanonical(_va: boolean);
26
- get value(): BoxedExpression | undefined;
27
- get complexity(): number;
28
- get isCollection(): boolean;
29
- get isIndexedCollection(): boolean;
30
- get isLazyCollection(): boolean;
31
- xcontains(_rhs: BoxedExpression): boolean | undefined;
32
- get xsize(): number | undefined;
33
- get isEmptyCollection(): boolean;
34
- get isFiniteCollection(): boolean;
35
- each(): Generator<BoxedExpression>;
36
- get(key: string): BoxedExpression | undefined;
37
- has(key: string): boolean;
38
- get keys(): string[];
39
- get entries(): [string, BoxedExpression][];
40
- get values(): BoxedExpression[];
41
- match(pattern: BoxedExpression, _options?: PatternMatchOptions): BoxedSubstitution | null;
42
- }
@@ -1,136 +0,0 @@
1
- /* 0.30.2 */
2
- import type { SimplifyOptions, ReplaceOptions, PatternMatchOptions, BoxedExpression, BoxedBaseDefinition, BoxedOperatorDefinition, BoxedRuleSet, BoxedSubstitution, CanonicalOptions, EvaluateOptions, ComputeEngine, Metadata, Rule, Sign, Substitution, Scope, BoxedValueDefinition } from '../global-types';
3
- import { Type } from '../../common/type/types';
4
- import { BoxedType } from '../../common/type/boxed-type';
5
- import { NumericValue } from '../numeric-value/types';
6
- import { _BoxedExpression } from './abstract-boxed-expression';
7
- /**
8
- * A boxed function expression represent an expression composed of an operator
9
- * (the name of the function) and a list of arguments. For example:
10
- * `["Add", 1, 2]` is a function expression with the operator "Add" and two
11
- * arguments 1 and 2.
12
- *
13
- * If canonical, it has a definition associated with it, based on the operator.
14
- *
15
- * The definition contains its signature and its evaluation handler.
16
- *
17
- */
18
- export declare class BoxedFunction extends _BoxedExpression {
19
- private readonly _operator;
20
- private readonly _ops;
21
- private _def;
22
- /** @todo: wrong. If the function is scoped (has its own lexical scope), the captured eval context. This includes the lexical scope for this expression
23
- */
24
- private _capturedContext;
25
- /** If the operator is scoped, the local scope associated with
26
- * the function expression
27
- */
28
- private _localScope;
29
- private _isPure;
30
- private _isStructural;
31
- private _hash;
32
- private _value;
33
- private _valueN;
34
- private _sgn;
35
- private _type;
36
- constructor(ce: ComputeEngine, operator: string, ops: ReadonlyArray<BoxedExpression>, options?: {
37
- metadata?: Metadata;
38
- canonical?: boolean;
39
- structural?: boolean;
40
- scope?: Scope;
41
- });
42
- get hash(): number;
43
- /**
44
- * For function expressions, `infer()` infers the result type of the function
45
- * based on the provided type and inference mode.
46
- */
47
- infer(t: Type, inferenceMode?: 'narrow' | 'widen'): boolean;
48
- bind(): void;
49
- reset(): void;
50
- get value(): BoxedExpression | undefined;
51
- get isCanonical(): boolean;
52
- get isPure(): boolean;
53
- get isConstant(): boolean;
54
- get constantValue(): number | boolean | string | object | undefined;
55
- get json(): Expression;
56
- get operator(): string;
57
- get ops(): ReadonlyArray<BoxedExpression>;
58
- get nops(): number;
59
- get op1(): BoxedExpression;
60
- get op2(): BoxedExpression;
61
- get op3(): BoxedExpression;
62
- get isScoped(): boolean;
63
- get localScope(): Scope | undefined;
64
- get isValid(): boolean;
65
- /** Note: if the expression is not canonical, this will return a canonical
66
- * version of the expression in the current lexical scope.
67
- */
68
- get canonical(): BoxedExpression;
69
- get structural(): BoxedExpression;
70
- get isStructural(): boolean;
71
- toNumericValue(): [NumericValue, BoxedExpression];
72
- /**
73
- * Note: the result is bound to the current scope, not the scope of the
74
- * original expression.
75
- * <!-- This may or may not be desirable -->
76
- */
77
- subs(sub: Substitution, options?: {
78
- canonical?: CanonicalOptions;
79
- }): BoxedExpression;
80
- replace(rules: BoxedRuleSet | Rule | Rule[], options?: Partial<ReplaceOptions>): BoxedExpression | null;
81
- match(pattern: BoxedExpression, options?: PatternMatchOptions): BoxedSubstitution | null;
82
- has(v: string | string[]): boolean;
83
- get sgn(): Sign | undefined;
84
- get isNaN(): boolean | undefined;
85
- get isInfinity(): boolean | undefined;
86
- get isFinite(): boolean | undefined;
87
- get isOne(): boolean | undefined;
88
- get isNegativeOne(): boolean | undefined;
89
- get isPositive(): boolean | undefined;
90
- get isNonNegative(): boolean | undefined;
91
- get isNegative(): boolean | undefined;
92
- get isNonPositive(): boolean | undefined;
93
- get numerator(): BoxedExpression;
94
- get denominator(): BoxedExpression;
95
- get numeratorDenominator(): [BoxedExpression, BoxedExpression];
96
- neg(): BoxedExpression;
97
- inv(): BoxedExpression;
98
- abs(): BoxedExpression;
99
- add(rhs: number | BoxedExpression): BoxedExpression;
100
- mul(rhs: NumericValue | number | BoxedExpression): BoxedExpression;
101
- div(rhs: number | BoxedExpression): BoxedExpression;
102
- pow(exp: number | BoxedExpression): BoxedExpression;
103
- root(exp: number | BoxedExpression): BoxedExpression;
104
- sqrt(): BoxedExpression;
105
- ln(semiBase?: number | BoxedExpression): BoxedExpression;
106
- get complexity(): number | undefined;
107
- get baseDefinition(): BoxedBaseDefinition | undefined;
108
- get operatorDefinition(): BoxedOperatorDefinition | undefined;
109
- get valueDefinition(): BoxedValueDefinition | undefined;
110
- get isNumber(): boolean | undefined;
111
- get isInteger(): boolean | undefined;
112
- get isRational(): boolean | undefined;
113
- get isReal(): boolean | undefined;
114
- get isFunctionExpression(): boolean;
115
- /** The type of the value of the function */
116
- get type(): BoxedType;
117
- simplify(options?: Partial<SimplifyOptions>): BoxedExpression;
118
- evaluate(options?: Partial<EvaluateOptions>): BoxedExpression;
119
- evaluateAsync(options?: Partial<EvaluateOptions>): Promise<BoxedExpression>;
120
- N(): BoxedExpression;
121
- solve(vars?: Iterable<string> | string | BoxedExpression | Iterable<BoxedExpression>): null | ReadonlyArray<BoxedExpression>;
122
- get isCollection(): boolean;
123
- get isIndexedCollection(): boolean;
124
- get isLazyCollection(): boolean;
125
- xcontains(rhs: BoxedExpression): boolean | undefined;
126
- get xsize(): number | undefined;
127
- get isEmptyCollection(): boolean | undefined;
128
- get isFiniteCollection(): boolean | undefined;
129
- each(): Generator<BoxedExpression>;
130
- at(index: number): BoxedExpression | undefined;
131
- get(index: BoxedExpression | string): BoxedExpression | undefined;
132
- indexWhere(predicate: (element: BoxedExpression) => boolean): number | undefined;
133
- subsetOf(rhs: BoxedExpression, strict: boolean): boolean;
134
- _computeValue(options?: Partial<EvaluateOptions>): () => BoxedExpression;
135
- _computeValueAsync(options?: Partial<EvaluateOptions>): () => Promise<BoxedExpression>;
136
- }
@@ -1,103 +0,0 @@
1
- /* 0.30.2 */
2
- import { Decimal } from 'decimal.js';
3
- import type { Expression, MathJsonNumberObject } from '../../math-json';
4
- import type { Rational, SmallInteger } from '../numerics/types';
5
- import { ExactNumericValueData, NumericValue, NumericValueData } from '../numeric-value/types';
6
- import { _BoxedExpression } from './abstract-boxed-expression';
7
- import { BoxedType } from '../../common/type/boxed-type';
8
- import type { BoxedRuleSet, BoxedSubstitution, CanonicalOptions, EvaluateOptions, ComputeEngine, Metadata, Rule, Sign, Substitution, BoxedExpression, PatternMatchOptions, ReplaceOptions, SimplifyOptions } from '../global-types';
9
- /**
10
- * BoxedNumber
11
- *
12
- */
13
- export declare class BoxedNumber extends _BoxedExpression {
14
- protected readonly _value: SmallInteger | NumericValue;
15
- private _hash;
16
- /**
17
- * By the time the constructor is called, the `value` should have been
18
- * screened for cases where it's a well-known value (0, NaN, +Infinity,
19
- * etc...) or non-normal (complex number with im = 0, rational with
20
- * denom = 1, etc...).
21
- *
22
- * This is done in `ce.number()`. In general, use `ce.number()` rather
23
- * than calling this constructor directly.
24
- *
25
- * We may store as a machine number if a Decimal is passed that is in machine
26
- * range
27
- */
28
- constructor(ce: ComputeEngine, value: SmallInteger | NumericValueData | ExactNumericValueData | NumericValue, options?: {
29
- metadata?: Metadata;
30
- });
31
- get hash(): number;
32
- get json(): Expression;
33
- get operator(): string;
34
- get isPure(): boolean;
35
- get isCanonical(): boolean;
36
- set isCanonical(val: boolean);
37
- get complexity(): number;
38
- /**
39
- *
40
- * Return a JavaScript number when possible (most cases); else return a
41
- * string representation of the number (ComplexInfinity and complex numbers
42
- * for example).
43
- *
44
- * When a JavaScript number is returned, it may have fewer digits than the
45
- * original number, but it will be a close approximation.
46
- *
47
- * @returns {number | string} The value of the number.
48
- */
49
- valueOf(): number | string;
50
- get numericValue(): number | NumericValue;
51
- get isNumberLiteral(): boolean;
52
- get re(): number;
53
- get im(): number;
54
- get bignumRe(): Decimal | undefined;
55
- get bignumIm(): Decimal | undefined;
56
- neg(): BoxedExpression;
57
- inv(): BoxedExpression;
58
- abs(): BoxedExpression;
59
- add(rhs: number | BoxedExpression): BoxedExpression;
60
- mul(rhs: NumericValue | number | BoxedExpression): BoxedExpression;
61
- div(rhs: number | BoxedExpression): BoxedExpression;
62
- pow(exp: number | BoxedExpression): BoxedExpression;
63
- root(exp: number | BoxedExpression): BoxedExpression;
64
- sqrt(): BoxedExpression;
65
- ln(semiBase?: number | BoxedExpression): BoxedExpression;
66
- get value(): BoxedExpression;
67
- get type(): BoxedType;
68
- get sgn(): Sign | undefined;
69
- get numerator(): BoxedExpression;
70
- get denominator(): BoxedExpression;
71
- get numeratorDenominator(): [BoxedExpression, BoxedExpression];
72
- subs(sub: Substitution, options?: {
73
- canonical?: CanonicalOptions;
74
- }): BoxedExpression;
75
- replace(rules: BoxedRuleSet | Rule | Rule[], options?: Partial<ReplaceOptions>): BoxedExpression | null;
76
- match(pattern: BoxedExpression, options?: PatternMatchOptions): BoxedSubstitution | null;
77
- /** x > 0, same as `isGreater(0)` */
78
- get isPositive(): boolean | undefined;
79
- /** x >= 0, same as `isGreaterEqual(0)` */
80
- get isNonNegative(): boolean | undefined;
81
- /** x < 0, same as `isLess(0)` */
82
- get isNegative(): boolean | undefined;
83
- /** x <= 0, same as `isLessEqual(0)` */
84
- get isNonPositive(): boolean | undefined;
85
- get isOdd(): boolean | undefined;
86
- get isEven(): boolean | undefined;
87
- get isInfinity(): boolean;
88
- get isNaN(): boolean;
89
- get isFinite(): boolean;
90
- get isNumber(): true;
91
- get isInteger(): boolean;
92
- get isRational(): boolean;
93
- get isReal(): boolean;
94
- is(other: BoxedExpression | number | bigint | boolean): boolean;
95
- get canonical(): BoxedExpression;
96
- get isStructural(): boolean;
97
- get structural(): BoxedExpression;
98
- toNumericValue(): [NumericValue, BoxedExpression];
99
- simplify(options?: Partial<SimplifyOptions>): BoxedExpression;
100
- evaluate(options?: Partial<EvaluateOptions>): BoxedExpression;
101
- N(): BoxedExpression;
102
- }
103
- export declare function canonicalNumber(ce: ComputeEngine, value: number | bigint | string | Decimal | Complex | Rational | NumericValue | MathJsonNumberObject): number | NumericValue;
@@ -1,53 +0,0 @@
1
- /* 0.30.2 */
2
- import { BoxedType } from '../../common/type/boxed-type';
3
- import type { OperatorDefinition, BoxedExpression, BoxedOperatorDefinition, CollectionHandlers, CompiledExpression, EvaluateOptions, ComputeEngine, Sign } from '../global-types';
4
- export declare class _BoxedOperatorDefinition implements BoxedOperatorDefinition {
5
- engine: ComputeEngine;
6
- name: string;
7
- description?: string | string[];
8
- url?: string;
9
- wikidata?: string;
10
- broadcastable: boolean;
11
- associative: boolean;
12
- commutative: boolean;
13
- commutativeOrder: ((a: BoxedExpression, b: BoxedExpression) => number) | undefined;
14
- idempotent: boolean;
15
- involution: boolean;
16
- pure: boolean;
17
- complexity: number;
18
- lazy: boolean;
19
- scoped: boolean;
20
- signature: BoxedType;
21
- inferredSignature: boolean;
22
- type?: (ops: ReadonlyArray<BoxedExpression>, options: {
23
- engine: ComputeEngine;
24
- }) => BoxedType | Type | TypeString | undefined;
25
- sgn?: (ops: ReadonlyArray<BoxedExpression>, options: {
26
- engine: ComputeEngine;
27
- }) => Sign | undefined;
28
- eq?: (a: BoxedExpression, b: BoxedExpression) => boolean | undefined;
29
- neq?: (a: BoxedExpression, b: BoxedExpression) => boolean | undefined;
30
- even?: (ops: ReadonlyArray<BoxedExpression>, options: {
31
- engine: ComputeEngine;
32
- }) => boolean | undefined;
33
- canonical?: (ops: ReadonlyArray<BoxedExpression>, options: {
34
- engine: ComputeEngine;
35
- }) => BoxedExpression | null;
36
- evaluate?: (ops: ReadonlyArray<BoxedExpression>, options: Partial<EvaluateOptions> & {
37
- engine: ComputeEngine;
38
- }) => BoxedExpression | undefined;
39
- evaluateAsync?: (ops: ReadonlyArray<BoxedExpression>, options?: Partial<EvaluateOptions> & {
40
- engine?: ComputeEngine;
41
- }) => Promise<BoxedExpression | undefined>;
42
- evalDimension?: (ops: ReadonlyArray<BoxedExpression>, options: {
43
- engine: ComputeEngine;
44
- }) => BoxedExpression;
45
- compile?: (expr: BoxedExpression) => CompiledExpression;
46
- collection?: CollectionHandlers;
47
- constructor(ce: ComputeEngine, name: string, def: OperatorDefinition);
48
- /** For debugging */
49
- toJSON(): any;
50
- infer(sig: Type): void;
51
- update(def: OperatorDefinition): void;
52
- onConfigurationChange(): void;
53
- }
@@ -1,4 +0,0 @@
1
- /* 0.30.2 */
2
- import type { BoxedExpression } from '../global-types';
3
- export declare function isWildcard(expr: BoxedExpression): expr is BoxedSymbol;
4
- export declare function wildcardName(expr: BoxedExpression): string | null;
@@ -1,27 +0,0 @@
1
- /* 0.30.2 */
2
- import { _BoxedExpression } from './abstract-boxed-expression';
3
- import { BoxedType } from '../../common/type/boxed-type';
4
- /**
5
- * BoxedString
6
- *
7
- */
8
- export declare class BoxedString extends _BoxedExpression {
9
- [Symbol.toStringTag]: string;
10
- private readonly _string;
11
- private _utf8Buffer?;
12
- private _unicodeScalarValues?;
13
- constructor(ce: ComputeEngine, expr: string, metadata?: Metadata);
14
- get json(): string;
15
- get hash(): number;
16
- get operator(): string;
17
- get isPure(): boolean;
18
- get isCanonical(): boolean;
19
- set isCanonical(_va: boolean);
20
- get value(): BoxedExpression;
21
- get type(): BoxedType;
22
- get complexity(): number;
23
- get string(): string;
24
- get buffer(): Uint8Array;
25
- get unicodeScalars(): number[];
26
- match(pattern: BoxedExpression, _options?: PatternMatchOptions): BoxedSubstitution | null;
27
- }
@@ -1,170 +0,0 @@
1
- /* 0.30.2 */
2
- import type { Type, TypeString } from '../../common/type/types';
3
- import type { OneOf } from '../../common/one-of';
4
- import { BoxedType } from '../../common/type/boxed-type';
5
- import type { BigNum } from '../numerics/types';
6
- import { NumericValue } from '../numeric-value/types';
7
- import type { BoxedExpression, SimplifyOptions, PatternMatchOptions, ReplaceOptions, BoxedValueDefinition, BoxedOperatorDefinition, ComputeEngine, Metadata, CanonicalOptions, BoxedBaseDefinition, BoxedSubstitution, EvaluateOptions, Rule, BoxedRule, BoxedRuleSet, Substitution, Sign, BoxedDefinition, CollectionHandlers } from '../global-types';
8
- import { _BoxedExpression } from './abstract-boxed-expression';
9
- /**
10
- * ### BoxedSymbol
11
- *
12
- * A boxed symbol is a reference to a `BoxedDefinition`.
13
- *
14
- * A `BoxedDefinition` "owns" all the information about a symbol, its
15
- * type and various attributes (is it a constant?, etc...).
16
- *
17
- * Boxed symbols are bound to a definition during construction if they
18
- * are canonical.
19
- *
20
- * If a symbol is not canonical (and thus not bound to a definition),
21
- * some properties and methods will return `undefined`, for example
22
- * `isInteger`, `isRational`, `isReal`, etc...
23
- *
24
- * There is a single value definition for each symbol but the value of a
25
- * symbol can be different in different evaluation contexts, for example
26
- * a local variable during a recursion.
27
- *
28
- * The value of a symbol is tracked in the evaluation context and
29
- * not in the value definition.
30
- *
31
- * The `value` property of a boxed symbol is the value of the symbol
32
- * in the current evaluation context. It is `undefined` if the symbol
33
- * is not bound to a definition or if the value is not known (a bound
34
- * symbol may have no value).
35
- *
36
- */
37
- export declare class BoxedSymbol extends _BoxedExpression {
38
- private _hash;
39
- /** The name of the symbol */
40
- protected _id: MathJsonSymbol;
41
- /**
42
- * The definition of the symbol, if the symbol is bound/canonical.
43
- */
44
- private readonly _def;
45
- /** Note: to indicate that the symbol should be canonical, pass a def. */
46
- constructor(ce: ComputeEngine, name: MathJsonSymbol, options?: {
47
- metadata?: Metadata;
48
- def?: BoxedDefinition;
49
- });
50
- get json(): Expression;
51
- get hash(): number;
52
- get isPure(): boolean;
53
- get isConstant(): boolean;
54
- bind(): void;
55
- reset(): void;
56
- get isCanonical(): boolean;
57
- set isCanonical(val: boolean);
58
- get canonical(): BoxedExpression;
59
- is(other: any): boolean;
60
- toNumericValue(): [NumericValue, BoxedExpression];
61
- neg(): BoxedExpression;
62
- inv(): BoxedExpression;
63
- abs(): BoxedExpression;
64
- add(rhs: number | BoxedExpression): BoxedExpression;
65
- mul(rhs: NumericValue | number | BoxedExpression): BoxedExpression;
66
- div(rhs: number | BoxedExpression): BoxedExpression;
67
- pow(exp: number | BoxedExpression): BoxedExpression;
68
- root(n: number | BoxedExpression): BoxedExpression;
69
- sqrt(): BoxedExpression;
70
- ln(semiBase?: number | BoxedExpression): BoxedExpression;
71
- solve(vars?: Iterable<string> | string | BoxedExpression | Iterable<BoxedExpression>): null | ReadonlyArray<BoxedExpression>;
72
- get complexity(): number;
73
- get operator(): MathJsonSymbol;
74
- get symbol(): MathJsonSymbol;
75
- get baseDefinition(): BoxedBaseDefinition | undefined;
76
- get valueDefinition(): BoxedValueDefinition | undefined;
77
- get operatorDefinition(): BoxedOperatorDefinition | undefined;
78
- /**
79
- *
80
- * Assuming the symbol is used as an argument, subsequent inferences will
81
- * narrow the domain of the symbol:
82
- *
83
- * ```
84
- * f: real -> number, g: integer -> number
85
- * f(x) => x: inferred to real
86
- * g(x) => x: narrowed to integer
87
- * ```
88
- *
89
- * If the symbol is used as a return value, its domain should be widened:
90
- *
91
- * ```
92
- * f: number -> integer, g: number -> real
93
- * x = f(2) => x: inferred to integer
94
- * x = g(2) => x: widened to real
95
- * ```
96
- *
97
- * Arguments accumulate constraints and narrow.
98
- * Return values accumulate possibilities and widen.
99
- *
100
- * @inheritdoc
101
- */
102
- infer(t: Type, inferenceMode?: 'narrow' | 'widen'): boolean;
103
- /** Return the value of the symbol, undefined if an operator or not bound */
104
- get _value(): BoxedExpression | undefined;
105
- get value(): BoxedExpression | undefined;
106
- set value(value: boolean | string | BigNum | number[] | OneOf<[
107
- {
108
- re: number;
109
- im: number;
110
- },
111
- {
112
- num: number;
113
- denom: number;
114
- },
115
- BoxedExpression
116
- ]> | number | undefined);
117
- /**
118
- * The type of the symbol.
119
- *
120
- * Note that the type of the value of the symbol may be more specific.'
121
- * For example, a symbol could have a type of 'number' but the value
122
- * could be 'integer'.
123
- *
124
- * If the symbol is not canonical (not bound to a definition), the type is
125
- * 'unknown'
126
- */
127
- get type(): BoxedType;
128
- set type(t: Type | TypeString | BoxedType);
129
- has(x: MathJsonSymbol | MathJsonSymbol[]): boolean;
130
- match(pattern: BoxedExpression, options?: PatternMatchOptions): BoxedSubstitution | null;
131
- get sgn(): Sign | undefined;
132
- get isOdd(): boolean | undefined;
133
- get isEven(): boolean | undefined;
134
- get isFinite(): boolean | undefined;
135
- get isInfinity(): boolean | undefined;
136
- get isNaN(): boolean | undefined;
137
- get isPositive(): boolean | undefined;
138
- get isNonPositive(): boolean | undefined;
139
- get isNegative(): boolean | undefined;
140
- get isNonNegative(): boolean | undefined;
141
- get isFunction(): boolean | undefined;
142
- get isNumber(): boolean | undefined;
143
- get isInteger(): boolean | undefined;
144
- get isRational(): boolean | undefined;
145
- get isReal(): boolean | undefined;
146
- get re(): number;
147
- get im(): number;
148
- get bignumRe(): BigNum | undefined;
149
- get bignumIm(): BigNum | undefined;
150
- simplify(options?: Partial<SimplifyOptions>): BoxedExpression;
151
- evaluate(options?: Partial<EvaluateOptions>): BoxedExpression;
152
- N(): BoxedExpression;
153
- replace(rules: Rule | (Rule | BoxedRule)[] | BoxedRuleSet, options?: Partial<ReplaceOptions>): BoxedExpression | null;
154
- subs(sub: Substitution, options?: {
155
- canonical?: CanonicalOptions;
156
- }): BoxedExpression;
157
- get _asCollection(): CollectionHandlers | undefined;
158
- get isCollection(): boolean;
159
- get isIndexedCollection(): boolean;
160
- get isLazyCollection(): boolean;
161
- xcontains(rhs: BoxedExpression): boolean | undefined;
162
- get xsize(): number;
163
- get isEmptyCollection(): boolean;
164
- get isFiniteCollection(): boolean | undefined;
165
- each(): Generator<BoxedExpression>;
166
- at(index: number): BoxedExpression | undefined;
167
- get(index: BoxedExpression | string): BoxedExpression | undefined;
168
- indexWhere(predicate: (element: BoxedExpression) => boolean): number | undefined;
169
- subsetOf(rhs: BoxedExpression, strict: boolean): boolean;
170
- }
@@ -1,83 +0,0 @@
1
- /* 0.30.2 */
2
- import type { ComputeEngine, TensorDataType, Metadata, BoxedBaseDefinition, BoxedOperatorDefinition, BoxedSubstitution, EvaluateOptions, BoxedExpression, SimplifyOptions, PatternMatchOptions, Tensor } from '../global-types';
3
- import { BoxedType } from '../../common/type/boxed-type';
4
- import { NumericValue } from '../numeric-value/types';
5
- import { _BoxedExpression } from './abstract-boxed-expression';
6
- /**
7
- * A boxed tensor represents an expression that can be represented by a tensor.
8
- * This could be a vector, matrix or multi-dimensional array.
9
- *
10
- * The object can be created either from a tensor or from an expression that
11
- * can be represented as a tensor.
12
- *
13
- * The structural counterpart (expression if input is tensor, or tensor
14
- * if input is expression) is created lazily.
15
- *
16
- */
17
- export declare class BoxedTensor<T extends TensorDataType> extends _BoxedExpression {
18
- readonly input: {
19
- ops: ReadonlyArray<BoxedExpression>;
20
- shape: number[];
21
- dtype: T;
22
- };
23
- readonly options?: {
24
- metadata?: Metadata;
25
- };
26
- private _tensor;
27
- private _expression?;
28
- constructor(ce: ComputeEngine, input: {
29
- ops: ReadonlyArray<BoxedExpression>;
30
- shape: number[];
31
- dtype: T;
32
- }, options?: {
33
- metadata?: Metadata;
34
- });
35
- get structural(): BoxedExpression;
36
- /** Create the tensor on demand */
37
- get tensor(): Tensor<T>;
38
- get baseDefinition(): BoxedBaseDefinition | undefined;
39
- get operatorDefinition(): BoxedOperatorDefinition | undefined;
40
- get hash(): number;
41
- get canonical(): BoxedExpression;
42
- get isCanonical(): boolean;
43
- get isPure(): boolean;
44
- get isValid(): boolean;
45
- get complexity(): number;
46
- get operator(): string;
47
- get nops(): number;
48
- get ops(): ReadonlyArray<BoxedExpression>;
49
- get op1(): BoxedExpression;
50
- get op2(): BoxedExpression;
51
- get op3(): BoxedExpression;
52
- neg(): BoxedExpression;
53
- inv(): BoxedExpression;
54
- abs(): BoxedExpression;
55
- add(rhs: number | BoxedExpression): BoxedExpression;
56
- sub(rhs: BoxedExpression): BoxedExpression;
57
- mul(rhs: NumericValue | number | BoxedExpression): BoxedExpression;
58
- div(rhs: number | BoxedExpression): BoxedExpression;
59
- pow(exp: number | BoxedExpression): BoxedExpression;
60
- root(exp: number | BoxedExpression): BoxedExpression;
61
- sqrt(): BoxedExpression;
62
- get shape(): number[];
63
- get rank(): number;
64
- get type(): BoxedType;
65
- get json(): Expression;
66
- /** Mathematical equality */
67
- isEqual(rhs: number | BoxedExpression): boolean | undefined;
68
- get isCollection(): boolean;
69
- get isIndexedCollection(): boolean;
70
- xcontains(other: BoxedExpression): boolean | undefined;
71
- get xsize(): number;
72
- each(): Generator<BoxedExpression>;
73
- at(index: number): BoxedExpression | undefined;
74
- match(pattern: BoxedExpression, options?: PatternMatchOptions): BoxedSubstitution | null;
75
- evaluate(options?: Partial<EvaluateOptions>): BoxedExpression;
76
- simplify(options?: Partial<SimplifyOptions>): BoxedExpression;
77
- N(): BoxedExpression;
78
- }
79
- export declare function isBoxedTensor(val: unknown): val is BoxedTensor<any>;
80
- export declare function expressionTensorInfo(operator: string, rows: ReadonlyArray<BoxedExpression>): {
81
- shape: number[];
82
- dtype: TensorDataType;
83
- } | undefined;