@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,46 +0,0 @@
1
- /* 0.30.2 */
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.30.2 */
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.30.2 */
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.30.2 */
2
- export declare function canonicalForm(expr: BoxedExpression, forms: CanonicalOptions, scope?: Scope): BoxedExpression;
@@ -1,13 +0,0 @@
1
- /* 0.30.2 */
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.30.2 */
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.30.2 */
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.30.2 */
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.30.2 */
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.30.2 */
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,12 +0,0 @@
1
- /* 0.30.2 */
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
- export declare function match(subject: BoxedExpression, pattern: BoxedExpression, options?: PatternMatchOptions): BoxedSubstitution | null;
@@ -1,11 +0,0 @@
1
- /* 0.30.2 */
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.30.2 */
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.30.2 */
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,48 +0,0 @@
1
- /* 0.30.2 */
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;
@@ -1,66 +0,0 @@
1
- /* 0.30.2 */
2
- import { NumericValue } from '../numeric-value/types';
3
- import type { Rational } from '../numerics/types';
4
- /**
5
- * Group terms in a product by common term.
6
- *
7
- * All the terms should be canonical.
8
- * - the arguments should have been flattened for `Multiply`
9
- *
10
- * - any argument of power been distributed, i.e.
11
- * (ab)^2 -> a^2 b^2
12
- * *
13
- * 3 + √5 + √(x+1) + x^2 + (a+b)^2 + d
14
- * -> [ [[3, "d"], [1, 1]],
15
- * [[5, "x+1"], [1, 2]],
16
- * [[1, "a+b"], [2, 1]]
17
- * ]
18
- *
19
- */
20
- export declare class Product {
21
- readonly options?: {
22
- canonical?: boolean;
23
- };
24
- engine: ComputeEngine;
25
- coefficient: NumericValue;
26
- terms: {
27
- term: BoxedExpression;
28
- exponent: Rational;
29
- }[];
30
- private _isCanonical;
31
- static from(expr: BoxedExpression): Product;
32
- constructor(ce: ComputeEngine, xs?: ReadonlyArray<BoxedExpression>, options?: {
33
- canonical?: boolean;
34
- });
35
- /**
36
- * Add a term to the product.
37
- *
38
- * If `this._isCanonical` a running product of exact terms is kept.
39
- * Otherwise, terms and their exponent are tallied.
40
- */
41
- mul(term: BoxedExpression, exp?: Rational): void;
42
- /** Divide the product by a term of coefficient */
43
- div(term: NumericValue | BoxedExpression): void;
44
- /** The terms of the product, grouped by degrees.
45
- *
46
- * If `mode` is `rational`, rationals are split into separate numerator and
47
- * denominator, so that a rational expression can be created later
48
- * If `mode` is `expression`, a boxed expression is returned, without
49
- * splitting rationals
50
- * If `mode` is `numeric`, the literals are combined into one expression
51
- *
52
- */
53
- groupedByDegrees(options?: {
54
- mode?: 'rational' | 'expression' | 'numeric';
55
- }): {
56
- exponent: Rational;
57
- terms: BoxedExpression[];
58
- }[] | null;
59
- asExpression(options?: {
60
- numericApproximation: boolean;
61
- }): BoxedExpression;
62
- /** The product, expressed as a numerator and denominator */
63
- asNumeratorDenominator(): [BoxedExpression, BoxedExpression];
64
- asRationalExpression(): BoxedExpression;
65
- }
66
- export declare function commonTerms(lhs: Product, rhs: Product): [NumericValue, BoxedExpression];
@@ -1,129 +0,0 @@
1
- /* 0.30.2 */
2
- export declare const ConditionParent: {
3
- boolean: string;
4
- string: string;
5
- expression: string;
6
- numeric: string;
7
- number: string;
8
- symbol: string;
9
- complex: string;
10
- imaginary: string;
11
- real: string;
12
- notreal: string;
13
- integer: string;
14
- rational: string;
15
- irrational: string;
16
- notzero: string;
17
- notone: string;
18
- finite: string;
19
- infinite: string;
20
- positive: string;
21
- negative: string;
22
- nonnegative: string;
23
- nonpositive: string;
24
- even: string;
25
- odd: string;
26
- prime: string;
27
- composite: string;
28
- constant: string;
29
- variable: string;
30
- function: string;
31
- operator: string;
32
- relation: string;
33
- equation: string;
34
- inequality: string;
35
- collection: string;
36
- list: string;
37
- set: string;
38
- tuple: string;
39
- single: string;
40
- pair: string;
41
- triple: string;
42
- tensor: string;
43
- vector: string;
44
- matrix: string;
45
- scalar: string;
46
- unit: string;
47
- dimension: string;
48
- angle: string;
49
- polynomial: string;
50
- };
51
- export declare const CONDITIONS: {
52
- boolean: (x: BoxedExpression) => boolean;
53
- string: (x: BoxedExpression) => boolean;
54
- number: (x: BoxedExpression) => boolean;
55
- symbol: (x: BoxedExpression) => boolean;
56
- expression: (x: BoxedExpression) => boolean;
57
- numeric: (x: BoxedExpression) => boolean;
58
- integer: (x: BoxedExpression) => boolean;
59
- rational: (x: BoxedExpression) => boolean;
60
- irrational: (x: BoxedExpression) => boolean;
61
- real: (x: BoxedExpression) => boolean;
62
- notreal: (x: BoxedExpression) => boolean;
63
- complex: (x: BoxedExpression) => boolean;
64
- imaginary: (x: BoxedExpression) => boolean;
65
- positive: (x: BoxedExpression) => boolean;
66
- negative: (x: BoxedExpression) => boolean;
67
- nonnegative: (x: BoxedExpression) => boolean;
68
- nonpositive: (x: BoxedExpression) => boolean;
69
- even: (x: BoxedExpression) => boolean;
70
- odd: (x: BoxedExpression) => boolean;
71
- prime: (x: BoxedExpression) => boolean;
72
- composite: (x: BoxedExpression) => boolean;
73
- notzero: (x: BoxedExpression) => boolean;
74
- notone: (x: BoxedExpression) => boolean;
75
- finite: (x: BoxedExpression) => boolean;
76
- infinite: (x: BoxedExpression) => boolean;
77
- constant: (x: BoxedExpression) => boolean;
78
- variable: (x: BoxedExpression) => boolean;
79
- function: (x: BoxedExpression) => boolean;
80
- relation: (x: BoxedExpression) => boolean;
81
- equation: (x: BoxedExpression) => boolean;
82
- inequality: (x: BoxedExpression) => boolean;
83
- collection: (x: BoxedExpression) => boolean;
84
- list: (x: BoxedExpression) => boolean;
85
- set: (x: BoxedExpression) => boolean;
86
- tuple: (x: BoxedExpression) => boolean;
87
- single: (x: BoxedExpression) => boolean;
88
- pair: (x: BoxedExpression) => boolean;
89
- triple: (x: BoxedExpression) => boolean;
90
- scalar: (x: BoxedExpression) => boolean;
91
- tensor: (x: BoxedExpression) => boolean;
92
- vector: (x: BoxedExpression) => boolean;
93
- matrix: (x: BoxedExpression) => boolean;
94
- unit: (x: BoxedExpression) => boolean;
95
- dimension: (x: BoxedExpression) => boolean;
96
- angle: (x: BoxedExpression) => boolean;
97
- polynomial: (x: BoxedExpression) => boolean;
98
- };
99
- export declare function checkConditions(x: BoxedExpression, conditions: string[]): boolean;
100
- /**
101
- * Create a boxed rule set from a collection of non-boxed rules
102
- */
103
- export declare function boxRules(ce: ComputeEngine, rs: Rule | ReadonlyArray<Rule | BoxedRule> | BoxedRuleSet | undefined | null, options?: {
104
- canonical?: boolean;
105
- }): BoxedRuleSet;
106
- /**
107
- * Apply a rule to an expression, assuming an incoming substitution
108
- * @param rule the rule to apply
109
- * @param expr the expression to apply the rule to
110
- * @param substitution an incoming substitution
111
- * @param options
112
- * @returns A transformed expression, if the rule matched. `null` otherwise.
113
- */
114
- export declare function applyRule(rule: Readonly<BoxedRule>, expr: BoxedExpression, substitution: BoxedSubstitution, options?: Readonly<Partial<ReplaceOptions>>): RuleStep | null;
115
- /**
116
- * Apply the rules in the ruleset and return a modified expression
117
- * and the set of rules that were applied.
118
- *
119
- * The `replace` function can be used to apply a rule to a non-canonical
120
- * expression. @fixme: account for options.canonical
121
- *
122
- */
123
- export declare function replace(expr: BoxedExpression, rules: Rule | (Rule | BoxedRule)[] | BoxedRuleSet, options?: Partial<ReplaceOptions>): RuleSteps;
124
- /**
125
- * For each rules in the rule set that match, return the `replace` of the rule
126
- *
127
- * @param rules
128
- */
129
- export declare function matchAnyRules(expr: BoxedExpression, rules: BoxedRuleSet, sub: BoxedSubstitution, options?: Partial<ReplaceOptions>): BoxedExpression[];
@@ -1,3 +0,0 @@
1
- /* 0.30.2 */
2
- import type { ComputeEngine, BoxedExpression, JsonSerializationOptions } from '../global-types';
3
- export declare function serializeJson(ce: ComputeEngine, expr: BoxedExpression, options: Readonly<JsonSerializationOptions>): Expression;
@@ -1,46 +0,0 @@
1
- /* 0.30.2 */
2
- export declare function sgn(expr: BoxedExpression): Sign | undefined;
3
- /**
4
- * Sign `s` is > 0.
5
- *
6
- * :::info[Note]
7
- * Returns `undefined` for cases where the given sign is either non-applicable to real numbers
8
- * ('nan', 'unsigned', 'complex-infinity') or does not convey enough information (e.g. 'real',
9
- * 'not-zero', 'real-not-zero', 'non-negative').
10
- * :::
11
- *
12
- * @param s
13
- */
14
- export declare function positiveSign(s: Sign | undefined): boolean | undefined;
15
- /**
16
- * Sign `s` is >= 0.
17
- *
18
- *
19
- * **note**: returns *undefined* where sign does not apply to the field of reals, or does not convey
20
- * enough information.
21
- *
22
- * @param s
23
- */
24
- export declare function nonNegativeSign(s: Sign | undefined): boolean | undefined;
25
- /**
26
- * Sign `s` is < 0.
27
- *
28
- * :::info[Note]
29
- * Returns `undefined` for cases where the given sign is either non-applicable to real numbers
30
- * ('nan', 'unsigned', 'complex-infinity') or does not convey enough information (e.g. 'real',
31
- * 'not-zero', 'real-not-zero', 'non-positive').
32
- * :::
33
- *
34
- * @param s
35
- */
36
- export declare function negativeSign(s: Sign | undefined): boolean | undefined;
37
- /**
38
- * Sign `s` is <= 0.
39
- *
40
- *
41
- * **note**: returns *undefined* where sign does not apply to the field of reals, or does not convey
42
- * enough information.
43
- *
44
- * @param s
45
- */
46
- export declare function nonPositiveSign(s: Sign | undefined): boolean | undefined;
@@ -1,6 +0,0 @@
1
- /* 0.30.2 */
2
- type InternalSimplifyOptions = SimplifyOptions & {
3
- useVariations: boolean;
4
- };
5
- export declare function simplify(expr: BoxedExpression, options?: Partial<InternalSimplifyOptions>, steps?: RuleSteps): RuleSteps;
6
- export {};
@@ -1,20 +0,0 @@
1
- /* 0.30.2 */
2
- export declare const UNIVARIATE_ROOTS: Rule[];
3
- /**
4
- * Expression is a function of a single variable (`x`) or an Equality
5
- *
6
- * Return the roots of that variable
7
- *
8
- */
9
- export declare function findUnivariateRoots(expr: BoxedExpression, x: string): ReadonlyArray<BoxedExpression>;
10
- /** Expr is an equation with an operator of
11
- * - `Equal`, `Less`, `Greater`, `LessEqual`, `GreaterEqual`
12
- *
13
- * Return an expression with the same operator, but with the first argument
14
- * a variable, if possible:
15
- * `2x < 4` => `x < 2`
16
- */
17
- export declare function univariateSolve(expr: BoxedExpression, x: string): ReadonlyArray<BoxedExpression> | null;
18
- /** Harmonization rules transform an expr into one or more equivalent
19
- * expressions that are easier to solve */
20
- export declare const HARMONIZATION_RULES: Rule[];
@@ -1,10 +0,0 @@
1
- /* 0.30.2 */
2
- export declare class Terms {
3
- private engine;
4
- private terms;
5
- constructor(ce: ComputeEngine, terms: ReadonlyArray<BoxedExpression>);
6
- private add;
7
- private find;
8
- N(): BoxedExpression;
9
- asExpression(): BoxedExpression;
10
- }
@@ -1,9 +0,0 @@
1
- /* 0.30.2 */
2
- export declare function Fu(exp: BoxedExpression): RuleStep | undefined;
3
- /** Assuming x in an expression in radians, convert to current angular unit. */
4
- export declare function radiansToAngle(x: BoxedExpression | undefined): BoxedExpression | undefined;
5
- export declare function evalTrig(name: string, op: BoxedExpression | undefined): BoxedExpression | undefined;
6
- export declare function processInverseFunction(ce: ComputeEngine, xs: ReadonlyArray<BoxedExpression>): BoxedExpression | undefined;
7
- export declare function trigSign(operator: string, x: BoxedExpression): Sign | undefined;
8
- export declare function isConstructible(x: string | BoxedExpression): boolean;
9
- export declare function constructibleValues(operator: string, x: BoxedExpression | undefined): undefined | BoxedExpression;