@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,5 +0,0 @@
1
- /* 0.30.2 */
2
- export declare function asLatexString(s: unknown): string | null;
3
- export declare function isRelationalOperator(name: string | undefined): boolean;
4
- export declare function isInequalityOperator(operator: string | undefined): boolean;
5
- export declare function isEquationOperator(operator: string | undefined): boolean;
@@ -1,4 +0,0 @@
1
- /* 0.30.2 */
2
- export type CanonicalArithmeticOperators = 'Add' | 'Negate' | 'Multiply' | 'Divide' | 'Power' | 'Sqrt' | 'Root' | 'Ln';
3
- export declare const ARITHMETIC_LIBRARY: SymbolDefinitions[];
4
- export declare function isPrime(expr: BoxedExpression): boolean | undefined;
@@ -1,2 +0,0 @@
1
- /* 0.30.2 */
2
- export declare const CALCULUS_LIBRARY: SymbolDefinitions[];
@@ -1,27 +0,0 @@
1
- /* 0.30.2 */
2
- export declare const DEFAULT_LINSPACE_COUNT = 50;
3
- export declare const COLLECTIONS_LIBRARY: SymbolDefinitions;
4
- /**
5
- * Normalize the arguments of range:
6
- * - [from, to] -> [from, to, 1] if to > from, or [from, to, -1] if to < from
7
- * - [x] -> [1, x]
8
- * - arguments rounded to integers
9
- *
10
- */
11
- export declare function range(expr: BoxedExpression): [lower: number, upper: number, step: number];
12
- /** Return the last value in the range
13
- * - could be less that lower if step is negative
14
- * - could be less than upper if step is positive, for
15
- * example `rangeLast([1, 6, 2])` = 5
16
- */
17
- export declare function rangeLast(r: [lower: number, upper: number, step: number]): number;
18
- /**
19
- * This function is used to reduce a collection of expressions to a single value. It
20
- * iterates over the collection, applying the given function to each element and the
21
- * accumulator. If the function returns `null`, the iteration is stopped and `undefined`
22
- * is returned. Otherwise, the result of the function is used as the new accumulator.
23
- * If the iteration completes, the final accumulator is returned.
24
- */
25
- export declare function reduceCollection<T>(collection: BoxedExpression, fn: (acc: T, next: BoxedExpression) => T | null, initial: T): Generator<T | undefined>;
26
- export declare function fromRange(start: number, end: number): number[];
27
- export declare function sortedIndices(expr: BoxedExpression, fn?: BoxedExpression | undefined): number[] | undefined;
@@ -1,2 +0,0 @@
1
- /* 0.30.2 */
2
- export declare const COMBINATORICS_LIBRARY: SymbolDefinitions[];
@@ -1,2 +0,0 @@
1
- /* 0.30.2 */
2
- export declare const COMPLEX_LIBRARY: SymbolDefinitions[];
@@ -1,2 +0,0 @@
1
- /* 0.30.2 */
2
- export declare const CONTROL_STRUCTURES_LIBRARY: SymbolDefinitions[];
@@ -1,2 +0,0 @@
1
- /* 0.30.2 */
2
- export declare const CORE_LIBRARY: SymbolDefinitions[];
@@ -1,4 +0,0 @@
1
- /* 0.30.2 */
2
- export declare function canonicalInvisibleOperator(ops: ReadonlyArray<BoxedExpression>, { engine: ce }: {
3
- engine: ComputeEngine;
4
- }): BoxedExpression | null;
@@ -1,17 +0,0 @@
1
- /* 0.30.2 */
2
- import type { SymbolDefinitions, ComputeEngine } from '../global-types';
3
- export declare function getStandardLibrary(categories: LibraryCategory[] | LibraryCategory | 'all'): readonly SymbolDefinitions[];
4
- export declare const LIBRARIES: {
5
- [category in LibraryCategory]?: SymbolDefinitions | SymbolDefinitions[];
6
- };
7
- /**
8
- * Set the symbol table of the current context (`engine.context`) to `table`
9
- *
10
- * `table` can be an array of symbol tables, in order to deal with circular
11
- * dependencies: it is possible to partition a library into multiple
12
- * symbol tables, to control the order in which they are processed and
13
- * avoid having expressions in the definition of an entry reference a symbol
14
- * or function name that has not yet been added to the symbol table.
15
- *
16
- */
17
- export declare function setSymbolDefinitions(engine: ComputeEngine, table: SymbolDefinitions): void;
@@ -1,2 +0,0 @@
1
- /* 0.30.2 */
2
- export declare const LINEAR_ALGEBRA_LIBRARY: SymbolDefinitions[];
@@ -1,6 +0,0 @@
1
- /* 0.30.2 */
2
- export declare const LOGIC_LIBRARY: SymbolDefinitions;
3
- export declare function simplifyLogicFunction(x: BoxedExpression): {
4
- value: BoxedExpression;
5
- because: string;
6
- } | undefined;
@@ -1,2 +0,0 @@
1
- /* 0.30.2 */
2
- export declare const NUMBER_THEORY_LIBRARY: SymbolDefinitions[];
@@ -1,2 +0,0 @@
1
- /* 0.30.2 */
2
- export declare const POLYNOMIALS_LIBRARY: SymbolDefinitions[];
@@ -1,2 +0,0 @@
1
- /* 0.30.2 */
2
- export declare function randomExpression(level?: number): Expression;
@@ -1,2 +0,0 @@
1
- /* 0.30.2 */
2
- export declare const RELOP_LIBRARY: SymbolDefinitions;
@@ -1,2 +0,0 @@
1
- /* 0.30.2 */
2
- export declare const SETS_LIBRARY: SymbolDefinitions;
@@ -1,2 +0,0 @@
1
- /* 0.30.2 */
2
- export declare const STATISTICS_LIBRARY: SymbolDefinitions[];
@@ -1,2 +0,0 @@
1
- /* 0.30.2 */
2
- export declare const TRIGONOMETRY_LIBRARY: SymbolDefinitions[];
@@ -1,77 +0,0 @@
1
- /* 0.30.2 */
2
- export type IndexingSet = {
3
- index: string | undefined;
4
- lower: number;
5
- upper: number;
6
- isFinite: boolean;
7
- };
8
- /**
9
- * IndexingSet is an expression describing an index variable
10
- * and a range of values for that variable.
11
- *
12
- * Note that when this function is called the indexing set is assumed to be canonical: 'Hold' has been handled, the indexing set is a tuple, and the bounds are canonical.
13
- *
14
- * This can take several valid forms:
15
- * - a symbol, e.g. `n`, the upper and lower bounds are assumed ot be infinity
16
- * - a tuple, e.g. `["Pair", "n", 1]` or `["Tuple", "n", 1, 10]` with one
17
- * or two bounds
18
- *
19
- * The result is a normalized version that includes the index, the lower and
20
- * upper bounds of the range, and a flag indicating whether the range is finite.
21
- * @param indexingSet
22
- * @returns
23
- */
24
- export declare function normalizeIndexingSet(indexingSet: BoxedExpression): IndexingSet;
25
- export declare function normalizeIndexingSets(ops: ReadonlyArray<BoxedExpression>): IndexingSet[];
26
- export declare function indexingSetCartesianProduct(indexingSets: IndexingSet[]): number[][];
27
- /**
28
- * Calculates the cartesian product of two arrays.
29
- * ```ts
30
- * // Example usage
31
- * const array1 = [1, 2, 3];
32
- * const array2 = ['a', 'b', 'c'];
33
- * const result = cartesianProduct(array1, array2);
34
- * console.log(result);
35
- * // Output: [[1, 'a'], [1, 'b'], [1, 'c'], [2, 'a'], [2, 'b'], [2, 'c'], [3, 'a'], [3, 'b'], [3, 'c']]
36
- * ```
37
- * @param array1 - The first array.
38
- * @param array2 - The second array.
39
- * @returns The cartesian product as a 2D array.
40
- */
41
- export declare function cartesianProduct(array1: number[], array2: number[]): number[][];
42
- /** Given a sequence of arguments, return an array of Limits:
43
- *
44
- * - ["Range", 1, 10] -> ["Limits", "Unknown", 1, 10]
45
- * - 1, 10 -> ["Limits", "Nothing", 1, 10]
46
- * - [Tuple, "x", 1, 10] -> ["Limits", "x", 1, 10]
47
- *
48
- */
49
- export declare function canonicalLimitsSequence(ops: ReadonlyArray<BoxedExpression>, options: {
50
- engine: ComputeEngine;
51
- }): BoxedExpression[];
52
- export declare function canonicalLimits(ops: ReadonlyArray<BoxedExpression>, { engine: ce }: {
53
- engine: ComputeEngine;
54
- }): BoxedExpression | null;
55
- /** Return a limit/indexing set in canonical form as a `Limits` expression
56
- * with:
57
- * - `index` (a symbol), `Nothing` if none is present
58
- * - `lower` (a number), `Nothing` if none is present
59
- * - `upper` (a number), `Nothing` if none is present
60
- *
61
- * Assume we are in the context of a big operator
62
- * (i.e. `pushScope()` has been called)
63
- */
64
- export declare function canonicalIndexingSet(expr: BoxedExpression): BoxedExpression | undefined;
65
- export declare function canonicalBigop(bigOp: string, body: BoxedExpression, indexingSets: BoxedExpression[], scope: Scope | undefined): BoxedExpression | null;
66
- /**
67
- * Process an expression of the form
68
- * - ['Operator', body, ['Tuple', index1, lower, upper]]
69
- * - ['Operator', body, ['Tuple', index1, lower, upper], ['Tuple', index2, lower, upper], ...]
70
- * - ['Operator', body]
71
- * - ['Operator', collection]
72
- *
73
- * `fn()` is the processing done on each element
74
- * Apply the function `fn` to the body of a big operator, according to the
75
- * indexing sets.
76
- */
77
- export declare function reduceBigOp<T>(body: BoxedExpression, indexes: ReadonlyArray<BoxedExpression>, fn: (acc: T, x: BoxedExpression) => T | null, initial: T): Generator<T | undefined>;
@@ -1,57 +0,0 @@
1
- /* 0.30.2 */
2
- import { BigNumFactory, NumericValue, NumericValueData } from './types';
3
- import { ExactNumericValue } from './exact-numeric-value';
4
- import { Expression } from '../../math-json/types';
5
- import { SmallInteger } from '../numerics/types';
6
- import { NumericPrimitiveType } from '../../common/type/types';
7
- export declare class BigNumericValue extends NumericValue {
8
- __brand: 'BigNumericValue';
9
- decimal: Decimal;
10
- bignum: BigNumFactory;
11
- constructor(value: number | Decimal | NumericValueData, bignum: BigNumFactory);
12
- get type(): NumericPrimitiveType;
13
- get isExact(): boolean;
14
- get asExact(): ExactNumericValue | undefined;
15
- toJSON(): Expression;
16
- toString(): string;
17
- clone(value: number | Decimal | NumericValueData): BigNumericValue;
18
- private _makeExact;
19
- get re(): number;
20
- get bignumRe(): Decimal;
21
- get numerator(): BigNumericValue;
22
- get denominator(): ExactNumericValue;
23
- get isNaN(): boolean;
24
- get isPositiveInfinity(): boolean;
25
- get isNegativeInfinity(): boolean;
26
- get isComplexInfinity(): boolean;
27
- get isZero(): boolean;
28
- isZeroWithTolerance(tolerance: number | Decimal): boolean;
29
- get isOne(): boolean;
30
- get isNegativeOne(): boolean;
31
- sgn(): -1 | 0 | 1 | undefined;
32
- N(): NumericValue;
33
- neg(): BigNumericValue;
34
- inv(): BigNumericValue;
35
- add(other: number | NumericValue): NumericValue;
36
- sub(other: NumericValue): NumericValue;
37
- mul(other: number | Decimal | NumericValue): NumericValue;
38
- div(other: SmallInteger | NumericValue): NumericValue;
39
- pow(exponent: number | NumericValue | {
40
- re: number;
41
- im: number;
42
- }): NumericValue;
43
- root(exp: number): NumericValue;
44
- sqrt(): NumericValue;
45
- gcd(other: NumericValue): NumericValue;
46
- abs(): NumericValue;
47
- ln(base?: number): NumericValue;
48
- exp(): NumericValue;
49
- floor(): NumericValue;
50
- ceil(): NumericValue;
51
- round(): NumericValue;
52
- eq(other: number | NumericValue): boolean;
53
- lt(other: number | NumericValue): boolean | undefined;
54
- lte(other: number | NumericValue): boolean | undefined;
55
- gt(other: number | NumericValue): boolean | undefined;
56
- gte(other: number | NumericValue): boolean | undefined;
57
- }
@@ -1,75 +0,0 @@
1
- /* 0.30.2 */
2
- import { Rational, SmallInteger } from '../numerics/types';
3
- import { BigNumFactory, ExactNumericValueData, NumericValue, NumericValueFactory } from './types';
4
- import { Expression } from '../../math-json/types';
5
- import { NumericPrimitiveType } from '../../common/type/types';
6
- /**
7
- * An ExactNumericValue is the sum of a Gaussian imaginary and the product of
8
- * a rational number and a square root:
9
- *
10
- * a/b * sqrt(c) + ki where a, b, c and k are integers
11
- *
12
- * Note that ExactNumericValue does not "know" about BigNumericValue, but
13
- * BigNumericValue "knows" about ExactNumericValue.
14
- *
15
- */
16
- export declare class ExactNumericValue extends NumericValue {
17
- __brand: 'ExactNumericValue';
18
- rational: Rational;
19
- radical: number;
20
- im: number;
21
- factory: NumericValueFactory;
22
- bignum: BigNumFactory;
23
- /** The caller is responsible to make sure the input is valid, i.e.
24
- * - rational is a fraction of integers (but it may not be reduced)
25
- * - radical is an integer
26
- */
27
- constructor(value: number | bigint | ExactNumericValueData, factory: NumericValueFactory, bignum: BigNumFactory);
28
- get type(): NumericPrimitiveType;
29
- get isExact(): boolean;
30
- get asExact(): NumericValue | undefined;
31
- toJSON(): Expression;
32
- clone(value: number | ExactNumericValueData): ExactNumericValue;
33
- /** Object.toString() */
34
- toString(): string;
35
- get sign(): -1 | 0 | 1;
36
- get re(): number;
37
- get bignumRe(): Decimal;
38
- get numerator(): ExactNumericValue;
39
- get denominator(): ExactNumericValue;
40
- normalize(): void;
41
- get isNaN(): boolean;
42
- get isPositiveInfinity(): boolean;
43
- get isNegativeInfinity(): boolean;
44
- get isComplexInfinity(): boolean;
45
- get isZero(): boolean;
46
- get isOne(): boolean;
47
- get isNegativeOne(): boolean;
48
- sgn(): -1 | 0 | 1 | undefined;
49
- N(): NumericValue;
50
- neg(): ExactNumericValue;
51
- inv(): NumericValue;
52
- add(other: number | NumericValue): NumericValue;
53
- sub(other: NumericValue): NumericValue;
54
- mul(other: number | Decimal | NumericValue): NumericValue;
55
- div(other: SmallInteger | NumericValue): NumericValue;
56
- pow(exponent: number | NumericValue | {
57
- re: number;
58
- im: number;
59
- }): NumericValue;
60
- root(exponent: number): NumericValue;
61
- sqrt(): NumericValue;
62
- gcd(other: NumericValue): NumericValue;
63
- abs(): NumericValue;
64
- ln(base?: number): NumericValue;
65
- exp(): NumericValue;
66
- floor(): NumericValue;
67
- ceil(): NumericValue;
68
- round(): NumericValue;
69
- eq(other: number | NumericValue): boolean;
70
- lt(other: number | NumericValue): boolean | undefined;
71
- lte(other: number | NumericValue): boolean | undefined;
72
- gt(other: number | NumericValue): boolean | undefined;
73
- gte(other: number | NumericValue): boolean | undefined;
74
- static sum(values: NumericValue[], factory: NumericValueFactory, bignumFactory: BigNumFactory): NumericValue[];
75
- }
@@ -1,56 +0,0 @@
1
- /* 0.30.2 */
2
- import { BigNumFactory, NumericValue, NumericValueData } from './types';
3
- import type { Expression } from '../../math-json/types';
4
- import type { SmallInteger } from '../numerics/types';
5
- import { NumericPrimitiveType } from '../../common/type/types';
6
- export declare class MachineNumericValue extends NumericValue {
7
- __brand: 'MachineNumericValue';
8
- decimal: number;
9
- bignum: BigNumFactory;
10
- constructor(value: number | Decimal | NumericValueData, bignum: BigNumFactory);
11
- private _makeExact;
12
- get type(): NumericPrimitiveType;
13
- get isExact(): boolean;
14
- get asExact(): NumericValue | undefined;
15
- toJSON(): Expression;
16
- toString(): string;
17
- clone(value: number | Decimal | NumericValueData): MachineNumericValue;
18
- get re(): number;
19
- get bignumRe(): Decimal | undefined;
20
- get numerator(): MachineNumericValue;
21
- get denominator(): NumericValue;
22
- get isNaN(): boolean;
23
- get isPositiveInfinity(): boolean;
24
- get isNegativeInfinity(): boolean;
25
- get isComplexInfinity(): boolean;
26
- get isZero(): boolean;
27
- isZeroWithTolerance(tolerance: number | Decimal): boolean;
28
- get isOne(): boolean;
29
- get isNegativeOne(): boolean;
30
- sgn(): -1 | 0 | 1 | undefined;
31
- N(): NumericValue;
32
- neg(): NumericValue;
33
- inv(): NumericValue;
34
- add(other: number | NumericValue): NumericValue;
35
- sub(other: NumericValue): NumericValue;
36
- mul(other: number | Decimal | NumericValue): NumericValue;
37
- div(other: SmallInteger | NumericValue): NumericValue;
38
- pow(exponent: number | {
39
- re: number;
40
- im: number;
41
- }): NumericValue;
42
- root(exponent: number): NumericValue;
43
- sqrt(): NumericValue;
44
- gcd(other: NumericValue): NumericValue;
45
- abs(): NumericValue;
46
- ln(base?: number): NumericValue;
47
- exp(): NumericValue;
48
- floor(): NumericValue;
49
- ceil(): NumericValue;
50
- round(): NumericValue;
51
- eq(other: number | NumericValue): boolean;
52
- lt(other: number | NumericValue): boolean | undefined;
53
- lte(other: number | NumericValue): boolean | undefined;
54
- gt(other: number | NumericValue): boolean | undefined;
55
- gte(other: number | NumericValue): boolean | undefined;
56
- }
@@ -1,116 +0,0 @@
1
- /* 0.30.2 */
2
- *
3
- * ## THEORY OF OPERATIONS
4
- *
5
- * A numeric value represents a number literal.
6
- *
7
- * It is defined as a functional field over the complex numbers.
8
- *
9
- * It includes basic arithmetic operations: addition, subtraction,
10
- * multiplication, power, division, negation, inversion, square root.
11
- *
12
- * Several flavors of numeric values are available:
13
- * - `NumericValue` is the base class for all numeric values.
14
- * - `ExactNumericValue` is a numeric value that represents numbers as the
15
- * sum of an imaginary number and the product of a rational and a radical
16
- * (square root of a integer).
17
- * - `BigNumericValue` is a numeric value that represents numbers as the
18
- * sum of an imaginary number and a decimal (arbitrary precision) number.
19
- *
20
- * An exact numeric value may need to be converted to a float one, for
21
- * example when calculating the square root of a square root.
22
- *
23
- * A float numeric value is never converted to an exact one.
24
- *
25
- */
26
- import { Decimal } from 'decimal.js';
27
- import type { Rational, SmallInteger } from '../numerics/types';
28
- import { NumericPrimitiveType } from '../../common/type/types';
29
- export type BigNumFactory = (value: Decimal.Value) => Decimal;
30
- /** The value is equal to `(decimal * rational * sqrt(radical)) + im * i`
31
- * @category Numerics */
32
- export type ExactNumericValueData = {
33
- rational?: Rational;
34
- radical?: number;
35
- };
36
- /** @category Numerics */
37
- export type NumericValueData = {
38
- re?: Decimal | number;
39
- im?: number;
40
- };
41
- /** @category Numerics */
42
- export type NumericValueFactory = (data: number | Decimal | NumericValueData) => NumericValue;
43
- /** @category Numerics */
44
- export declare abstract class NumericValue {
45
- abstract get type(): NumericPrimitiveType;
46
- /** True if numeric value is the product of a rational and the square root of an integer.
47
- *
48
- * This includes: 3/4√5, -2, √2, etc...
49
- *
50
- * But it doesn't include 0.5, 3.141592, etc...
51
- *
52
- */
53
- abstract get isExact(): boolean;
54
- /** If `isExact()`, returns an ExactNumericValue, otherwise returns undefined.
55
- */
56
- abstract get asExact(): NumericValue | undefined;
57
- /** The real part of this numeric value.
58
- *
59
- * Can be negative, 0 or positive.
60
- */
61
- abstract get re(): number;
62
- /** bignum version of .re, if available */
63
- get bignumRe(): Decimal | undefined;
64
- /** The imaginary part of this numeric value.
65
- *
66
- * Can be negative, zero or positive.
67
- */
68
- im: number;
69
- get bignumIm(): Decimal | undefined;
70
- abstract get numerator(): NumericValue;
71
- abstract get denominator(): NumericValue;
72
- abstract get isNaN(): boolean;
73
- abstract get isPositiveInfinity(): boolean;
74
- abstract get isNegativeInfinity(): boolean;
75
- abstract get isComplexInfinity(): boolean;
76
- abstract get isZero(): boolean;
77
- isZeroWithTolerance(_tolerance: number | Decimal): boolean;
78
- abstract get isOne(): boolean;
79
- abstract get isNegativeOne(): boolean;
80
- /** The sign of complex numbers is undefined */
81
- abstract sgn(): -1 | 0 | 1 | undefined;
82
- /** Return a non-exact representation of the numeric value */
83
- abstract N(): NumericValue;
84
- abstract neg(): NumericValue;
85
- abstract inv(): NumericValue;
86
- abstract add(other: number | NumericValue): NumericValue;
87
- abstract sub(other: NumericValue): NumericValue;
88
- abstract mul(other: number | Decimal | NumericValue): NumericValue;
89
- abstract div(other: SmallInteger | NumericValue): NumericValue;
90
- abstract pow(n: number | NumericValue | {
91
- re: number;
92
- im: number;
93
- }): NumericValue;
94
- abstract root(n: number): NumericValue;
95
- abstract sqrt(): NumericValue;
96
- abstract gcd(other: NumericValue): NumericValue;
97
- abstract abs(): NumericValue;
98
- abstract ln(base?: number): NumericValue;
99
- abstract exp(): NumericValue;
100
- abstract floor(): NumericValue;
101
- abstract ceil(): NumericValue;
102
- abstract round(): NumericValue;
103
- abstract eq(other: number | NumericValue): boolean;
104
- abstract lt(other: number | NumericValue): boolean | undefined;
105
- abstract lte(other: number | NumericValue): boolean | undefined;
106
- abstract gt(other: number | NumericValue): boolean | undefined;
107
- abstract gte(other: number | NumericValue): boolean | undefined;
108
- /** Object.valueOf(): returns a primitive value, preferably a JavaScript
109
- * number over a string, even if at the expense of precision */
110
- valueOf(): number | string;
111
- /** Object.toPrimitive() */
112
- [Symbol.toPrimitive](hint: 'number' | 'string' | 'default'): number | string | null;
113
- /** Object.toJSON */
114
- toJSON(): any;
115
- print(): void;
116
- }
@@ -1,2 +0,0 @@
1
- /* 0.30.2 */
2
- export declare function bigint(a: Decimal | number | bigint | string): bigint | null;
@@ -1,4 +0,0 @@
1
- /* 0.30.2 */
2
- export declare function bigintValue(expr: Expression | null | undefined): bigint | null;
3
- /** Output a shorthand if possible */
4
- export declare function numberToExpression(num: number | bigint, fractionalDigits?: string | number): Expression;
@@ -1,12 +0,0 @@
1
- /* 0.30.2 */
2
- /** An interval is a continuous set of real numbers */
3
- export type Interval = {
4
- start: number;
5
- openStart: boolean;
6
- end: number;
7
- openEnd: boolean;
8
- };
9
- export declare function interval(expr: BoxedExpression): Interval | undefined;
10
- export declare function intervalContains(int: Interval, val: number): boolean;
11
- /** Return true if int1 is a subset of int2 */
12
- export declare function intervalSubset(int1: Interval, int2: Interval): boolean;
@@ -1,4 +0,0 @@
1
- /* 0.30.2 */
2
- estimate: number;
3
- error: number;
4
- };
@@ -1,18 +0,0 @@
1
- /* 0.30.2 */
2
- export declare function lcm(a: bigint, b: bigint): bigint;
3
- /** Return `[factor, root]` such that
4
- * pow(n, 1/exponent) = factor * pow(root, 1/exponent)
5
- *
6
- * canonicalInteger(75, 2) -> [5, 3] = 5^2 * 3
7
- *
8
- */
9
- export declare function canonicalInteger(n: bigint, exponent: number): [factor: bigint, root: bigint];
10
- export declare function reducedInteger(n: bigint): bigint | number;
11
- /**
12
- * Computes the factorial of a number as a generator to allow interruptibility.
13
- * Yields intermediate values periodically, but these are not intended to be the primary result.
14
- *
15
- * @param n - The number to compute the factorial of (as a BigInt).
16
- * @returns A generator that can be iterated for intermediate values, with the final value returned when the computation completes.
17
- */
18
- export declare function factorial(n: bigint): Generator<bigint, bigint>;
@@ -1,9 +0,0 @@
1
- /* 0.30.2 */
2
- export declare function gcd(a: BigNum, b: BigNum): BigNum;
3
- export declare function lcm(a: BigNum, b: BigNum): BigNum;
4
- export declare function factorial2(ce: IBigNum, n: BigNum): BigNum;
5
- /**
6
- * If the exponent of the bignum is in the range of the exponents
7
- * for machine numbers,return true.
8
- */
9
- export declare function isInMachineRange(d: BigNum): boolean;
@@ -1,3 +0,0 @@
1
- /* 0.30.2 */
2
- export declare function gamma(c: Complex): Complex;
3
- export declare function gammaln(c: Complex): Complex;
@@ -1,60 +0,0 @@
1
- /* 0.30.2 */
2
- export declare const MACHINE_PRECISION_BITS = 53;
3
- export declare const MACHINE_PRECISION: number;
4
- export declare const DEFAULT_TOLERANCE = 1e-10;
5
- export declare const SMALL_INTEGER = 1000000;
6
- /** The largest number of digits of a bigint */
7
- export declare const MAX_BIGINT_DIGITS = 1024;
8
- export declare const MAX_ITERATION = 1000000;
9
- export declare const MAX_SYMBOLIC_TERMS = 200;
10
- /**
11
- * Returns the smallest floating-point number greater than x.
12
- * Denormalized values may not be supported.
13
- */
14
- export declare function nextUp(x: number): number;
15
- export declare function nextDown(x: number): number;
16
- /** Return `[factor, root]` such that
17
- * pow(n, 1/exponent) = factor * pow(root, 1/exponent)
18
- *
19
- * canonicalInteger(75, 2) -> [5, 3] = 5^2 * 3
20
- *
21
- */
22
- export declare function canonicalInteger(n: number, exponent: number): readonly [factor: number, root: number];
23
- export declare function gcd(a: number, b: number): number;
24
- export declare function lcm(a: number, b: number): number;
25
- export declare function factorial(n: number): number;
26
- export declare function factorial2(n: number): number;
27
- export declare function chop(n: number, tolerance?: number): 0 | number;
28
- /**
29
- * An 8th-order centered difference approximation can be used to get a highly
30
- * accurate approximation of the first derivative of a function.
31
- * The formula for the 8th-order centered difference approximation for the
32
- * first derivative is given by:
33
- *
34
- * $$ f'(x) \approx \frac{1}{280h} \left[ -f(x-4h) + \frac{4}{3}f(x-3h) - \frac{1}{5}f(x-2h) + \frac{8}{5}f(x-h) - \frac{8}{5}f(x+h) + \frac{1}{5}f(x+2h) - \frac{4}{3}f(x+3h) + f(x+4h) \right]$$
35
- *
36
- * Note: Mathematica uses an 8th order approximation for the first derivative
37
- *
38
- * f: the function
39
- * x: the point at which to approximate the derivative
40
- * h: the step size
41
- *
42
- * See https://en.wikipedia.org/wiki/Finite_difference_coefficient
43
- */
44
- export declare function centeredDiff8thOrder(f: (number: any) => number, x: number, h?: number): number;
45
- /**
46
- *
47
- * @param f
48
- * @param x
49
- * @param dir Direction of approach: > 0 for right, < 0 for left, 0 for both
50
- * @returns
51
- */
52
- export declare function limit(f: (x: number) => number, x: number, dir?: number): number;
53
- export declare function cantorEnumerateRationals(): Generator<[number, number]>;
54
- export declare function cantorEnumeratePositiveRationals(): Generator<[
55
- number,
56
- number
57
- ]>;
58
- export declare function cantorEnumerateComplexNumbers(): Generator<[number, number]>;
59
- export declare function cantorEnumerateIntegers(): Generator<number>;
60
- export declare function cantorEnumerateNaturalNumbers(): Generator<number>;
@@ -1,7 +0,0 @@
1
- /* 0.30.2 */
2
- export declare function primeFactors(n: number): {
3
- [factor: number]: number;
4
- };
5
- export declare function isPrime(n: number): boolean | undefined;
6
- export declare function isPrimeBigint(n: bigint): boolean | undefined;
7
- export declare function bigPrimeFactors(d: bigint): Map<bigint, number>;