@cortex-js/compute-engine 0.32.0 → 0.32.1

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 (153) hide show
  1. package/dist/compute-engine.esm.js +42905 -0
  2. package/dist/compute-engine.min.esm.js +125 -0
  3. package/dist/compute-engine.min.umd.js +127 -0
  4. package/dist/compute-engine.umd.js +42930 -0
  5. package/dist/math-json.esm.js +130 -0
  6. package/dist/math-json.min.esm.js +130 -0
  7. package/dist/math-json.min.umd.js +4 -0
  8. package/dist/math-json.umd.js +155 -0
  9. package/dist/types/common/ansi-codes.d.ts +41 -0
  10. package/dist/types/common/configuration-change.d.ts +28 -0
  11. package/dist/types/common/fuzzy-string-match.d.ts +2 -0
  12. package/dist/types/common/grapheme-splitter.d.ts +15 -0
  13. package/dist/types/common/interruptible.d.ts +20 -0
  14. package/dist/types/common/one-of.d.ts +10 -0
  15. package/dist/types/common/signals.d.ts +96 -0
  16. package/dist/types/common/type/ast-nodes.d.ts +146 -0
  17. package/dist/types/common/type/boxed-type.d.ts +30 -0
  18. package/dist/types/common/type/lexer.d.ts +51 -0
  19. package/dist/types/common/type/parse.d.ts +211 -0
  20. package/dist/types/common/type/parser.d.ts +45 -0
  21. package/dist/types/common/type/primitive.d.ts +10 -0
  22. package/dist/types/common/type/serialize.d.ts +2 -0
  23. package/dist/types/common/type/subtype.d.ts +6 -0
  24. package/dist/types/common/type/type-builder.d.ts +32 -0
  25. package/dist/types/common/type/types.d.ts +300 -0
  26. package/dist/types/common/type/utils.d.ts +36 -0
  27. package/dist/types/common/utils.d.ts +23 -0
  28. package/dist/types/compute-engine/assume.d.ts +26 -0
  29. package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +165 -0
  30. package/dist/types/compute-engine/boxed-expression/apply.d.ts +5 -0
  31. package/dist/types/compute-engine/boxed-expression/arithmetic-add.d.ts +16 -0
  32. package/dist/types/compute-engine/boxed-expression/arithmetic-mul-div.d.ts +27 -0
  33. package/dist/types/compute-engine/boxed-expression/arithmetic-power.d.ts +38 -0
  34. package/dist/types/compute-engine/boxed-expression/ascii-math.d.ts +11 -0
  35. package/dist/types/compute-engine/boxed-expression/box.d.ts +47 -0
  36. package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +44 -0
  37. package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +136 -0
  38. package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +103 -0
  39. package/dist/types/compute-engine/boxed-expression/boxed-operator-definition.d.ts +53 -0
  40. package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +107 -0
  41. package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +27 -0
  42. package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +170 -0
  43. package/dist/types/compute-engine/boxed-expression/boxed-tensor.d.ts +83 -0
  44. package/dist/types/compute-engine/boxed-expression/boxed-value-definition.d.ts +46 -0
  45. package/dist/types/compute-engine/boxed-expression/cache.d.ts +7 -0
  46. package/dist/types/compute-engine/boxed-expression/canonical-utils.d.ts +5 -0
  47. package/dist/types/compute-engine/boxed-expression/canonical.d.ts +2 -0
  48. package/dist/types/compute-engine/boxed-expression/compare.d.ts +13 -0
  49. package/dist/types/compute-engine/boxed-expression/expand.d.ts +20 -0
  50. package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +12 -0
  51. package/dist/types/compute-engine/boxed-expression/factor.d.ts +10 -0
  52. package/dist/types/compute-engine/boxed-expression/flatten.d.ts +25 -0
  53. package/dist/types/compute-engine/boxed-expression/hold.d.ts +10 -0
  54. package/dist/types/compute-engine/boxed-expression/match.d.ts +41 -0
  55. package/dist/types/compute-engine/boxed-expression/negate.d.ts +11 -0
  56. package/dist/types/compute-engine/boxed-expression/numerics.d.ts +34 -0
  57. package/dist/types/compute-engine/boxed-expression/order.d.ts +71 -0
  58. package/dist/types/compute-engine/boxed-expression/polynomials.d.ts +105 -0
  59. package/dist/types/compute-engine/boxed-expression/product.d.ts +66 -0
  60. package/dist/types/compute-engine/boxed-expression/rules.d.ts +129 -0
  61. package/dist/types/compute-engine/boxed-expression/serialize.d.ts +3 -0
  62. package/dist/types/compute-engine/boxed-expression/sgn.d.ts +46 -0
  63. package/dist/types/compute-engine/boxed-expression/simplify.d.ts +6 -0
  64. package/dist/types/compute-engine/boxed-expression/solve.d.ts +20 -0
  65. package/dist/types/compute-engine/boxed-expression/terms.d.ts +10 -0
  66. package/dist/types/compute-engine/boxed-expression/trigonometry.d.ts +9 -0
  67. package/dist/types/compute-engine/boxed-expression/utils.d.ts +64 -0
  68. package/dist/types/compute-engine/boxed-expression/validate.d.ts +58 -0
  69. package/dist/types/compute-engine/collection-utils.d.ts +35 -0
  70. package/dist/types/compute-engine/compilation/base-compiler.d.ts +31 -0
  71. package/dist/types/compute-engine/compilation/javascript-target.d.ts +68 -0
  72. package/dist/types/compute-engine/compilation/types.d.ts +83 -0
  73. package/dist/types/compute-engine/cost-function.d.ts +13 -0
  74. package/dist/types/compute-engine/function-utils.d.ts +120 -0
  75. package/dist/types/compute-engine/global-types.d.ts +2930 -0
  76. package/dist/types/compute-engine/index.d.ts +660 -0
  77. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +2 -0
  78. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +2 -0
  79. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +2 -0
  80. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-complex.d.ts +2 -0
  81. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +27 -0
  82. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-linear-algebra.d.ts +2 -0
  83. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +2 -0
  84. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +2 -0
  85. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-relational-operators.d.ts +2 -0
  86. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +2 -0
  87. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-statistics.d.ts +2 -0
  88. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +3 -0
  89. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +2 -0
  90. package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +88 -0
  91. package/dist/types/compute-engine/latex-syntax/parse-symbol.d.ts +21 -0
  92. package/dist/types/compute-engine/latex-syntax/parse.d.ts +316 -0
  93. package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +29 -0
  94. package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +10 -0
  95. package/dist/types/compute-engine/latex-syntax/serializer.d.ts +37 -0
  96. package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +18 -0
  97. package/dist/types/compute-engine/latex-syntax/types.d.ts +896 -0
  98. package/dist/types/compute-engine/latex-syntax/utils.d.ts +5 -0
  99. package/dist/types/compute-engine/library/arithmetic.d.ts +4 -0
  100. package/dist/types/compute-engine/library/calculus.d.ts +2 -0
  101. package/dist/types/compute-engine/library/collections.d.ts +27 -0
  102. package/dist/types/compute-engine/library/combinatorics.d.ts +2 -0
  103. package/dist/types/compute-engine/library/complex.d.ts +2 -0
  104. package/dist/types/compute-engine/library/control-structures.d.ts +2 -0
  105. package/dist/types/compute-engine/library/core.d.ts +2 -0
  106. package/dist/types/compute-engine/library/invisible-operator.d.ts +4 -0
  107. package/dist/types/compute-engine/library/library.d.ts +17 -0
  108. package/dist/types/compute-engine/library/linear-algebra.d.ts +2 -0
  109. package/dist/types/compute-engine/library/logic-analysis.d.ts +64 -0
  110. package/dist/types/compute-engine/library/logic-utils.d.ts +58 -0
  111. package/dist/types/compute-engine/library/logic.d.ts +7 -0
  112. package/dist/types/compute-engine/library/number-theory.d.ts +2 -0
  113. package/dist/types/compute-engine/library/polynomials.d.ts +2 -0
  114. package/dist/types/compute-engine/library/random-expression.d.ts +2 -0
  115. package/dist/types/compute-engine/library/relational-operator.d.ts +2 -0
  116. package/dist/types/compute-engine/library/sets.d.ts +2 -0
  117. package/dist/types/compute-engine/library/statistics.d.ts +2 -0
  118. package/dist/types/compute-engine/library/trigonometry.d.ts +2 -0
  119. package/dist/types/compute-engine/library/utils.d.ts +77 -0
  120. package/dist/types/compute-engine/numeric-value/big-numeric-value.d.ts +57 -0
  121. package/dist/types/compute-engine/numeric-value/exact-numeric-value.d.ts +75 -0
  122. package/dist/types/compute-engine/numeric-value/machine-numeric-value.d.ts +56 -0
  123. package/dist/types/compute-engine/numeric-value/types.d.ts +116 -0
  124. package/dist/types/compute-engine/numerics/bigint.d.ts +2 -0
  125. package/dist/types/compute-engine/numerics/expression.d.ts +4 -0
  126. package/dist/types/compute-engine/numerics/interval.d.ts +12 -0
  127. package/dist/types/compute-engine/numerics/monte-carlo.d.ts +4 -0
  128. package/dist/types/compute-engine/numerics/numeric-bigint.d.ts +18 -0
  129. package/dist/types/compute-engine/numerics/numeric-bignum.d.ts +9 -0
  130. package/dist/types/compute-engine/numerics/numeric-complex.d.ts +3 -0
  131. package/dist/types/compute-engine/numerics/numeric.d.ts +60 -0
  132. package/dist/types/compute-engine/numerics/primes.d.ts +7 -0
  133. package/dist/types/compute-engine/numerics/rationals.d.ts +43 -0
  134. package/dist/types/compute-engine/numerics/richardson.d.ts +80 -0
  135. package/dist/types/compute-engine/numerics/special-functions.d.ts +28 -0
  136. package/dist/types/compute-engine/numerics/statistics.d.ts +24 -0
  137. package/dist/types/compute-engine/numerics/strings.d.ts +2 -0
  138. package/dist/types/compute-engine/numerics/types.d.ts +30 -0
  139. package/dist/types/compute-engine/symbolic/antiderivative.d.ts +3 -0
  140. package/dist/types/compute-engine/symbolic/derivative.d.ts +18 -0
  141. package/dist/types/compute-engine/symbolic/distribute.d.ts +5 -0
  142. package/dist/types/compute-engine/symbolic/simplify-product.d.ts +6 -0
  143. package/dist/types/compute-engine/symbolic/simplify-rules.d.ts +27 -0
  144. package/dist/types/compute-engine/symbolic/simplify-sum.d.ts +6 -0
  145. package/dist/types/compute-engine/tensor/tensor-fields.d.ts +128 -0
  146. package/dist/types/compute-engine/tensor/tensors.d.ts +93 -0
  147. package/dist/types/compute-engine/types.d.ts +8 -0
  148. package/dist/types/compute-engine.d.ts +3 -0
  149. package/dist/types/math-json/symbols.d.ts +11 -0
  150. package/dist/types/math-json/types.d.ts +122 -0
  151. package/dist/types/math-json/utils.d.ts +87 -0
  152. package/dist/types/math-json.d.ts +3 -0
  153. package/package.json +1 -1
@@ -0,0 +1,122 @@
1
+ /* 0.32.1 */
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[]];
@@ -0,0 +1,87 @@
1
+ /* 0.32.1 */
2
+ export declare const MISSING: Expression;
3
+ export declare function isNumberExpression(expr: Expression | null): expr is number | string | MathJsonNumberObject;
4
+ export declare function isNumberObject(expr: Expression | null): expr is MathJsonNumberObject;
5
+ export declare function isSymbolObject(expr: Expression | null): expr is MathJsonSymbolObject;
6
+ export declare function isStringObject(expr: Expression | null): expr is MathJsonStringObject;
7
+ export declare function isDictionaryObject(expr: Expression | null): expr is MathJsonDictionaryObject;
8
+ export declare function isFunctionObject(expr: Expression | null): expr is MathJsonFunctionObject;
9
+ export declare function isExpressionObject(expr: Expression | null): expr is ExpressionObject;
10
+ /**
11
+ * Returns true if `expr` has at least one recognized metadata property
12
+ * (`latex` or `wikidata`) with a non-undefined value.
13
+ */
14
+ export declare function hasMetaData(expr: Expression | null): expr is ExpressionObject & Partial<MathJsonAttributes>;
15
+ /** If expr is a string literal, return it.
16
+ *
17
+ * A string literal is a JSON string that begins and ends with
18
+ * **U+0027 APOSTROPHE** : **`'`** or an object literal with a `str` key.
19
+ */
20
+ export declare function stringValue(expr: Expression | null | undefined): string | null;
21
+ export declare function stripText(expr: Expression | null | undefined): Expression | null;
22
+ /**
23
+ * The operator of a function is symbol.
24
+ *
25
+ * Return an empty string if the expression is not a function.
26
+ *
27
+ * Examples:
28
+ * * `["Negate", 5]` -> `"Negate"`
29
+ */
30
+ export declare function operator(expr: Expression | null | undefined): MathJsonSymbol;
31
+ /**
32
+ * Return the arguments of a function, or an empty array if not a function
33
+ * or no arguments.
34
+ */
35
+ export declare function operands(expr: Expression | null | undefined): ReadonlyArray<Expression>;
36
+ /** Return the nth operand of a function expression */
37
+ export declare function operand(expr: Expression | null, n: 1 | 2 | 3): Expression | null;
38
+ export declare function nops(expr: Expression | null | undefined): number;
39
+ export declare function unhold(expr: Expression | null): Expression | null;
40
+ export declare function symbol(expr: Expression | null | undefined): string | null;
41
+ export declare function dictionaryFromExpression(expr: Expression | null): null | MathJsonDictionaryObject;
42
+ export declare function dictionaryFromEntries(dict: Record<string, Expression>): Expression;
43
+ /**
44
+ * CAUTION: `machineValue()` will return a truncated value if the number
45
+ * has a precision outside of the machine range.
46
+ */
47
+ export declare function machineValue(expr: Expression | null | undefined): number | null;
48
+ /**
49
+ * Return a rational (numer over denom) representation of the expression,
50
+ * if possible, `null` otherwise.
51
+ *
52
+ * The expression can be:
53
+ * - Some symbols: "Infinity", "Half"...
54
+ * - ["Power", d, -1]
55
+ * - ["Power", n, 1]
56
+ * - ["Divide", n, d]
57
+ *
58
+ * The denominator is always > 0.
59
+ */
60
+ export declare function rationalValue(expr: Expression | undefined | null): [number, number] | null;
61
+ /**
62
+ * Apply a substitution to an expression.
63
+ */
64
+ export declare function subs(expr: Expression, s: {
65
+ [symbol: string]: Expression;
66
+ }): Expression;
67
+ /**
68
+ * Apply a function to the arguments of a function and return an array of T
69
+ */
70
+ export declare function mapArgs<T>(expr: Expression, fn: (x: Expression) => T): T[];
71
+ /**
72
+ * Assuming that op is an associative operator, fold lhs or rhs
73
+ * if either are the same operator.
74
+ */
75
+ export declare function foldAssociativeOperator(op: string, lhs: Expression, rhs: Expression): Expression;
76
+ /** Return the elements of a sequence, or null if the expression is not a sequence. The sequence can be optionally enclosed by a`["Delimiter"]` expression */
77
+ export declare function getSequence(expr: Expression | null | undefined): ReadonlyArray<Expression> | null;
78
+ /** `Nothing` or the empty sequence (`["Sequence"]`) */
79
+ export declare function isEmptySequence(expr: Expression | null | undefined): expr is null | undefined;
80
+ export declare function missingIfEmpty(expr: Expression | null | undefined): Expression;
81
+ /** The number of leaves (atomic expressions) in the expression */
82
+ export declare function countLeaves(expr: Expression | null): number;
83
+ /** True if the string matches the expected pattern for a number */
84
+ export declare function matchesNumber(s: string): boolean;
85
+ /** True if the string matches the expected pattern for a symbol */
86
+ export declare function matchesSymbol(s: string): boolean;
87
+ export declare function matchesString(s: string): boolean;
@@ -0,0 +1,3 @@
1
+ /* 0.32.1 */
2
+ export { isSymbolObject, isStringObject, isFunctionObject, stringValue, operator, operand, symbol, mapArgs, dictionaryFromExpression, } from './math-json/utils';
3
+ export declare const version = "0.32.1";
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.32.0",
2
+ "version": "0.32.1",
3
3
  "scripts": {
4
4
  "doc": "bash ./scripts/doc.sh",
5
5
  "build": "bash ./scripts/build.sh",