@cortex-js/compute-engine 0.31.0 → 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 (149) hide show
  1. package/package.json +1 -1
  2. package/dist/compute-engine.esm.js +0 -41311
  3. package/dist/compute-engine.min.esm.js +0 -125
  4. package/dist/compute-engine.min.umd.js +0 -127
  5. package/dist/compute-engine.umd.js +0 -41336
  6. package/dist/math-json.esm.js +0 -130
  7. package/dist/math-json.min.esm.js +0 -130
  8. package/dist/math-json.min.umd.js +0 -4
  9. package/dist/math-json.umd.js +0 -155
  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/ast-nodes.d.ts +0 -146
  18. package/dist/types/common/type/boxed-type.d.ts +0 -30
  19. package/dist/types/common/type/lexer.d.ts +0 -51
  20. package/dist/types/common/type/parse.d.ts +0 -211
  21. package/dist/types/common/type/parser.d.ts +0 -45
  22. package/dist/types/common/type/primitive.d.ts +0 -10
  23. package/dist/types/common/type/serialize.d.ts +0 -2
  24. package/dist/types/common/type/subtype.d.ts +0 -6
  25. package/dist/types/common/type/type-builder.d.ts +0 -32
  26. package/dist/types/common/type/types.d.ts +0 -300
  27. package/dist/types/common/type/utils.d.ts +0 -36
  28. package/dist/types/common/utils.d.ts +0 -23
  29. package/dist/types/compute-engine/assume.d.ts +0 -26
  30. package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +0 -165
  31. package/dist/types/compute-engine/boxed-expression/apply.d.ts +0 -5
  32. package/dist/types/compute-engine/boxed-expression/arithmetic-add.d.ts +0 -16
  33. package/dist/types/compute-engine/boxed-expression/arithmetic-mul-div.d.ts +0 -27
  34. package/dist/types/compute-engine/boxed-expression/arithmetic-power.d.ts +0 -38
  35. package/dist/types/compute-engine/boxed-expression/ascii-math.d.ts +0 -11
  36. package/dist/types/compute-engine/boxed-expression/box.d.ts +0 -47
  37. package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +0 -44
  38. package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +0 -136
  39. package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +0 -103
  40. package/dist/types/compute-engine/boxed-expression/boxed-operator-definition.d.ts +0 -53
  41. package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +0 -107
  42. package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +0 -27
  43. package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +0 -170
  44. package/dist/types/compute-engine/boxed-expression/boxed-tensor.d.ts +0 -83
  45. package/dist/types/compute-engine/boxed-expression/boxed-value-definition.d.ts +0 -46
  46. package/dist/types/compute-engine/boxed-expression/cache.d.ts +0 -7
  47. package/dist/types/compute-engine/boxed-expression/canonical-utils.d.ts +0 -5
  48. package/dist/types/compute-engine/boxed-expression/canonical.d.ts +0 -2
  49. package/dist/types/compute-engine/boxed-expression/compare.d.ts +0 -13
  50. package/dist/types/compute-engine/boxed-expression/expand.d.ts +0 -20
  51. package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +0 -12
  52. package/dist/types/compute-engine/boxed-expression/factor.d.ts +0 -10
  53. package/dist/types/compute-engine/boxed-expression/flatten.d.ts +0 -25
  54. package/dist/types/compute-engine/boxed-expression/hold.d.ts +0 -10
  55. package/dist/types/compute-engine/boxed-expression/match.d.ts +0 -19
  56. package/dist/types/compute-engine/boxed-expression/negate.d.ts +0 -11
  57. package/dist/types/compute-engine/boxed-expression/numerics.d.ts +0 -34
  58. package/dist/types/compute-engine/boxed-expression/order.d.ts +0 -71
  59. package/dist/types/compute-engine/boxed-expression/polynomials.d.ts +0 -105
  60. package/dist/types/compute-engine/boxed-expression/product.d.ts +0 -66
  61. package/dist/types/compute-engine/boxed-expression/rules.d.ts +0 -129
  62. package/dist/types/compute-engine/boxed-expression/serialize.d.ts +0 -3
  63. package/dist/types/compute-engine/boxed-expression/sgn.d.ts +0 -46
  64. package/dist/types/compute-engine/boxed-expression/simplify.d.ts +0 -6
  65. package/dist/types/compute-engine/boxed-expression/solve.d.ts +0 -20
  66. package/dist/types/compute-engine/boxed-expression/terms.d.ts +0 -10
  67. package/dist/types/compute-engine/boxed-expression/trigonometry.d.ts +0 -9
  68. package/dist/types/compute-engine/boxed-expression/utils.d.ts +0 -64
  69. package/dist/types/compute-engine/boxed-expression/validate.d.ts +0 -58
  70. package/dist/types/compute-engine/collection-utils.d.ts +0 -35
  71. package/dist/types/compute-engine/compilation/base-compiler.d.ts +0 -31
  72. package/dist/types/compute-engine/compilation/javascript-target.d.ts +0 -68
  73. package/dist/types/compute-engine/compilation/types.d.ts +0 -83
  74. package/dist/types/compute-engine/cost-function.d.ts +0 -13
  75. package/dist/types/compute-engine/function-utils.d.ts +0 -120
  76. package/dist/types/compute-engine/global-types.d.ts +0 -2930
  77. package/dist/types/compute-engine/index.d.ts +0 -660
  78. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +0 -2
  79. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +0 -2
  80. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +0 -2
  81. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-complex.d.ts +0 -2
  82. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +0 -27
  83. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-linear-algebra.d.ts +0 -2
  84. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +0 -2
  85. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +0 -2
  86. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-relational-operators.d.ts +0 -2
  87. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +0 -2
  88. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-statistics.d.ts +0 -2
  89. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +0 -3
  90. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +0 -2
  91. package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +0 -88
  92. package/dist/types/compute-engine/latex-syntax/parse-symbol.d.ts +0 -21
  93. package/dist/types/compute-engine/latex-syntax/parse.d.ts +0 -303
  94. package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +0 -29
  95. package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +0 -10
  96. package/dist/types/compute-engine/latex-syntax/serializer.d.ts +0 -37
  97. package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +0 -18
  98. package/dist/types/compute-engine/latex-syntax/types.d.ts +0 -845
  99. package/dist/types/compute-engine/latex-syntax/utils.d.ts +0 -5
  100. package/dist/types/compute-engine/library/arithmetic.d.ts +0 -4
  101. package/dist/types/compute-engine/library/calculus.d.ts +0 -2
  102. package/dist/types/compute-engine/library/collections.d.ts +0 -27
  103. package/dist/types/compute-engine/library/combinatorics.d.ts +0 -2
  104. package/dist/types/compute-engine/library/complex.d.ts +0 -2
  105. package/dist/types/compute-engine/library/control-structures.d.ts +0 -2
  106. package/dist/types/compute-engine/library/core.d.ts +0 -2
  107. package/dist/types/compute-engine/library/invisible-operator.d.ts +0 -4
  108. package/dist/types/compute-engine/library/library.d.ts +0 -17
  109. package/dist/types/compute-engine/library/linear-algebra.d.ts +0 -2
  110. package/dist/types/compute-engine/library/logic.d.ts +0 -6
  111. package/dist/types/compute-engine/library/number-theory.d.ts +0 -2
  112. package/dist/types/compute-engine/library/polynomials.d.ts +0 -2
  113. package/dist/types/compute-engine/library/random-expression.d.ts +0 -2
  114. package/dist/types/compute-engine/library/relational-operator.d.ts +0 -2
  115. package/dist/types/compute-engine/library/sets.d.ts +0 -2
  116. package/dist/types/compute-engine/library/statistics.d.ts +0 -2
  117. package/dist/types/compute-engine/library/trigonometry.d.ts +0 -2
  118. package/dist/types/compute-engine/library/utils.d.ts +0 -77
  119. package/dist/types/compute-engine/numeric-value/big-numeric-value.d.ts +0 -57
  120. package/dist/types/compute-engine/numeric-value/exact-numeric-value.d.ts +0 -75
  121. package/dist/types/compute-engine/numeric-value/machine-numeric-value.d.ts +0 -56
  122. package/dist/types/compute-engine/numeric-value/types.d.ts +0 -116
  123. package/dist/types/compute-engine/numerics/bigint.d.ts +0 -2
  124. package/dist/types/compute-engine/numerics/expression.d.ts +0 -4
  125. package/dist/types/compute-engine/numerics/interval.d.ts +0 -12
  126. package/dist/types/compute-engine/numerics/monte-carlo.d.ts +0 -4
  127. package/dist/types/compute-engine/numerics/numeric-bigint.d.ts +0 -18
  128. package/dist/types/compute-engine/numerics/numeric-bignum.d.ts +0 -9
  129. package/dist/types/compute-engine/numerics/numeric-complex.d.ts +0 -3
  130. package/dist/types/compute-engine/numerics/numeric.d.ts +0 -60
  131. package/dist/types/compute-engine/numerics/primes.d.ts +0 -7
  132. package/dist/types/compute-engine/numerics/rationals.d.ts +0 -43
  133. package/dist/types/compute-engine/numerics/richardson.d.ts +0 -80
  134. package/dist/types/compute-engine/numerics/special-functions.d.ts +0 -28
  135. package/dist/types/compute-engine/numerics/statistics.d.ts +0 -24
  136. package/dist/types/compute-engine/numerics/strings.d.ts +0 -2
  137. package/dist/types/compute-engine/numerics/types.d.ts +0 -30
  138. package/dist/types/compute-engine/symbolic/antiderivative.d.ts +0 -3
  139. package/dist/types/compute-engine/symbolic/derivative.d.ts +0 -18
  140. package/dist/types/compute-engine/symbolic/distribute.d.ts +0 -5
  141. package/dist/types/compute-engine/symbolic/simplify-rules.d.ts +0 -27
  142. package/dist/types/compute-engine/tensor/tensor-fields.d.ts +0 -128
  143. package/dist/types/compute-engine/tensor/tensors.d.ts +0 -93
  144. package/dist/types/compute-engine/types.d.ts +0 -8
  145. package/dist/types/compute-engine.d.ts +0 -3
  146. package/dist/types/math-json/symbols.d.ts +0 -11
  147. package/dist/types/math-json/types.d.ts +0 -122
  148. package/dist/types/math-json/utils.d.ts +0 -87
  149. package/dist/types/math-json.d.ts +0 -3
@@ -1,170 +0,0 @@
1
- /* 0.31.0 */
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
- contains(rhs: BoxedExpression): boolean | undefined;
162
- get count(): 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.31.0 */
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
- contains(other: BoxedExpression): boolean | undefined;
71
- get count(): 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;
@@ -1,46 +0,0 @@
1
- /* 0.31.0 */
2
- import type { Type, TypeString } from '../../common/type/types';
3
- import { BoxedType } from '../../common/type/boxed-type';
4
- import { ConfigurationChangeListener } from '../../common/configuration-change';
5
- /**
6
- * ### THEORY OF OPERATIONS
7
- *
8
- * - The value in the definition is the initial value of the symbol when
9
- * entering an evaluation context. Unless it is a constant, it is not the
10
- * value of the symbol itself, which is stored in the evaluation context.
11
- *
12
- * - The value or type of a constant cannot be changed.
13
- *
14
- * - When the type is changed, the value is preserved if it is compatible
15
- * with the new type, otherwise it is reset to no value.
16
- *
17
- * - When the value is changed, the type is unaffected. If the value is not
18
- * compatible with the type (setting a def with a numeric type to a value
19
- * of `True` for example), the value is discarded.
20
- *
21
- */
22
- export declare class _BoxedValueDefinition implements BoxedValueDefinition, ConfigurationChangeListener {
23
- readonly name: string; /** Used for debugging and error messages */
24
- wikidata?: string;
25
- description?: string | string[];
26
- url?: string;
27
- private _engine;
28
- private _defValue?;
29
- private _value;
30
- private _type;
31
- inferredType: boolean;
32
- _isConstant: boolean;
33
- holdUntil: 'never' | 'evaluate' | 'N';
34
- eq?: (a: BoxedExpression) => boolean | undefined;
35
- neq?: (a: BoxedExpression) => boolean | undefined;
36
- cmp?: (a: BoxedExpression) => '=' | '>' | '<' | undefined;
37
- collection?: CollectionHandlers;
38
- constructor(ce: ComputeEngine, name: string, def: Partial<ValueDefinition>);
39
- /** For debugging */
40
- toJSON(): any;
41
- get isConstant(): boolean;
42
- get value(): BoxedExpression | undefined;
43
- get type(): BoxedType;
44
- set type(t: Type | TypeString | BoxedType);
45
- onConfigurationChange(): void;
46
- }
@@ -1,7 +0,0 @@
1
- /* 0.31.0 */
2
- value: T | null;
3
- generation: number | undefined;
4
- };
5
- /** The cache v will get updated if necessary */
6
- export declare function cachedValue<T>(v: CachedValue<T>, generation: number | undefined, fn: () => T): T;
7
- export declare function cachedValueAsync<T>(v: CachedValue<T>, generation: number | undefined, fn: () => Promise<T>): Promise<T>;
@@ -1,5 +0,0 @@
1
- /* 0.31.0 */
2
- /**
3
- * Ensure all expressions in the array are in canonical form
4
- */
5
- export declare function canonical(ce: ComputeEngine, xs: ReadonlyArray<BoxedExpression>, scope?: Scope): ReadonlyArray<BoxedExpression>;
@@ -1,2 +0,0 @@
1
- /* 0.31.0 */
2
- export declare function canonicalForm(expr: BoxedExpression, forms: CanonicalOptions, scope?: Scope): BoxedExpression;
@@ -1,13 +0,0 @@
1
- /* 0.31.0 */
2
- /**
3
- * Structural equality of boxed expressions.
4
- */
5
- export declare function same(a: BoxedExpression, b: BoxedExpression): boolean;
6
- /**
7
- * Mathematical equality of two boxed expressions.
8
- *
9
- * In general, it is impossible to always prove equality
10
- * ([Richardson's theorem](https://en.wikipedia.org/wiki/Richardson%27s_theorem)) but this works often...
11
- */
12
- export declare function eq(a: BoxedExpression, inputB: number | BoxedExpression): boolean | undefined;
13
- export declare function cmp(a: BoxedExpression, b: number | BoxedExpression): '<' | '=' | '>' | '>=' | '<=' | undefined;
@@ -1,20 +0,0 @@
1
- /* 0.31.0 */
2
- export declare function expandProducts(ce: ComputeEngine, ops: ReadonlyArray<BoxedExpression>): BoxedExpression | null;
3
- export declare function choose(n: number, k: number): number;
4
- /** Attempt to transform the expression (h, ops) into a sum */
5
- export declare function expandFunction(ce: ComputeEngine, h: string, ops: ReadonlyArray<BoxedExpression>): BoxedExpression | null;
6
- /** Apply the distributive law if the expression is a product of sums.
7
- * For example, a(b + c) = ab + ac
8
- * Expand the expression if it is a power of a sum.
9
- * Expand the terms of the expression if it is a sum or negate.
10
- * If the expression is a fraction, expand the numerator.
11
- * If the exression is a relational operator, expand the operands.
12
- * Return null if the expression cannot be expanded.
13
- */
14
- export declare function expand(expr: BoxedExpression | undefined): BoxedExpression | null;
15
- /**
16
- * Recursive expand of all terms in the expression.
17
- *
18
- * `expand()` only expands the top level of the expression.
19
- */
20
- export declare function expandAll(expr: BoxedExpression): BoxedExpression | null;
@@ -1,12 +0,0 @@
1
- /* 0.31.0 */
2
- export declare class ExpressionMap<U> implements ExpressionMapInterface<U> {
3
- readonly _items: Map<BoxedExpression, U>;
4
- constructor(source?: ExpressionMapInterface<U> | readonly (readonly [BoxedExpression, U])[]);
5
- has(expr: BoxedExpression): boolean;
6
- get(expr: BoxedExpression): U | undefined;
7
- clear(): void;
8
- set(expr: BoxedExpression, value: U): void;
9
- delete(expr: BoxedExpression): void;
10
- [Symbol.iterator](): IterableIterator<[BoxedExpression, U]>;
11
- entries(): IterableIterator<[BoxedExpression, U]>;
12
- }
@@ -1,10 +0,0 @@
1
- /* 0.31.0 */
2
- /** Combine rational expressions into a single fraction */
3
- export declare function together(op: BoxedExpression): BoxedExpression;
4
- /**
5
- * Return an expression factored as a product.
6
- * - 2x + 4 -> 2(x + 2)
7
- * - 2x < 4 -> x < 2
8
- * - (2x) * (2y) -> 4xy
9
- */
10
- export declare function factor(expr: BoxedExpression): BoxedExpression;
@@ -1,25 +0,0 @@
1
- /* 0.31.0 */
2
- /**
3
- *
4
- * Make all the arguments canonical.
5
- *
6
- * "Lift" Sequence expressions to the top level.
7
- * e.g. `["Add", 1, ["Sequence", 2, 3]]` -> `["Add", 1, 2, 3]`
8
- *
9
- * Additionally, if an operator is provided, also lift nested expressions
10
- * with the same operator.
11
- * e.g. `["f", a, ["f", b, c]]` -> `["f", a, b, c]`
12
- *
13
- * Note: *not* recursive
14
- */
15
- export declare function flatten<T extends ReadonlyArray<BoxedExpression> | BoxedExpression[]>(ops: T, operator?: string): T;
16
- /**
17
- * Flatten the arguments.
18
- * @fixme replace with just flatten.
19
- * @fixme consider adding flatternSort()
20
- */
21
- export declare function flattenOps<T extends ReadonlyArray<BoxedExpression> | BoxedExpression[]>(ops: T, operator: string): T;
22
- /**
23
- * @todo: this function should probably not be recursive. As it, it is semi-recursive.
24
- */
25
- export declare function flattenSequence(xs: ReadonlyArray<BoxedExpression>): ReadonlyArray<BoxedExpression>;
@@ -1,10 +0,0 @@
1
- /* 0.31.0 */
2
- /** Apply the function `f` to each operand of the expression `expr`,
3
- * account for the 'lazy' property of the operator definition:
4
- *
5
- * Account for `Hold`, `ReleaseHold`, `Sequence`, `Symbol` and `Nothing`.
6
- *
7
- * If `f` returns `null`, the element is not added to the result
8
- */
9
- export declare function holdMap(expr: BoxedExpression, f: (x: BoxedExpression) => BoxedExpression | null): ReadonlyArray<BoxedExpression>;
10
- export declare function holdMapAsync(expr: BoxedExpression, f: (x: BoxedExpression) => Promise<BoxedExpression | null>): Promise<ReadonlyArray<BoxedExpression>>;
@@ -1,19 +0,0 @@
1
- /* 0.31.0 */
2
- /**
3
- * The function attempts to match a subject expression to a
4
- * [pattern](/compute-engine/guides/patterns-and-rules/).
5
- *
6
- * If the match is successful, it returns a `Substitution` indicating how to
7
- * transform the pattern to become the subject.
8
- *
9
- * If the expression does not match the pattern, it returns `null`.
10
- *
11
- * <!--
12
- * @consider?
13
- * - pattern 'validation' (not quite the right term in this context) here? In a similar way to the
14
- * check/condition supplied in 'matchPermutation()'? (i.e. inspect for redundant sequences of
15
- * wildcard combinations).
16
- * -->
17
- *
18
- */
19
- export declare function match(subject: BoxedExpression, pattern: BoxedExpression, options?: PatternMatchOptions): BoxedSubstitution | null;
@@ -1,11 +0,0 @@
1
- /* 0.31.0 */
2
- export declare function canonicalNegate(expr: BoxedExpression): BoxedExpression;
3
- /**
4
- * Distribute `Negate` (multiply by -1) if expr is a number literal, an
5
- * addition or multiplication or another `Negate`.
6
- *
7
- * It is important to do all these to handle cases like
8
- * `-3x` -> ["Negate, ["Multiply", 3, "x"]] -> ["Multiply, -3, x]
9
- */
10
- export declare function negate(expr: BoxedExpression): BoxedExpression;
11
- export declare function negateProduct(ce: ComputeEngine, args: ReadonlyArray<BoxedExpression>): BoxedExpression;
@@ -1,34 +0,0 @@
1
- /* 0.31.0 */
2
- import { Decimal } from 'decimal.js';
3
- import type { Rational } from '../numerics/types';
4
- import type { BoxedExpression, SemiBoxedExpression } from '../global-types';
5
- export declare function asRational(expr: BoxedExpression): Rational | undefined;
6
- export declare function asBigint(x: Complex | Decimal | SemiBoxedExpression | undefined): bigint | null;
7
- export declare function asBignum(expr: BoxedExpression | undefined): Decimal | null;
8
- /**
9
- * Validate if the expression is a small integer.
10
- * A small integer is an integer between -SMALL_INTEGER and SMALL_INTEGER (inclusive).
11
- * Returns null if the expression is not a small integer.
12
- *
13
- * Unlike `toInteger()` this functions fails if the expression is not an
14
- * integer. `toInteger()` will round the value to the nearest integer.
15
- */
16
- export declare function asSmallInteger(expr: number | BoxedExpression | undefined): number | null;
17
- /**
18
- * Convert a boxed expression to an integer.
19
- * Returns null if the expression cannot be converted to an integer.
20
- * If the expression is a complex number, only the real part is considered.
21
- * If the real part is not an integer, it is rounded to the nearest integer.
22
- *
23
- * Unlike `asSmallInteger()`, this function does not check if the integer is
24
- * within the range of -SMALL_INTEGER to SMALL_INTEGER, and it rounds the
25
- * value to the nearest integer if it is a number.
26
- *
27
- */
28
- export declare function toInteger(expr: BoxedExpression | undefined): number | null;
29
- /** Convert a boxed expression to a bigint.
30
- * Returns null if the expression cannot be converted to a bigint.
31
- * If the expression is a complex number, only the real part is considered.
32
- * If the real part is not an integer, it is rounded to the nearest integer.
33
- */
34
- export declare function toBigint(expr: BoxedExpression | undefined): bigint | null;
@@ -1,71 +0,0 @@
1
- /* 0.31.0 */
2
- export type Order = 'lex' | 'dexlex' | 'grevlex' | 'elim';
3
- export declare const DEFAULT_COMPLEXITY = 100000;
4
- /**
5
- * The sorting order of arguments of the Add function uses a modified degrevlex:
6
- * - Sort by total degree (sum of degree)
7
- * - Sort by max degree.
8
- * - Sort reverse lexicographically
9
- * - Sort by rank
10
- *
11
- *
12
- * E.g.
13
- * - 2x^2 + 3x + 1
14
- * - 2x^2y^3 + 5x^3y
15
- */
16
- export declare function addOrder(a: BoxedExpression, b: BoxedExpression): number;
17
- export declare function equalOrder(a: BoxedExpression, b: BoxedExpression): number;
18
- declare const RANKS: readonly ["integer", "rational", "radical", "real", "complex", "constant", "symbol", "multiply", "divide", "add", "trig", "fn", "power", "string", "other"];
19
- export type Rank = (typeof RANKS)[number];
20
- /**
21
- * Given two expressions `a` and `b`, return:
22
- * - `-1` if `a` should be ordered before `b`
23
- * - `+1` if `b` should be ordered before `a`
24
- * - `0` if they have the same order (they are structurally equal)
25
- *
26
- * The default order is as follow:
27
- *
28
- * 1/ Literal numeric values (rational, machine numbers and Decimal numbers),
29
- * ordered by their numeric value (smaller numbers before larger numbers)
30
- *
31
- * 2/ Literal complex numbers, ordered by their real parts. In case of a tie,
32
- * ordered by the absolute value of their imaginary parts. In case of a tie,
33
- * ordered by the value of their imaginary parts.
34
- *
35
- * 3/ Symbols, ordered by their name as strings
36
- *
37
- * 4/ Addition, ordered as a polynom, with higher degree terms first
38
- *
39
- * 5/ Other functions, ordered by their `complexity` property. In case
40
- * of a tie, ordered by the operator of the expression as a string. In case of a
41
- * tie, by the leaf count of each expression. In case of a tie, by the order
42
- * of each argument, left to right.
43
- *
44
- * 6/ Strings, ordered by comparing their Unicode code point values. While this
45
- * sort order is quick to calculate, it can produce unexpected results, for
46
- * example "E" < "e" < "È" and "11" < "2". This ordering is not suitable to
47
- * collate natural language strings.
48
- *
49
- * See https://reference.wolfram.com/language/ref/Sort.html for a
50
- * description of the ordering of expressions in Mathematica.
51
- *
52
- */
53
- export declare function order(a: BoxedExpression, b: BoxedExpression): number;
54
- /** Return a version of the expression with its arguments sorted in
55
- * canonical order
56
- */
57
- export declare function canonicalOrder(expr: BoxedExpression, { recursive }: {
58
- recursive?: boolean;
59
- }): BoxedExpression;
60
- export declare function sortOperands(operator: string, xs: ReadonlyArray<BoxedExpression>): ReadonlyArray<BoxedExpression>;
61
- /**
62
- * Sort the terms of a polynomial expression (`Add` expression) according
63
- * to the deglex polynomial ordering
64
- *
65
- */
66
- export declare function polynomialOrder(expr: BoxedExpression): BoxedExpression;
67
- export declare function lexicographicOrder(expr: BoxedExpression, vars?: ReadonlyArray<string>): BoxedExpression;
68
- export declare function degreeLexicographicOrder(expr: BoxedExpression, vars?: ReadonlyArray<string>): BoxedExpression;
69
- export declare function degreeReverseLexicographicOrder(expr: BoxedExpression, vars?: ReadonlyArray<string>): BoxedExpression;
70
- export declare function eliminationOrder(expr: BoxedExpression, vars?: ReadonlyArray<string>): BoxedExpression;
71
- export {};
@@ -1,105 +0,0 @@
1
- /* 0.31.0 */
2
- /**
3
- * Coefficient of a univariate (single variable) polynomial.
4
- *
5
- * The first element is a constant.
6
- * The second element is the coefficient of the variable.
7
- * The third element is the coefficient of the variable squared.
8
- * ...etc
9
- *
10
- * `3x^3 + 5x + √5 + 2` -> ['√5 + 2', 5, null, 3]
11
- *
12
- * If a coefficient does not apply (there are no corresponding term), it is `null`.
13
- *
14
- */
15
- export type UnivariateCoefficients = (null | BoxedExpression)[];
16
- export type MultivariateCoefficients = (null | (null | BoxedExpression)[])[];
17
- /**
18
- * Return a list of coefficient of powers of `vars` in `poly`,
19
- * starting with power 0.
20
- *
21
- * If `poly` is not a polynomial, return `null`.
22
- */
23
- export declare function coefficients(poly: BoxedExpression, vars: string): UnivariateCoefficients | null;
24
- export declare function coefficients(poly: BoxedExpression, vars: string[]): MultivariateCoefficients | null;
25
- /**
26
- * The total degree of an expression is the sum of the
27
- * positive integer degrees of the factors in the expression:
28
- *
29
- * `3√2x^5y^3` -> 5 + 3 = 8
30
- */
31
- export declare function totalDegree(expr: BoxedExpression): number;
32
- /**
33
- * The max degree of a polynomial is the largest positive integer degree
34
- * in the factors (monomials) of the expression
35
- *
36
- * `3√2x^5y^3` -> 5
37
- *
38
- */
39
- export declare function maxDegree(expr: BoxedExpression): number;
40
- /**
41
- * Return a lexicographic key of the expression, for example
42
- * `xy^2` -> `x y`
43
- * `x\frac{1}{y}` -> `x y`
44
- * `2xy + y^2` -> `x y y`
45
- *
46
- */
47
- export declare function lex(expr: BoxedExpression): string;
48
- export declare function revlex(expr: BoxedExpression): string;
49
- /**
50
- * Get the degree of a polynomial in a specific variable.
51
- * Returns -1 if the expression is not a polynomial in the variable.
52
- *
53
- * Examples:
54
- * - `polynomialDegree(x^3 + 2x + 1, 'x')` → 3
55
- * - `polynomialDegree(x*y + y^2, 'x')` → 1
56
- * - `polynomialDegree(sin(x), 'x')` → -1 (not a polynomial)
57
- */
58
- export declare function polynomialDegree(expr: BoxedExpression, variable: string): number;
59
- /**
60
- * Extract coefficients of a univariate polynomial.
61
- * Returns an array where index i contains the coefficient of x^i.
62
- * Returns null if the expression is not a polynomial in the variable.
63
- *
64
- * Examples:
65
- * - `getPolynomialCoefficients(x^3 + 2x + 1, 'x')` → [1, 2, 0, 1]
66
- * - `getPolynomialCoefficients(3x^2 - x + 5, 'x')` → [5, -1, 3]
67
- */
68
- export declare function getPolynomialCoefficients(expr: BoxedExpression, variable: string): BoxedExpression[] | null;
69
- /**
70
- * Construct a polynomial expression from its coefficients.
71
- * coeffs[i] is the coefficient of x^i.
72
- *
73
- * Examples:
74
- * - `fromCoefficients([1, 2, 0, 1], 'x')` → x^3 + 2x + 1
75
- * - `fromCoefficients([5, -1, 3], 'x')` → 3x^2 - x + 5
76
- */
77
- export declare function fromCoefficients(coeffs: BoxedExpression[], variable: string): BoxedExpression;
78
- /**
79
- * Polynomial long division.
80
- * Returns [quotient, remainder] such that dividend = divisor * quotient + remainder.
81
- * Returns null if inputs are not valid polynomials or divisor is zero.
82
- *
83
- * Examples:
84
- * - `polynomialDivide(x^3-1, x-1, 'x')` → [x^2+x+1, 0]
85
- * - `polynomialDivide(x^3+2x+1, x+1, 'x')` → [x^2-x+3, -2]
86
- */
87
- export declare function polynomialDivide(dividend: BoxedExpression, divisor: BoxedExpression, variable: string): [BoxedExpression, BoxedExpression] | null;
88
- /**
89
- * Compute the GCD of two polynomials using the Euclidean algorithm.
90
- * Returns a monic polynomial (leading coefficient = 1).
91
- *
92
- * Examples:
93
- * - `polynomialGCD(x^2-1, x-1, 'x')` → x-1
94
- * - `polynomialGCD(x^3-1, x^2-1, 'x')` → x-1
95
- */
96
- export declare function polynomialGCD(a: BoxedExpression, b: BoxedExpression, variable: string): BoxedExpression;
97
- /**
98
- * Cancel common polynomial factors in a rational expression (Divide).
99
- * Returns the simplified expression.
100
- *
101
- * Examples:
102
- * - `cancelCommonFactors((x^2-1)/(x-1), 'x')` → x+1
103
- * - `cancelCommonFactors((x+1)/(x^2+3x+2), 'x')` → 1/(x+2)
104
- */
105
- export declare function cancelCommonFactors(expr: BoxedExpression, variable: string): BoxedExpression;