@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,43 +0,0 @@
1
- /* 0.31.0 */
2
- export declare function isRational(x: any | null): x is Rational;
3
- export declare function isMachineRational(x: any | null): x is [SmallInteger, SmallInteger];
4
- export declare function isBigRational(x: any | null): x is [bigint, bigint];
5
- export declare function isZero(x: Rational): boolean;
6
- export declare function isPositive(x: Rational): boolean;
7
- export declare function isOne(x: Rational): boolean;
8
- export declare function isNegativeOne(x: Rational): boolean;
9
- export declare function isInteger(x: Rational): boolean;
10
- export declare function machineNumerator(x: Rational): number;
11
- export declare function machineDenominator(x: Rational): number;
12
- export declare function rationalAsFloat(x: Rational): number;
13
- export declare function isNeg(x: Rational): boolean;
14
- export declare function div(lhs: Rational, rhs: Rational): Rational;
15
- /**
16
- * Add a literal numeric value to a rational.
17
- * If the rational is a bigint, this is a hint to do the calculation in bigint
18
- * (no need to check `bignumPreferred()`).
19
- * @param lhs
20
- * @param rhs
21
- * @returns
22
- */
23
- export declare function add(lhs: Rational, rhs: Rational): Rational;
24
- export declare function mul(lhs: Rational, rhs: Rational): Rational;
25
- export declare function neg(x: [SmallInteger, SmallInteger]): [SmallInteger, SmallInteger];
26
- export declare function neg(x: [bigint, bigint]): [bigint, bigint];
27
- export declare function neg(x: Rational): Rational;
28
- export declare function inverse(x: [SmallInteger, SmallInteger]): [SmallInteger, SmallInteger];
29
- export declare function inverse(x: [bigint, bigint]): [bigint, bigint];
30
- export declare function inverse(x: Rational): Rational;
31
- export declare function asMachineRational(r: Rational): [SmallInteger, SmallInteger];
32
- export declare function pow(r: Rational, exp: SmallInteger): Rational;
33
- export declare function sqrt(r: Rational): Rational | undefined;
34
- export declare function rationalGcd(lhs: Rational, rhs: Rational): Rational;
35
- export declare function reducedRational(r: [SmallInteger, SmallInteger]): [SmallInteger, SmallInteger];
36
- export declare function reducedRational(r: [bigint, bigint]): [bigint, bigint];
37
- export declare function reducedRational(r: Rational): Rational;
38
- /** Return a rational approximation of x */
39
- export declare function rationalize(x: number): [n: number, d: number] | number;
40
- /** Return [factor, root] such that factor * sqrt(root) = sqrt(n)
41
- * when factor and root are rationals
42
- */
43
- export declare function reduceRationalSquareRoot(n: Rational): [factor: Rational, root: number | bigint];
@@ -1,80 +0,0 @@
1
- /* 0.31.0 */
2
-
3
- Translated from https://github.com/JuliaMath/Richardson.jl/blob/master/src/Richardson.jl
4
-
5
-
6
- The `Richardson` module provides a function `extrapolate` that
7
- extrapolates a given function `f(x)` to `f(x0)`, evaluating
8
- `f` only at a geometric sequence of points `> x0`
9
- (or optionally `< x0`).
10
-
11
- The key algorithm is Richardson extrapolation using a Neville—Aitken
12
- tableau, which adaptively increases the degree of an extrapolation
13
- polynomial until convergence is achieved to a desired tolerance
14
- (or convergence stalls due to e.g. floating-point errors). This
15
- allows one to obtain `f(x0)` to high-order accuracy, assuming
16
- that `f(x0+h)` has a Taylor series or some other power
17
- series in `h`.
18
- */
19
- export interface ExtrapolateOptions {
20
- contract?: number;
21
- step?: number;
22
- power?: number;
23
- atol?: number;
24
- rtol?: number;
25
- maxeval?: number;
26
- breaktol?: number;
27
- }
28
- /**
29
- *
30
- * Extrapolate `f(x)` to `f₀ ≈ f(x0)`, evaluating `f` only at `x > x0` points
31
- (or `x < x0` if `h < 0`) using Richardson extrapolation starting at
32
- `x=x₀+h`. It returns a tuple `(f₀, err)` of the estimated `f(x0)`
33
- and an error estimate.
34
-
35
- The return value of `f` can be any type supporting `±` and `norm`
36
- operations (i.e. a normed vector space).
37
- Similarly, `h` and `x0` can be in any normed vector space,
38
- in which case `extrapolate` performs Richardson extrapolation
39
- of `f(x0+s*h)` to `s=0⁺` (i.e. it takes the limit as `x` goes
40
- to `x0` along the `h` direction).
41
-
42
- On each step of Richardson extrapolation, it shrinks `x-x0` by
43
- a factor of `contract`, stopping when the estimated error is
44
- `< max(rtol*norm(f₀), atol)`, when the estimated error
45
- increases by more than `breaktol` (e.g. due to numerical errors in the
46
- computation of `f`), when `f` returns a non-finite value (`NaN` or `Inf`),
47
- or when `f` has been evaluated `maxeval` times. Note that
48
- if the function may converge to zero, you may want
49
- specify a nonzero `atol` (which cannot be set by default
50
- because it depends on the scale/units of `f`); alternatively,
51
- in such cases `extrapolate` will halt when it becomes
52
- limited by the floating-point precision. (Passing `breaktol=Inf`
53
- can be useful to force `extrapolate` to continue shrinking `h` even
54
- if polynomial extrapolation is initially failing to converge,
55
- possibly at the cost of extraneous function evaluations.)
56
-
57
-
58
- If `x0 = ±∞` (`±Inf`), then `extrapolate` computes the limit of
59
- `f(x)` as `x ⟶ ±∞` using geometrically *increasing* values
60
- of `h` (by factors of `1/contract`).
61
-
62
- In general, the starting `h` should be large enough that `f(x0+h)`
63
- can be computed accurately and efficiently (e.g. without
64
- severe cancellation errors), but small enough that `f` does not
65
- oscillate much between `x0` and `h`. i.e. `h` should be a typical
66
- scale over which the function `f` varies significantly.
67
-
68
- Technically, Richardson extrapolation assumes that `f(x0+h)` can
69
- be expanded in a power series in `h^power`, where the default
70
- `power=1` corresponds to an ordinary Taylor series (i.e. assuming
71
- `f` is analytic at `x0`). If this is not true, you may obtain
72
- slow convergence from `extrapolate`, but you can pass a different
73
- value of `power` (e.g. `power=0.5`) if your `f` has some different
74
- (Puiseux) power-series expansion. Conversely, if `f` is
75
- an *even* function around `x0`, i.e. `f(x0+h) == f(x0-h)`,
76
- so that its Taylor series contains only *even* powers of `h`,
77
- you can accelerate convergence by passing `power=2`.
78
-
79
- */
80
- export declare function extrapolate(f: (x: number) => number, x0: number, options?: ExtrapolateOptions): [val: number, err: number];
@@ -1,28 +0,0 @@
1
- /* 0.31.0 */
2
- import type { BigNum } from './types';
3
- export declare function gammaln(z: number): number;
4
- export declare function gamma(z: number): number;
5
- /**
6
- * Inverse Error Function.
7
- *
8
- */
9
- export declare function erfInv(x: number): number;
10
- /**
11
- * Trivial function, used when compiling.
12
- */
13
- export declare function erfc(x: number): number;
14
- /**
15
- * An approximation of the gaussian error function, Erf(), using
16
- * Abramowitz and Stegun approximation.
17
- *
18
- * Thoughts for future improvements:
19
- * - https://math.stackexchange.com/questions/321569/approximating-the-error-function-erf-by-analytical-functions
20
- * - https://en.wikipedia.org/wiki/Error_function#Approximation_with_elementary_functions
21
-
22
- *
23
- * References:
24
- * - NIST: https://dlmf.nist.gov/7.24#i
25
- */
26
- export declare function erf(x: number): number;
27
- export declare function bigGammaln(ce: ComputeEngine, z: BigNum): BigNum;
28
- export declare function bigGamma(ce: ComputeEngine, z: BigNum): BigNum;
@@ -1,24 +0,0 @@
1
- /* 0.31.0 */
2
- import type { BigNum } from './types';
3
- export declare function mean(values: Iterable<number>): number;
4
- export declare function bigMean(bignum: BigNumFactory, values: Iterable<BigNum>): BigNum;
5
- export declare function median(values: Iterable<number>): number;
6
- export declare function bigMedian(values: Iterable<BigNum>): BigNum;
7
- export declare function variance(values: Iterable<number>): number;
8
- export declare function bigVariance(bignum: BigNumFactory, values: Iterable<BigNum>): BigNum;
9
- export declare function populationVariance(values: Iterable<number>): number;
10
- export declare function bigPopulationVariance(bignum: BigNumFactory, values: Iterable<BigNum>): BigNum;
11
- export declare function standardDeviation(values: Iterable<number>): number;
12
- export declare function bigStandardDeviation(bignum: BigNumFactory, values: Iterable<BigNum>): BigNum;
13
- export declare function populationStandardDeviation(values: Iterable<number>): number;
14
- export declare function bigPopulationStandardDeviation(bignum: BigNumFactory, values: Iterable<BigNum>): BigNum;
15
- export declare function kurtosis(values: Iterable<number>): number;
16
- export declare function bigKurtosis(bignum: BigNumFactory, values: Iterable<BigNum>): BigNum;
17
- export declare function skewness(values: Iterable<number>): number;
18
- export declare function bigSkewness(bignum: BigNumFactory, values: Iterable<BigNum>): BigNum;
19
- export declare function mode(values: Iterable<number>): number;
20
- export declare function bigMode(bignum: BigNumFactory, values: Iterable<BigNum>): BigNum;
21
- export declare function quartiles(values: Iterable<number>): [number, number, number];
22
- export declare function bigQuartiles(values: Iterable<BigNum>): [BigNum, BigNum, BigNum];
23
- export declare function interquartileRange(values: Iterable<number>): number;
24
- export declare function bigInterquartileRange(values: Iterable<BigNum>): BigNum;
@@ -1,2 +0,0 @@
1
- /* 0.31.0 */
2
- export declare function numberToString(num: number | bigint, fractionalDigits?: number | string): string;
@@ -1,30 +0,0 @@
1
- /* 0.31.0 */
2
- type IsInteger<N extends number> = `${N}` extends `${string}.${string}` ? never : `${N}` extends `-${string}.${string}` ? never : number;
3
- /** A `SmallInteger` is an integer < 1e6
4
- * @category Numerics
5
- */
6
- export type SmallInteger = IsInteger<number>;
7
- /**
8
- * A rational number is a number that can be expressed as the quotient or fraction p/q of two integers,
9
- * a numerator p and a non-zero denominator q.
10
- *
11
- * A rational can either be represented as a pair of small integers or
12
- * a pair of big integers.
13
- *
14
- * @category Numerics
15
- */
16
- export type Rational = [SmallInteger, SmallInteger] | [bigint, bigint];
17
- /** @category Numerics */
18
- export type BigNum = Decimal;
19
- /** @category Numerics */
20
- export interface IBigNum {
21
- readonly _BIGNUM_NAN: BigNum;
22
- readonly _BIGNUM_ZERO: BigNum;
23
- readonly _BIGNUM_ONE: BigNum;
24
- readonly _BIGNUM_TWO: BigNum;
25
- readonly _BIGNUM_HALF: BigNum;
26
- readonly _BIGNUM_PI: BigNum;
27
- readonly _BIGNUM_NEGATIVE_ONE: BigNum;
28
- bignum(value: string | number | bigint | BigNum): BigNum;
29
- }
30
- export {};
@@ -1,3 +0,0 @@
1
- /* 0.31.0 */
2
- /** Calculate the antiderivative of fn, as an expression (not a function) */
3
- export declare function antiderivative(fn: BoxedExpression, index: string): BoxedExpression;
@@ -1,18 +0,0 @@
1
- /* 0.31.0 */
2
- /**
3
- *
4
- * @param fn The function to differentiate, a function literal.
5
- *
6
- * @returns a function expression representing the derivative of `fn` with
7
- * respect to the variables in `degrees`.
8
- */
9
- export declare function derivative(fn: BoxedExpression, order: number): BoxedExpression | undefined;
10
- /**
11
- * Calculate the partial derivative of an expression with respect to a
12
- * variable, `v`.
13
- *
14
- * All expressions that do not explicitly depend on `v` are taken to have zero
15
- * partial derivative.
16
- *
17
- */
18
- export declare function differentiate(expr: BoxedExpression, v: string): BoxedExpression | undefined;
@@ -1,5 +0,0 @@
1
- /* 0.31.0 */
2
- /**
3
- *
4
- */
5
- export declare function distribute(expr: BoxedExpression, g?: string, f?: string): BoxedExpression;
@@ -1,27 +0,0 @@
1
- /* 0.31.0 */
2
- /**
3
- * @todo: a set to "tidy" an expression. Different from a canonical form, but
4
- * inline with the user's expectations.
5
- *
6
- * Example:
7
- *
8
- * - a^n * a^m -> a^(n+m)
9
- * - a / √b -> (a * √b) / b
10
- *
11
- */
12
- /**
13
- * A set of simplification rules.
14
- *
15
- * The rules are expressed as
16
- *
17
- * `[lhs, rhs, condition]`
18
- *
19
- * where `lhs` is rewritten as `rhs` if `condition` is true.
20
- *
21
- * `lhs` and `rhs` can be either an Expression or a LaTeX string.
22
- *
23
- * If using an Expression, the expression is *not* canonicalized before being
24
- * used. Therefore in some cases using Expression, while more verbose,
25
- * may be necessary as the expression could be simplified by the canonicalization.
26
- */
27
- export declare const SIMPLIFY_RULES: Rule[];
@@ -1,128 +0,0 @@
1
- /* 0.31.0 */
2
- import { BoxedExpression, ComputeEngine, DataTypeMap, TensorDataType, TensorField } from '../global-types';
3
- /** @category Tensors */
4
- export declare function makeTensorField<DT extends keyof DataTypeMap>(ce: ComputeEngine, dtype: DT): TensorField<DataTypeMap[DT]>;
5
- /** @category Tensors */
6
- export declare class TensorFieldNumber implements TensorField<number> {
7
- private ce;
8
- one: number;
9
- zero: number;
10
- nan: number;
11
- constructor(ce: ComputeEngine);
12
- cast(x: number, dtype: 'float64'): undefined | number;
13
- cast(x: number, dtype: 'float32'): undefined | number;
14
- cast(x: number, dtype: 'int32'): undefined | number;
15
- cast(x: number, dtype: 'uint8'): undefined | number;
16
- cast(x: number, dtype: 'complex128'): undefined | Complex;
17
- cast(x: number, dtype: 'complex64'): undefined | Complex;
18
- cast(x: number, dtype: 'bool'): undefined | boolean;
19
- cast(x: number, dtype: 'expression'): undefined | BoxedExpression;
20
- cast(x: number[], dtype: 'float64'): undefined | number[];
21
- cast(x: number[], dtype: 'float32'): undefined | number[];
22
- cast(x: number[], dtype: 'int32'): undefined | number[];
23
- cast(x: number[], dtype: 'uint8'): undefined | number[];
24
- cast(x: number[], dtype: 'complex128'): undefined | Complex[];
25
- cast(x: number[], dtype: 'complex64'): undefined | Complex[];
26
- cast(x: number[], dtype: 'bool'): undefined | boolean[];
27
- cast(x: number[], dtype: 'expression'): undefined | BoxedExpression[];
28
- expression(x: number): BoxedExpression;
29
- isZero(x: number): boolean;
30
- isOne(x: number): boolean;
31
- equals(lhs: number, rhs: number): boolean;
32
- add(lhs: number, rhs: number): number;
33
- addn(...xs: number[]): number;
34
- neg(x: number): number;
35
- sub(lhs: number, rhs: number): number;
36
- mul(lhs: number, rhs: number): number;
37
- muln(...xs: number[]): number;
38
- div(lhs: number, rhs: number): number;
39
- pow(lhs: number, rhs: number): number;
40
- conjugate(x: number): number;
41
- }
42
- /** @category Tensors */
43
- export declare class TensorFieldExpression implements TensorField<BoxedExpression> {
44
- one: BoxedExpression;
45
- zero: BoxedExpression;
46
- nan: BoxedExpression;
47
- private ce;
48
- constructor(ce: ComputeEngine);
49
- cast(x: BoxedExpression, dtype: 'float64'): undefined | number;
50
- cast(x: BoxedExpression, dtype: 'float32'): undefined | number;
51
- cast(x: BoxedExpression, dtype: 'int32'): undefined | number;
52
- cast(x: BoxedExpression, dtype: 'uint8'): undefined | number;
53
- cast(x: BoxedExpression, dtype: 'complex128'): undefined | Complex;
54
- cast(x: BoxedExpression, dtype: 'complex64'): undefined | Complex;
55
- cast(x: BoxedExpression, dtype: 'bool'): undefined | boolean;
56
- cast(x: BoxedExpression, dtype: 'expression'): undefined | BoxedExpression;
57
- cast(x: BoxedExpression[], dtype: 'float64'): undefined | number[];
58
- cast(x: BoxedExpression[], dtype: 'float32'): undefined | number[];
59
- cast(x: BoxedExpression[], dtype: 'int32'): undefined | number[];
60
- cast(x: BoxedExpression[], dtype: 'uint8'): undefined | number[];
61
- cast(x: BoxedExpression[], dtype: 'complex128'): undefined | Complex[];
62
- cast(x: BoxedExpression[], dtype: 'complex64'): undefined | Complex[];
63
- cast(x: BoxedExpression[], dtype: 'bool'): undefined | boolean[];
64
- cast(x: BoxedExpression[], dtype: 'expression'): undefined | BoxedExpression[];
65
- expression(x: BoxedExpression): BoxedExpression;
66
- isZero(x: BoxedExpression): boolean;
67
- isOne(x: BoxedExpression): boolean;
68
- equals(lhs: BoxedExpression, rhs: BoxedExpression): boolean;
69
- add(lhs: BoxedExpression, rhs: BoxedExpression): BoxedExpression;
70
- addn(...xs: BoxedExpression[]): BoxedExpression;
71
- neg(x: BoxedExpression): BoxedExpression;
72
- sub(lhs: BoxedExpression, rhs: BoxedExpression): BoxedExpression;
73
- mul(lhs: BoxedExpression, rhs: BoxedExpression): BoxedExpression;
74
- muln(...xs: BoxedExpression[]): BoxedExpression;
75
- div(lhs: BoxedExpression, rhs: BoxedExpression): BoxedExpression;
76
- pow(lhs: BoxedExpression, rhs: number): BoxedExpression;
77
- conjugate(x: BoxedExpression): BoxedExpression;
78
- }
79
- /** @category Tensors */
80
- export declare class TensorFieldComplex implements TensorField<Complex> {
81
- one: Complex;
82
- zero: Complex;
83
- nan: Complex;
84
- private ce;
85
- constructor(ce: ComputeEngine);
86
- cast(x: Complex, dtype: 'float64'): undefined | number;
87
- cast(x: Complex, dtype: 'float32'): undefined | number;
88
- cast(x: Complex, dtype: 'int32'): undefined | number;
89
- cast(x: Complex, dtype: 'uint8'): undefined | number;
90
- cast(x: Complex, dtype: 'complex128'): undefined | Complex;
91
- cast(x: Complex, dtype: 'complex64'): undefined | Complex;
92
- cast(x: Complex, dtype: 'bool'): undefined | boolean;
93
- cast(x: Complex, dtype: 'expression'): undefined | BoxedExpression;
94
- cast(x: Complex[], dtype: 'float64'): undefined | number[];
95
- cast(x: Complex[], dtype: 'float32'): undefined | number[];
96
- cast(x: Complex[], dtype: 'int32'): undefined | number[];
97
- cast(x: Complex[], dtype: 'uint8'): undefined | number[];
98
- cast(x: Complex[], dtype: 'complex128'): undefined | Complex[];
99
- cast(x: Complex[], dtype: 'complex64'): undefined | Complex[];
100
- cast(x: Complex[], dtype: 'bool'): undefined | boolean[];
101
- cast(x: Complex[], dtype: 'expression'): undefined | BoxedExpression[];
102
- expression(z: Complex): BoxedExpression;
103
- isZero(z: Complex): boolean;
104
- isOne(z: Complex): boolean;
105
- equals(lhs: Complex, rhs: Complex): boolean;
106
- add(lhs: Complex, rhs: Complex): Complex;
107
- addn(...xs: Complex[]): Complex;
108
- neg(z: Complex): Complex;
109
- sub(lhs: Complex, rhs: Complex): Complex;
110
- mul(lhs: Complex, rhs: Complex): Complex;
111
- muln(...xs: Complex[]): Complex;
112
- div(lhs: Complex, rhs: Complex): Complex;
113
- pow(lhs: Complex, rhs: number): Complex;
114
- conjugate(z: Complex): Complex;
115
- }
116
- /**
117
- * @category Tensors
118
- * @internal
119
- */
120
- export declare function getSupertype(t1: TensorDataType | undefined, t2: TensorDataType): TensorDataType;
121
- /**
122
- * If the expression is a literal number, return the datatype of the
123
- * number (or boolean). Otherwise, return the `expression`.
124
- *
125
- * @category Tensors
126
- * @internal
127
- */
128
- export declare function getExpressionDatatype(expr: BoxedExpression): TensorDataType;
@@ -1,93 +0,0 @@
1
- /* 0.31.0 */
2
- /** @category Tensors */
3
- export declare abstract class AbstractTensor<DT extends keyof DataTypeMap> implements Tensor<DT> {
4
- private ce;
5
- /**
6
- * Return a tuple of tensors that have the same dtype.
7
- * If necessary, one of the two input tensors is upcast.
8
- *
9
- * The shape of the tensors is reshaped to a compatible
10
- * shape. If the shape is not compatible, `undefined` is returned.
11
- *
12
- * @param lhs
13
- * @param rhs
14
- */
15
- static align<T1 extends TensorDataType, T2 extends TensorDataType>(lhs: AbstractTensor<T1>, rhs: AbstractTensor<T2>): [AbstractTensor<T1>, AbstractTensor<T1>];
16
- static align<T1 extends TensorDataType, T2 extends TensorDataType>(lhs: AbstractTensor<T1>, rhs: AbstractTensor<T2>): [AbstractTensor<T2>, AbstractTensor<T2>];
17
- /**
18
- * Apply a function to the elements of two tensors, or to a tensor
19
- * and a scalar.
20
- *
21
- * The tensors are aligned and broadcasted if necessary.
22
- *
23
- * @param fn
24
- * @param lhs
25
- * @param rhs
26
- * @returns
27
- */
28
- static broadcast<T extends TensorDataType>(fn: (lhs: DataTypeMap[T], rhs: DataTypeMap[T]) => DataTypeMap[T], lhs: AbstractTensor<T>, rhs: AbstractTensor<T> | DataTypeMap[T]): AbstractTensor<T>;
29
- readonly field: TensorField<DataTypeMap[DT]>;
30
- readonly shape: number[];
31
- readonly rank: number;
32
- private readonly _strides;
33
- constructor(ce: ComputeEngine, tensorData: TensorData<DT>);
34
- abstract get dtype(): DT;
35
- abstract get data(): DataTypeMap[DT][];
36
- get expression(): BoxedExpression;
37
- /**
38
- * Like expression(), but return a nested JS array instead
39
- * of a BoxedExpression
40
- */
41
- get array(): NestedArray<DataTypeMap[DT]>;
42
- /** Indices are 1-based, return a 0-based index in the data */
43
- private _index;
44
- get isSquare(): boolean;
45
- get isSymmetric(): boolean;
46
- get isSkewSymmetric(): boolean;
47
- get isUpperTriangular(): boolean;
48
- get isLowerTriangular(): boolean;
49
- get isTriangular(): boolean;
50
- get isDiagonal(): boolean;
51
- get isIdentity(): boolean;
52
- get isZero(): boolean;
53
- /**
54
- * The number of indices should match the rank of the tensor.
55
- *
56
- * Note: the indices are 1-based
57
- * Note: the data is broadcast (wraps around) if the indices are out of bounds
58
- *
59
- * LaTeX notation `A\lbracki, j\rbrack` or `A_{i, j}`
60
- */
61
- at(...indices: number[]): DataTypeMap[DT];
62
- diagonal(axis1?: number, axis2?: number): undefined | DataTypeMap[DT][];
63
- trace(axis1?: number, axis2?: number): undefined | DataTypeMap[DT];
64
- /**
65
- * Change the shape of the tensor
66
- *
67
- * The data is reused (and shared) between the two tensors.
68
- */
69
- reshape(...shape: number[]): AbstractTensor<DT>;
70
- slice(index: number): AbstractTensor<DT>;
71
- flatten(): DataTypeMap[DT][];
72
- upcast<DT extends keyof DataTypeMap>(dtype: DT): AbstractTensor<DT>;
73
- /** Transpose the first and second axis */
74
- transpose(): undefined | AbstractTensor<DT>;
75
- /** Transpose two axes. */
76
- transpose(axis1: number, axis2: number, fn?: (v: DataTypeMap[DT]) => DataTypeMap[DT]): undefined | AbstractTensor<DT>;
77
- conjugateTranspose(axis1: number, axis2: number): undefined | AbstractTensor<DT>;
78
- determinant(): undefined | DataTypeMap[DT];
79
- inverse(): undefined | AbstractTensor<DT>;
80
- pseudoInverse(): undefined | AbstractTensor<DT>;
81
- adjugateMatrix(): undefined | AbstractTensor<DT>;
82
- minor(i: number, j: number): undefined | DataTypeMap[DT];
83
- map1(fn: (lhs: DataTypeMap[DT], rhs: DataTypeMap[DT]) => DataTypeMap[DT], scalar: DataTypeMap[DT]): AbstractTensor<DT>;
84
- map2(fn: (lhs: DataTypeMap[DT], rhs: DataTypeMap[DT]) => DataTypeMap[DT], rhs: AbstractTensor<DT>): AbstractTensor<DT>;
85
- add(rhs: AbstractTensor<DT> | DataTypeMap[DT]): AbstractTensor<DT>;
86
- subtract(rhs: AbstractTensor<DT> | DataTypeMap[DT]): AbstractTensor<DT>;
87
- multiply(rhs: AbstractTensor<DT> | DataTypeMap[DT]): AbstractTensor<DT>;
88
- divide(rhs: AbstractTensor<DT> | DataTypeMap[DT]): AbstractTensor<DT>;
89
- power(rhs: AbstractTensor<DT> | DataTypeMap[DT]): AbstractTensor<DT>;
90
- equals(rhs: AbstractTensor<DT>): boolean;
91
- }
92
- /** @category Tensors */
93
- export declare function makeTensor<T extends TensorDataType>(ce: ComputeEngine, data: TensorData<T>): AbstractTensor<T>;
@@ -1,8 +0,0 @@
1
- /* 0.31.0 */
2
- export * from '../math-json/types';
3
- export * from '../common/type/boxed-type';
4
- export * from '../common/type/types';
5
- export type * from './latex-syntax/types';
6
- export * from './numerics/types';
7
- export * from './numeric-value/types';
8
- export * from './global-types';
@@ -1,3 +0,0 @@
1
- /* 0.31.0 */
2
- export { ComputeEngine } from './compute-engine/index';
3
- export * from './compute-engine/types';
@@ -1,11 +0,0 @@
1
- /* 0.31.0 */
2
- * Return true if the string is a valid symbol.
3
- *
4
- * Check for symbols matching a profile of [Unicode UAX31](https://unicode.org/reports/tr31/)
5
- *
6
- * See https://cortexjs.io/math-json/#symbols for a full definition of the
7
- * profile.
8
- */
9
- export declare function isValidSymbol(s: string): boolean;
10
- export declare const EMOJIS: RegExp;
11
- export declare function validateSymbol(s: unknown): 'valid' | 'not-a-string' | 'empty-string' | 'expected-nfc' | 'unexpected-mixed-emoji' | 'unexpected-bidi-marker' | 'unexpected-script' | 'invalid-first-char' | 'invalid-char';
@@ -1,122 +0,0 @@
1
- /* 0.31.0 */
2
- * The following properties can be added to any MathJSON expression
3
- * to provide additional information about the expression.
4
- *
5
- * @category MathJSON */
6
- export type MathJsonAttributes = {
7
- /** A human readable string to annotate this expression, since JSON does not
8
- * allow comments in its encoding */
9
- comment?: string;
10
- /** A Markdown-encoded string providing documentation about this expression.
11
- */
12
- documentation?: string;
13
- /** A visual representation of this expression as a LaTeX string.
14
- *
15
- * This can be useful to preserve non-semantic details, for example
16
- * parentheses in an expression or styling attributes.
17
- */
18
- latex?: string;
19
- /**
20
- * A short string referencing an entry in a wikibase.
21
- *
22
- * For example:
23
- *
24
- * `"Q167"` is the [wikidata entry](https://www.wikidata.org/wiki/Q167)
25
- * for the `Pi` constant.
26
- */
27
- wikidata?: string;
28
- /** A base URL for the `wikidata` key.
29
- *
30
- * A full URL can be produced by concatenating this key with the `wikidata`
31
- * key. This key applies to this node and all its children.
32
- *
33
- * The default value is "https://www.wikidata.org/wiki/"
34
- */
35
- wikibase?: string;
36
- /** A short string indicating an entry in an OpenMath Content Dictionary.
37
- *
38
- * For example: `arith1/#abs`.
39
- *
40
- */
41
- openmathSymbol?: string;
42
- /** A base URL for an OpenMath content dictionary. This key applies to this
43
- * node and all its children.
44
- *
45
- * The default value is "http://www.openmath.org/cd".
46
- */
47
- openmathCd?: string;
48
- /** A URL to the source code from which this expression was generated.
49
- */
50
- sourceUrl?: string;
51
- /** The source code from which this expression was generated.
52
- *
53
- * It could be a LaTeX expression, or some other source language.
54
- */
55
- sourceContent?: string;
56
- /**
57
- * A character offset in `sourceContent` or `sourceUrl` from which this
58
- * expression was generated.
59
- */
60
- sourceOffsets?: [start: number, end: number];
61
- };
62
- /** @category MathJSON */
63
- export type MathJsonSymbol = string;
64
- /**
65
- * A MathJSON numeric quantity.
66
- *
67
- * The `num` string is made of:
68
- * - an optional `-` minus sign
69
- * - a string of decimal digits
70
- * - an optional fraction part (a `.` decimal marker followed by decimal digits)
71
- * - an optional repeating decimal pattern: a string of digits enclosed in
72
- * parentheses
73
- * - an optional exponent part (a `e` or `E` exponent marker followed by an
74
- * optional `-` minus sign, followed by a string of digits)
75
- *
76
- * It can also consist of the string `NaN`, `-Infinity` or `+Infinity` to
77
- * represent these respective values.
78
- *
79
- * A MathJSON number may contain more digits or an exponent with a greater
80
- * range than can be represented in an IEEE 64-bit floating-point.
81
- *
82
- * For example:
83
- * - `-12.34`
84
- * - `0.234e-56`
85
- * - `1.(3)`
86
- * - `123456789123456789.123(4567)e999`
87
- * @category MathJSON
88
- */
89
- export type MathJsonNumberObject = {
90
- num: 'NaN' | '-Infinity' | '+Infinity' | string;
91
- } & MathJsonAttributes;
92
- /** @category MathJSON */
93
- export type MathJsonSymbolObject = {
94
- sym: MathJsonSymbol;
95
- } & MathJsonAttributes;
96
- /** @category MathJSON */
97
- export type MathJsonStringObject = {
98
- str: string;
99
- } & MathJsonAttributes;
100
- /** @category MathJSON */
101
- export type MathJsonFunctionObject = {
102
- fn: [MathJsonSymbol, ...Expression[]];
103
- } & MathJsonAttributes;
104
- /** @category MathJSON */
105
- export type DictionaryValue = boolean | number | string | ExpressionObject | ReadonlyArray<DictionaryValue>;
106
- /** @category MathJSON */
107
- export type MathJsonDictionaryObject = {
108
- dict: Record<string, DictionaryValue>;
109
- } & MathJsonAttributes;
110
- /**
111
- * @category MathJSON
112
- */
113
- export type ExpressionObject = MathJsonNumberObject | MathJsonStringObject | MathJsonSymbolObject | MathJsonFunctionObject | MathJsonDictionaryObject;
114
- /**
115
- * A MathJSON expression is a recursive data structure.
116
- *
117
- * The leaf nodes of an expression are numbers, strings and symbols.
118
- * The dictionary and function nodes can contain expressions themselves.
119
- *
120
- * @category MathJSON
121
- */
122
- export type Expression = ExpressionObject | number | MathJsonSymbol | string | readonly [MathJsonSymbol, ...Expression[]];