@cortex-js/compute-engine 0.24.1 → 0.25.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.
- package/dist/compute-engine.esm.js +25400 -24799
- package/dist/compute-engine.js +25401 -24800
- package/dist/compute-engine.min.esm.js +13 -13
- package/dist/compute-engine.min.js +13 -13
- package/dist/math-json.esm.js +6 -3
- package/dist/math-json.js +6 -3
- package/dist/math-json.min.esm.js +6 -3
- package/dist/math-json.min.js +2 -2
- package/dist/types/common/ansi-codes.d.ts +1 -1
- package/dist/types/common/grapheme-splitter.d.ts +1 -1
- package/dist/types/common/signals.d.ts +1 -1
- package/dist/types/common/utils.d.ts +1 -1
- package/dist/types/compute-engine/assume.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +30 -19
- package/dist/types/compute-engine/boxed-expression/box.d.ts +9 -9
- package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +4 -4
- package/dist/types/compute-engine/boxed-expression/boxed-domain.d.ts +3 -2
- package/dist/types/compute-engine/boxed-expression/boxed-function-definition.d.ts +2 -1
- package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +9 -10
- package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +5 -4
- package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +2 -15
- package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +3 -4
- package/dist/types/compute-engine/boxed-expression/boxed-symbol-definition.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +7 -8
- package/dist/types/compute-engine/boxed-expression/boxed-tensor.d.ts +6 -7
- package/dist/types/compute-engine/boxed-expression/canonical.d.ts +2 -2
- package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/factor.d.ts +11 -0
- package/dist/types/compute-engine/boxed-expression/match.d.ts +14 -0
- package/dist/types/compute-engine/boxed-expression/numerics.d.ts +41 -0
- package/dist/types/compute-engine/boxed-expression/order.d.ts +6 -6
- package/dist/types/compute-engine/boxed-expression/public.d.ts +1964 -0
- package/dist/types/compute-engine/boxed-expression/serialize.d.ts +3 -15
- package/dist/types/compute-engine/boxed-expression/utils.d.ts +5 -2
- package/dist/types/compute-engine/boxed-expression/validate.d.ts +7 -6
- package/dist/types/compute-engine/collection-utils.d.ts +1 -1
- package/dist/types/compute-engine/compile.d.ts +2 -2
- package/dist/types/compute-engine/compute-engine.d.ts +83 -60
- package/dist/types/compute-engine/cost-function.d.ts +1 -1
- package/dist/types/compute-engine/domain-utils.d.ts +3 -2
- package/dist/types/compute-engine/function-utils.d.ts +2 -2
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-complex.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-linear-algebra.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-relational-operators.d.ts +1 -3
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-statistics.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +5 -4
- package/dist/types/compute-engine/latex-syntax/parse-identifier.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/parse.d.ts +71 -29
- package/dist/types/compute-engine/latex-syntax/public.d.ts +264 -252
- package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +9 -3
- package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/serializer.d.ts +6 -11
- package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +3 -2
- package/dist/types/compute-engine/library/arithmetic-add.d.ts +5 -5
- package/dist/types/compute-engine/library/arithmetic-divide.d.ts +2 -1
- package/dist/types/compute-engine/library/arithmetic-multiply.d.ts +4 -4
- package/dist/types/compute-engine/library/arithmetic-power.d.ts +2 -1
- package/dist/types/compute-engine/library/arithmetic.d.ts +1 -1
- package/dist/types/compute-engine/library/calculus.d.ts +1 -1
- package/dist/types/compute-engine/library/collections.d.ts +1 -1
- package/dist/types/compute-engine/library/complex.d.ts +1 -1
- package/dist/types/compute-engine/library/control-structures.d.ts +1 -1
- package/dist/types/compute-engine/library/core.d.ts +3 -2
- package/dist/types/compute-engine/library/domains.d.ts +1 -1
- package/dist/types/compute-engine/library/library.d.ts +1 -1
- package/dist/types/compute-engine/library/linear-algebra.d.ts +1 -1
- package/dist/types/compute-engine/library/logic.d.ts +1 -1
- package/dist/types/compute-engine/library/polynomials.d.ts +1 -1
- package/dist/types/compute-engine/library/random-expression.d.ts +1 -1
- package/dist/types/compute-engine/library/relational-operator.d.ts +1 -2
- package/dist/types/compute-engine/library/sets.d.ts +1 -1
- package/dist/types/compute-engine/library/statistics.d.ts +1 -1
- package/dist/types/compute-engine/library/trigonometry.d.ts +1 -1
- package/dist/types/compute-engine/library/utils.d.ts +2 -2
- package/dist/types/compute-engine/numerics/numeric-bigint.d.ts +7 -1
- package/dist/types/compute-engine/numerics/numeric-bignum.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric-complex.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric.d.ts +7 -17
- package/dist/types/compute-engine/numerics/primes.d.ts +6 -1
- package/dist/types/compute-engine/numerics/rationals.d.ts +4 -13
- package/dist/types/compute-engine/numerics/richardson.d.ts +1 -1
- package/dist/types/compute-engine/numerics/terms.d.ts +7 -4
- package/dist/types/compute-engine/public.d.ts +3 -1841
- package/dist/types/compute-engine/rules.d.ts +1 -1
- package/dist/types/compute-engine/simplify-rules.d.ts +1 -1
- package/dist/types/compute-engine/solve.d.ts +4 -3
- package/dist/types/compute-engine/symbolic/derivative.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/expand.d.ts +2 -2
- package/dist/types/compute-engine/symbolic/flatten.d.ts +6 -4
- package/dist/types/compute-engine/symbolic/negate.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/polynomials.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/product.d.ts +4 -3
- package/dist/types/compute-engine/symbolic/tensor-fields.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/tensors.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/utils.d.ts +5 -10
- package/dist/types/compute-engine.d.ts +2 -2
- package/dist/types/math-json/math-json-format.d.ts +3 -3
- package/dist/types/math-json/utils.d.ts +4 -6
- package/dist/types/math-json.d.ts +2 -2
- package/package.json +1 -1
- package/dist/types/compute-engine/latex-syntax/latex-syntax.d.ts +0 -28
- package/dist/types/compute-engine/numerics/factor.d.ts +0 -27
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.25.0 */
|
|
2
|
+
import { Rule } from './public';
|
|
2
3
|
export declare const UNIVARIATE_ROOTS: Rule[];
|
|
3
4
|
/**
|
|
4
5
|
* Expression is a function of a single variable (`x`) or an Equality
|
|
@@ -6,7 +7,7 @@ export declare const UNIVARIATE_ROOTS: Rule[];
|
|
|
6
7
|
* Return the roots of that variable
|
|
7
8
|
*
|
|
8
9
|
*/
|
|
9
|
-
export declare function findUnivariateRoots(expr: BoxedExpression, x: string): BoxedExpression
|
|
10
|
+
export declare function findUnivariateRoots(expr: BoxedExpression, x: string): ReadonlyArray<BoxedExpression>;
|
|
10
11
|
/** Expr is an equation with a head of
|
|
11
12
|
* - `Equal`, `Less`, `Greater`, `LessEqual`, `GreaterEqual`
|
|
12
13
|
*
|
|
@@ -14,5 +15,5 @@ export declare function findUnivariateRoots(expr: BoxedExpression, x: string): B
|
|
|
14
15
|
* a variable, if possible:
|
|
15
16
|
* `2x < 4` => `x < 2`
|
|
16
17
|
*/
|
|
17
|
-
export declare function univariateSolve(expr: BoxedExpression, x: string): SemiBoxedExpression
|
|
18
|
+
export declare function univariateSolve(expr: BoxedExpression, x: string): ReadonlyArray<SemiBoxedExpression> | null;
|
|
18
19
|
export declare const HARMONIZATION_RULES: Rule[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/* 0.
|
|
2
|
-
export declare function distribute(expr: BoxedExpression
|
|
1
|
+
/* 0.25.0 */
|
|
2
|
+
export declare function distribute(expr: ReadonlyArray<BoxedExpression>): BoxedExpression;
|
|
3
3
|
/** Use the multinomial theorem (https://en.wikipedia.org/wiki/Multinomial_theorem) to expand the expression.
|
|
4
4
|
* The expression must be a power of a sum of terms.
|
|
5
5
|
* The power must be a positive integer.
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.25.0 */
|
|
2
2
|
/**
|
|
3
3
|
* Flatten the arguments.
|
|
4
4
|
*/
|
|
5
|
-
export declare function flattenOps(ops: BoxedExpression
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
export declare function flattenOps(ops: ReadonlyArray<BoxedExpression>, head: string): ReadonlyArray<BoxedExpression>;
|
|
6
|
+
/**
|
|
7
|
+
* @todo: this function should probably not be recursive. As it, it is semi-recursive.
|
|
8
|
+
*/
|
|
9
|
+
export declare function flattenSequence(xs: ReadonlyArray<BoxedExpression>): ReadonlyArray<BoxedExpression>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.25.0 */
|
|
2
|
+
import { Rational } from '../numerics/rationals';
|
|
2
3
|
/**
|
|
3
4
|
* Group terms in a product by common term.
|
|
4
5
|
*
|
|
@@ -30,7 +31,7 @@ export declare class Product {
|
|
|
30
31
|
private _hasInfinity;
|
|
31
32
|
private _hasZero;
|
|
32
33
|
private _isCanonical;
|
|
33
|
-
constructor(ce: IComputeEngine, xs?: BoxedExpression
|
|
34
|
+
constructor(ce: IComputeEngine, xs?: ReadonlyArray<BoxedExpression>, options?: {
|
|
34
35
|
canonical?: boolean;
|
|
35
36
|
});
|
|
36
37
|
get isEmpty(): boolean;
|
|
@@ -41,7 +42,7 @@ export declare class Product {
|
|
|
41
42
|
* Otherwise, terms and their exponent are tallied.
|
|
42
43
|
*/
|
|
43
44
|
addTerm(term: BoxedExpression): void;
|
|
44
|
-
/** Return all
|
|
45
|
+
/** Return all the terms with an exponent of 1 and
|
|
45
46
|
* the square root of rationals (which technically have an
|
|
46
47
|
* exponent of 1/2, but are considered as degree 1 terms)
|
|
47
48
|
*/
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.25.0 */
|
|
2
2
|
import { Decimal } from 'decimal.js';
|
|
3
|
-
import {
|
|
3
|
+
import { Rational } from '../numerics/rationals';
|
|
4
|
+
import { BoxedExpression, Hold, IComputeEngine, SemiBoxedExpression } from '../public';
|
|
4
5
|
/**
|
|
5
6
|
* Return a rational coef and constant such that `coef * mod + constant = expr`
|
|
6
7
|
*/
|
|
@@ -11,17 +12,11 @@ import { BoxedExpression, Hold, Rational } from '../public';
|
|
|
11
12
|
*
|
|
12
13
|
* Return null if no `coef`/`constant` can be found.
|
|
13
14
|
*/
|
|
14
|
-
/**
|
|
15
|
-
* Apply the operator `op` to the left-hand-side and right-hand-side
|
|
16
|
-
* expression. Applies the associativity rule specified by the definition,
|
|
17
|
-
* i.e. 'op(a, op(b, c))` -> `op(a, b, c)`, etc...
|
|
18
|
-
*
|
|
19
|
-
*/
|
|
20
|
-
export declare function applyAssociativeOperator(op: string, lhs: BoxedExpression, rhs: BoxedExpression, associativity?: 'right' | 'left' | 'non' | 'both'): BoxedExpression;
|
|
21
15
|
export declare function makePositive(expr: BoxedExpression): [sign: number, expr: BoxedExpression];
|
|
22
16
|
export declare function apply(expr: BoxedExpression, fn: (x: number) => number | Complex, bigFn?: (x: Decimal) => Decimal | Complex | number, complexFn?: (x: Complex) => number | Complex): number | Decimal | Complex;
|
|
23
17
|
export declare function applyN(expr: BoxedExpression, fn: (x: number) => number | Complex, bigFn?: (x: Decimal) => Decimal | Complex | number, complexFn?: (x: Complex) => number | Complex): BoxedExpression | undefined;
|
|
24
18
|
export declare function apply2(expr1: BoxedExpression, expr2: BoxedExpression, fn: (x1: number, x2: number) => number | Complex | Rational, bigFn?: (x1: Decimal, x2: Decimal) => Decimal | Complex | Rational | number, complexFn?: (x1: Complex, x2: number | Complex) => Complex | number): number | Decimal | Complex | Rational;
|
|
25
19
|
export declare function apply2N(expr1: BoxedExpression, expr2: BoxedExpression, fn: (x1: number, x2: number) => number | Complex | Rational, bigFn?: (x1: Decimal, x2: Decimal) => Decimal | Complex | number | Rational, complexFn?: (x1: Complex, x2: number | Complex) => Complex | number): BoxedExpression | undefined;
|
|
26
20
|
export declare function shouldHold(skip: Hold, count: number, index: number): boolean;
|
|
27
|
-
export declare function
|
|
21
|
+
export declare function semiCanonical(ce: IComputeEngine, xs: ReadonlyArray<SemiBoxedExpression>): BoxedExpression[];
|
|
22
|
+
export declare function canonical(xs: ReadonlyArray<BoxedExpression>): ReadonlyArray<BoxedExpression>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* 0.
|
|
2
|
-
export declare const version = "0.
|
|
1
|
+
/* 0.25.0 */
|
|
2
|
+
export declare const version = "0.25.0";
|
|
3
3
|
export { ComputeEngine } from './compute-engine/compute-engine';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.25.0 */
|
|
2
2
|
/** @category MathJSON */
|
|
3
3
|
export type Attributes = {
|
|
4
4
|
/** A human readable string to annotate this expression, since JSON does not
|
|
@@ -96,7 +96,7 @@ export type MathJsonString = {
|
|
|
96
96
|
} & Attributes;
|
|
97
97
|
/** @category MathJSON */
|
|
98
98
|
export type MathJsonFunction = {
|
|
99
|
-
fn: [
|
|
99
|
+
fn: [MathJsonIdentifier | MathJsonFunction, ...Expression[]];
|
|
100
100
|
} & Attributes;
|
|
101
101
|
/** @category MathJSON */
|
|
102
102
|
export type MathJsonDictionary = {
|
|
@@ -112,4 +112,4 @@ export type MathJsonDictionary = {
|
|
|
112
112
|
*
|
|
113
113
|
* @category MathJSON
|
|
114
114
|
*/
|
|
115
|
-
export type Expression = number | MathJsonIdentifier | string | MathJsonNumber | MathJsonString | MathJsonSymbol | MathJsonFunction | MathJsonDictionary | [
|
|
115
|
+
export type Expression = number | MathJsonIdentifier | string | MathJsonNumber | MathJsonString | MathJsonSymbol | MathJsonFunction | MathJsonDictionary | [MathJsonIdentifier | MathJsonFunction, ...Expression[]];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.25.0 */
|
|
2
2
|
export declare const MISSING: Expression;
|
|
3
3
|
export declare function isNumberExpression(expr: Expression | null): expr is number | string | MathJsonNumber;
|
|
4
4
|
export declare function isNumberObject(expr: Expression | null): expr is MathJsonNumber;
|
|
@@ -68,12 +68,10 @@ export declare function subs(expr: Expression, s: {
|
|
|
68
68
|
*/
|
|
69
69
|
export declare function mapArgs<T>(expr: Expression, fn: (x: Expression) => T): T[];
|
|
70
70
|
/**
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
* i.e. 'op(a, op(b, c))` -> `op(a, b, c)`, etc...
|
|
74
|
-
*
|
|
71
|
+
* Assuming that op is an associative operator, fold lhs or rhs
|
|
72
|
+
* if either are the same operator.
|
|
75
73
|
*/
|
|
76
|
-
export declare function
|
|
74
|
+
export declare function foldAssociativeOperator(op: string, lhs: Expression, rhs: Expression): Expression;
|
|
77
75
|
/** 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 */
|
|
78
76
|
export declare function getSequence(expr: Expression | null): Expression[] | null;
|
|
79
77
|
export declare function isEmptySequence(expr: Expression | null): boolean;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.25.0 */
|
|
2
2
|
export { isSymbolObject, isStringObject, isFunctionObject, isDictionaryObject, stringValue as getStringValue, head, headName, symbol, applyRecursively, mapArgs, op, nops, dictionary as getDictionary, } from './math-json/utils';
|
|
3
|
-
export declare const version = "0.
|
|
3
|
+
export declare const version = "0.25.0";
|
package/package.json
CHANGED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/* 0.24.1 */
|
|
2
|
-
import { Serializer } from './serializer';
|
|
3
|
-
import { Expression } from '../../math-json/math-json-format';
|
|
4
|
-
import { WarningSignalHandler } from '../../common/signals';
|
|
5
|
-
import { IComputeEngine } from '../public';
|
|
6
|
-
export declare const DEFAULT_SERIALIZE_LATEX_OPTIONS: Required<SerializeLatexOptions>;
|
|
7
|
-
export declare class LatexSyntax {
|
|
8
|
-
onError: WarningSignalHandler;
|
|
9
|
-
readonly options: NumberFormattingOptions & ParseLatexOptions & SerializeLatexOptions;
|
|
10
|
-
readonly computeEngine: IComputeEngine;
|
|
11
|
-
private _dictionary;
|
|
12
|
-
private _dictionaryInput;
|
|
13
|
-
private _serializer?;
|
|
14
|
-
constructor(options: Partial<NumberFormattingOptions> & Partial<ParseLatexOptions> & Partial<SerializeLatexOptions> & {
|
|
15
|
-
computeEngine: IComputeEngine;
|
|
16
|
-
dictionary?: readonly LatexDictionaryEntry[];
|
|
17
|
-
onError?: WarningSignalHandler;
|
|
18
|
-
});
|
|
19
|
-
get dictionary(): readonly LatexDictionaryEntry[];
|
|
20
|
-
set dictionary(val: readonly LatexDictionaryEntry[]);
|
|
21
|
-
updateOptions(opt: Partial<NumberFormattingOptions> & Partial<ParseLatexOptions> & Partial<SerializeLatexOptions>): void;
|
|
22
|
-
static getDictionary(category?: LibraryCategory | 'all'): readonly Readonly<object>[];
|
|
23
|
-
parse(latex: LatexString): Expression;
|
|
24
|
-
serialize(expr: Expression, options?: {
|
|
25
|
-
canonical?: boolean;
|
|
26
|
-
}): LatexString;
|
|
27
|
-
get serializer(): Serializer;
|
|
28
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/* 0.24.1 */
|
|
2
|
-
import Decimal from 'decimal.js';
|
|
3
|
-
import { BoxedExpression, Rational } from '../public';
|
|
4
|
-
/**
|
|
5
|
-
* Attempt to factor a numeric coefficient `c` and a `rest` out of a
|
|
6
|
-
* canonical expression `expr` such that `ce.mul(c, rest)` is equal to `expr`.
|
|
7
|
-
*
|
|
8
|
-
* Attempts to make `rest` a positive value (i.e. pulls out negative sign).
|
|
9
|
-
*
|
|
10
|
-
* The numeric coefficient could be an expression, for example:
|
|
11
|
-
* ['Multiply', 2, ['Sqrt', 5], 'x']
|
|
12
|
-
* -> [['Multiply', 2, ['Sqrt', 5]], 'x']
|
|
13
|
-
*
|
|
14
|
-
* ['Multiply', 2, 'x', 3, 'a']
|
|
15
|
-
* -> [6, ['Multiply', 'x', 'a']]
|
|
16
|
-
*
|
|
17
|
-
* ['Divide', ['Multiply', 2, 'x'], ['Multiply', 3, 'y', 'a']]
|
|
18
|
-
* -> [['Rational', 2, 3], ['Divide', 'x', ['Multiply, 'y', 'a']]]
|
|
19
|
-
*/
|
|
20
|
-
export declare function asCoefficient(expr: BoxedExpression): [coef: Rational, rest: BoxedExpression];
|
|
21
|
-
export declare function applyCoefficient(value: number | Decimal | Complex | Rational | null, coef: Rational): number | Decimal | Complex | Rational | null;
|
|
22
|
-
/** Combine rational expressions into a single fraction */
|
|
23
|
-
export declare function together(op: BoxedExpression): BoxedExpression;
|
|
24
|
-
/**
|
|
25
|
-
* Return a list of expressions that multiply together to form `expr`.
|
|
26
|
-
*/
|
|
27
|
-
export declare function factor(expr: BoxedExpression): BoxedExpression;
|