@latex-math/core 0.1.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/LICENCE +21 -0
- package/dist/ast/index.d.ts +87 -0
- package/dist/calculus/index.d.ts +3 -0
- package/dist/errors/index.d.ts +24 -0
- package/dist/evaluator/index.d.ts +7 -0
- package/dist/index.cjs +1523 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +1470 -0
- package/dist/math/index.d.ts +28 -0
- package/dist/parser/index.d.ts +4 -0
- package/dist/parser/normalizer.d.ts +11 -0
- package/dist/printer/index.d.ts +2 -0
- package/dist/simplifier/index.d.ts +5 -0
- package/dist/tokenizer/index.d.ts +21 -0
- package/package.json +40 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare class Complex {
|
|
2
|
+
re: number;
|
|
3
|
+
im: number;
|
|
4
|
+
constructor(re: number, im: number);
|
|
5
|
+
add(other: Complex | number): Complex;
|
|
6
|
+
sub(other: Complex | number): Complex;
|
|
7
|
+
mul(other: Complex | number): Complex;
|
|
8
|
+
div(other: Complex | number): Complex;
|
|
9
|
+
exp(): Complex;
|
|
10
|
+
ln(): Complex;
|
|
11
|
+
pow(other: Complex | number): Complex;
|
|
12
|
+
}
|
|
13
|
+
export declare class MatrixValue {
|
|
14
|
+
rows: MathValue[][];
|
|
15
|
+
constructor(rows: MathValue[][]);
|
|
16
|
+
add(other: MatrixValue): MatrixValue;
|
|
17
|
+
mul(other: MatrixValue | MathValue): MatrixValue;
|
|
18
|
+
transpose(): MatrixValue;
|
|
19
|
+
det(): MathValue;
|
|
20
|
+
private _det;
|
|
21
|
+
inv(): MatrixValue;
|
|
22
|
+
}
|
|
23
|
+
export type MathValue = number | Complex | MatrixValue;
|
|
24
|
+
export declare function mathAdd(a: MathValue, b: MathValue): MathValue;
|
|
25
|
+
export declare function mathSub(a: MathValue, b: MathValue): MathValue;
|
|
26
|
+
export declare function mathMul(a: MathValue, b: MathValue): MathValue;
|
|
27
|
+
export declare function mathDiv(a: MathValue, b: MathValue): MathValue;
|
|
28
|
+
export declare function mathPow(base: MathValue, exponent: MathValue): MathValue;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalizes LaTeX expressions to make ambiguous or unbraced arguments explicit.
|
|
3
|
+
* In standard TeX macro syntax, commands take single tokens as arguments when braces
|
|
4
|
+
* are omitted. For instance:
|
|
5
|
+
* \sqrt 1+2 -> \sqrt{1} + 2
|
|
6
|
+
* \frac12 -> \frac{1}{2}
|
|
7
|
+
* \frac 1 2 -> \frac{1}{2}
|
|
8
|
+
* \binom42 -> \binom{4}{2}
|
|
9
|
+
* \sqrt[3]8 -> \sqrt[3]{8}
|
|
10
|
+
*/
|
|
11
|
+
export declare function normalizeLatex(input: string): string;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Expression } from '../ast/index.js';
|
|
2
|
+
export declare function simplify(node: Expression): Expression;
|
|
3
|
+
export declare function expand(node: Expression): Expression;
|
|
4
|
+
export declare function factor(node: Expression): Expression;
|
|
5
|
+
export declare function substitute(node: Expression, variables: Record<string, Expression | number>): Expression;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare enum TokenType {
|
|
2
|
+
Number = "Number",
|
|
3
|
+
Identifier = "Identifier",// x, y, a
|
|
4
|
+
Command = "Command",// \cdot, \times, \frac
|
|
5
|
+
Operator = "Operator",// +, -, *, /, =, <, >
|
|
6
|
+
LeftParen = "LeftParen",
|
|
7
|
+
RightParen = "RightParen",
|
|
8
|
+
LeftBrace = "LeftBrace",
|
|
9
|
+
RightBrace = "RightBrace",
|
|
10
|
+
LeftBracket = "LeftBracket",
|
|
11
|
+
RightBracket = "RightBracket",
|
|
12
|
+
Caret = "Caret",
|
|
13
|
+
Underscore = "Underscore",
|
|
14
|
+
EOF = "EOF"
|
|
15
|
+
}
|
|
16
|
+
export interface Token {
|
|
17
|
+
type: TokenType;
|
|
18
|
+
value: string;
|
|
19
|
+
position: number;
|
|
20
|
+
}
|
|
21
|
+
export declare function tokenize(input: string): Token[];
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@latex-math/core",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"require": "./dist/index.cjs",
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "tsup src/index.ts --format cjs,esm && tsc --emitDeclarationOnly",
|
|
18
|
+
"test": "vitest run",
|
|
19
|
+
"test:watch": "vitest"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"tsup": "^8.3.5",
|
|
23
|
+
"typescript": "^5.7.0",
|
|
24
|
+
"vitest": "^2.1.8"
|
|
25
|
+
},
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"dist",
|
|
31
|
+
"README.md",
|
|
32
|
+
"LICENSE"
|
|
33
|
+
],
|
|
34
|
+
"license": "MIT",
|
|
35
|
+
"author": "Sora1123",
|
|
36
|
+
"repository": {
|
|
37
|
+
"type": "git",
|
|
38
|
+
"url": "https://github.com/Sora1123/latex-math.git"
|
|
39
|
+
}
|
|
40
|
+
}
|