pimath 0.0.128 → 0.0.130
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/main.d.ts +39 -0
- package/dist/maths/algebra/equation.d.ts +120 -0
- package/dist/maths/algebra/linearSystem.d.ts +40 -0
- package/dist/maths/algebra/logicalset.d.ts +28 -0
- package/dist/maths/algebra/monom.d.ts +207 -0
- package/dist/maths/algebra/polynom.d.ts +155 -0
- package/dist/maths/algebra/rational.d.ts +44 -0
- package/dist/maths/algebra/study/rationalStudy.d.ts +14 -0
- package/dist/maths/algebra/study.d.ts +140 -0
- package/dist/maths/coefficients/fraction.d.ts +90 -0
- package/dist/maths/coefficients/nthRoot.d.ts +23 -0
- package/dist/maths/geometry/circle.d.ts +46 -0
- package/dist/maths/geometry/line.d.ts +102 -0
- package/dist/maths/geometry/point.d.ts +36 -0
- package/dist/maths/geometry/triangle.d.ts +92 -0
- package/dist/maths/geometry/vector.d.ts +38 -0
- package/dist/maths/numeric.d.ts +28 -0
- package/dist/maths/numexp.d.ts +19 -0
- package/dist/maths/randomization/random.d.ts +26 -0
- package/dist/maths/randomization/randomCore.d.ts +7 -0
- package/dist/maths/randomization/rndFraction.d.ts +13 -0
- package/dist/maths/randomization/rndGeometryCircle.d.ts +13 -0
- package/dist/maths/randomization/rndGeometryLine.d.ts +13 -0
- package/dist/maths/randomization/rndGeometryPoint.d.ts +13 -0
- package/dist/maths/randomization/rndHelpers.d.ts +23 -0
- package/dist/maths/randomization/rndMonom.d.ts +13 -0
- package/dist/maths/randomization/rndPolynom.d.ts +14 -0
- package/dist/maths/randomization/rndTypes.d.ts +40 -0
- package/dist/maths/shutingyard.d.ts +59 -0
- package/dist/pimath.js +85 -85
- package/lib/main.ts +42 -0
- package/{src → lib}/maths/algebra/equation.ts +52 -58
- package/{src → lib}/maths/algebra/linearSystem.ts +5 -6
- package/lib/maths/algebra/logicalset.ts +183 -0
- package/{src → lib}/maths/algebra/monom.ts +7 -8
- package/{src → lib}/maths/algebra/polynom.ts +2 -2
- package/{src → lib}/maths/algebra/study.ts +9 -9
- package/{src → lib}/maths/coefficients/fraction.ts +4 -4
- package/{src → lib}/maths/geometry/circle.ts +6 -9
- package/{src → lib}/maths/geometry/line.ts +1 -1
- package/{src → lib}/maths/geometry/vector.ts +35 -34
- package/{src → lib}/maths/numexp.ts +91 -77
- package/{src → lib}/maths/randomization/rndHelpers.ts +1 -1
- package/{src → lib}/maths/randomization/rndMonom.ts +13 -13
- package/{src → lib}/maths/randomization/rndPolynom.ts +24 -24
- package/package.json +11 -12
- package/.eslintrc.js +0 -24
- package/.idea/$CACHE_FILE$ +0 -6
- package/.idea/PI.iml +0 -14
- package/.idea/codeStyles/codeStyleConfig.xml +0 -5
- package/.idea/inspectionProfiles/Project_Default.xml +0 -6
- package/.idea/jsLibraryMappings.xml +0 -6
- package/.idea/misc.xml +0 -6
- package/.idea/modules.xml +0 -8
- package/.idea/php.xml +0 -19
- package/.idea/shelf/Uncommitted_changes_before_Checkout_at_07_11_2023_08_30_[Default_Changelist]/shelved.patch +0 -192
- package/.idea/shelf/Uncommitted_changes_before_Checkout_at_07_11_2023_08_30_[Default_Changelist]1/shelved.patch +0 -0
- package/.idea/shelf/Uncommitted_changes_before_Checkout_at_07_11_2023_08_30__Default_Changelist_.xml +0 -4
- package/.idea/shelf/Uncommitted_changes_before_Checkout_at_09_11_2023_10_43_[Default_Changelist]/shelved.patch +0 -2404
- package/.idea/shelf/Uncommitted_changes_before_Checkout_at_09_11_2023_10_43__Default_Changelist_.xml +0 -4
- package/.idea/shelf/Uncommitted_changes_before_Checkout_at_09_11_2023_11_01_[Default_Changelist]/shelved.patch +0 -1362
- package/.idea/shelf/Uncommitted_changes_before_Checkout_at_09_11_2023_11_01__Default_Changelist_.xml +0 -4
- package/.idea/shelf/Uncommitted_changes_before_Update_at_24_07_2023_15_31_[Default_Changelist]/shelved.patch +0 -90
- package/.idea/shelf/Uncommitted_changes_before_Update_at_24_07_2023_15_31__Default_Changelist_.xml +0 -4
- package/.idea/vcs.xml +0 -6
- package/dist/demo/exercises.html +0 -283
- package/dist/demo/matrices.html +0 -39
- package/dist/demo/playground.html +0 -20
- package/dist/demo.css +0 -3
- package/dist/pimath.umd.cjs +0 -15
- package/docs/.nojekyll +0 -1
- package/docs/assets/highlight.css +0 -78
- package/docs/assets/main.js +0 -59
- package/docs/assets/navigation.js +0 -1
- package/docs/assets/search.js +0 -1
- package/docs/assets/style.css +0 -1383
- package/docs/classes/Logicalset.Logicalset.html +0 -217
- package/docs/classes/Polynom.Rational.html +0 -397
- package/docs/classes/Vector-1.Vector.html +0 -490
- package/docs/classes/Vector.Point.html +0 -337
- package/docs/classes/algebra_equation.Equation.html +0 -790
- package/docs/classes/algebra_linearSystem.LinearSystem.html +0 -404
- package/docs/classes/algebra_monom.Monom.html +0 -962
- package/docs/classes/algebra_polynom.Polynom.html +0 -1275
- package/docs/classes/coefficients_fraction.Fraction.html +0 -934
- package/docs/classes/geometry_circle.Circle.html +0 -472
- package/docs/classes/geometry_line.Line.html +0 -774
- package/docs/classes/geometry_triangle.Triangle.html +0 -429
- package/docs/classes/numeric.Numeric.html +0 -265
- package/docs/classes/shutingyard.Shutingyard.html +0 -250
- package/docs/enums/algebra_equation.PARTICULAR_SOLUTION.html +0 -83
- package/docs/enums/geometry_line.LinePropriety.html +0 -97
- package/docs/enums/shutingyard.ShutingyardMode.html +0 -97
- package/docs/enums/shutingyard.ShutingyardType.html +0 -111
- package/docs/index.html +0 -63
- package/docs/interfaces/algebra_equation.ISolution.html +0 -105
- package/docs/interfaces/algebra_polynom.IEuclidian.html +0 -87
- package/docs/interfaces/geometry_triangle.remarquableLines.html +0 -163
- package/docs/modules/Logicalset.html +0 -65
- package/docs/modules/Polynom.html +0 -65
- package/docs/modules/Vector-1.html +0 -65
- package/docs/modules/Vector.html +0 -65
- package/docs/modules/algebra_equation.html +0 -69
- package/docs/modules/algebra_linearSystem.html +0 -61
- package/docs/modules/algebra_monom.html +0 -65
- package/docs/modules/algebra_polynom.html +0 -69
- package/docs/modules/coefficients_fraction.html +0 -65
- package/docs/modules/geometry_circle.html +0 -61
- package/docs/modules/geometry_line.html +0 -65
- package/docs/modules/geometry_triangle.html +0 -65
- package/docs/modules/numeric.html +0 -61
- package/docs/modules/shutingyard.html +0 -75
- package/docs/types/algebra_monom.literalType.html +0 -61
- package/docs/types/algebra_polynom.PolynomParsingType.html +0 -56
- package/docs/types/coefficients_fraction.FractionParsingType.html +0 -56
- package/docs/types/shutingyard.Token.html +0 -63
- package/docs/types/shutingyard.tokenType.html +0 -68
- package/docs/variables/shutingyard.tokenConstant.html +0 -61
- package/index.html +0 -15
- package/public/demo/exercises.html +0 -283
- package/public/demo/matrices.html +0 -39
- package/public/demo/playground.html +0 -20
- package/public/demo.css +0 -3
- package/src/demo/exercises.ts +0 -0
- package/src/demo/matrices.ts +0 -61
- package/src/demo/playground.ts +0 -153
- package/src/main.ts +0 -42
- package/src/maths/algebra/logicalset.ts +0 -183
- package/tests/algebra/equation.test.ts +0 -64
- package/tests/algebra/linear.test.ts +0 -58
- package/tests/algebra/monom.test.ts +0 -78
- package/tests/algebra/polynom.test.ts +0 -343
- package/tests/algebra/rationnal.test.ts +0 -64
- package/tests/algebra/study.test.ts +0 -48
- package/tests/coefficients/fraction.test.ts +0 -131
- package/tests/custom.test.ts +0 -33
- package/tests/geometry/circle.test.ts +0 -404
- package/tests/geometry/line.test.ts +0 -36
- package/tests/numeric.test.ts +0 -43
- package/tests/numexp.test.ts +0 -89
- package/tests/shutingyard.test.ts +0 -58
- package/tsconfig.json +0 -52
- package/tsconfig.testing.json +0 -28
- package/typedoc.katex.js +0 -11
- package/vite.config.js +0 -23
- package/webpack-production-min.config.js +0 -26
- package/webpack-production.config.js +0 -26
- package/webpack.config.js +0 -26
- /package/{src → lib}/maths/algebra/rational.ts +0 -0
- /package/{src → lib}/maths/algebra/study/rationalStudy.ts +0 -0
- /package/{src → lib}/maths/coefficients/nthRoot.ts +0 -0
- /package/{src → lib}/maths/geometry/point.ts +0 -0
- /package/{src → lib}/maths/geometry/triangle.ts +0 -0
- /package/{src → lib}/maths/numeric.ts +0 -0
- /package/{src → lib}/maths/randomization/random.ts +0 -0
- /package/{src → lib}/maths/randomization/randomCore.ts +0 -0
- /package/{src → lib}/maths/randomization/rndFraction.ts +0 -0
- /package/{src → lib}/maths/randomization/rndGeometryCircle.ts +0 -0
- /package/{src → lib}/maths/randomization/rndGeometryLine.ts +0 -0
- /package/{src → lib}/maths/randomization/rndGeometryPoint.ts +0 -0
- /package/{src → lib}/maths/randomization/rndTypes.ts +0 -0
- /package/{src → lib}/maths/shutingyard.ts +0 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Line } from '../geometry/line';
|
|
2
|
+
import { randomGeometryLineConfig } from './random';
|
|
3
|
+
import { randomCore } from './randomCore';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Create a random monom based on a based configuration
|
|
7
|
+
*/
|
|
8
|
+
export declare class rndGeometryLine extends randomCore {
|
|
9
|
+
protected _config: randomGeometryLineConfig;
|
|
10
|
+
protected _defaultConfig: randomGeometryLineConfig;
|
|
11
|
+
constructor(userConfig?: randomGeometryLineConfig);
|
|
12
|
+
generate: () => Line;
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Point } from '../geometry/point';
|
|
2
|
+
import { randomGeometryPointConfig } from './random';
|
|
3
|
+
import { randomCore } from './randomCore';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Create a random monom based on a based configuration
|
|
7
|
+
*/
|
|
8
|
+
export declare class rndGeometryPoint extends randomCore {
|
|
9
|
+
protected _config: randomGeometryPointConfig;
|
|
10
|
+
protected _defaultConfig: randomGeometryPointConfig;
|
|
11
|
+
constructor(userConfig?: randomGeometryPointConfig);
|
|
12
|
+
generate: () => Point;
|
|
13
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare class rndHelpers {
|
|
2
|
+
/**
|
|
3
|
+
* Random boolean with a percent ratio
|
|
4
|
+
* @param percent
|
|
5
|
+
*/
|
|
6
|
+
static randomBool(percent?: number): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Random integer between two values.
|
|
9
|
+
* @param a (number) : From this value to the second value. If the second is ommited, this value is the max value.
|
|
10
|
+
* @param b (number) : To this value. If this is ommited.
|
|
11
|
+
*/
|
|
12
|
+
static randomInt(a: number, b?: number, exclude?: number[]): number;
|
|
13
|
+
/**
|
|
14
|
+
* Random integer between -max and max value.
|
|
15
|
+
* @param max (number) : determine the limits.
|
|
16
|
+
* @param zero (bool) : determine if zero is allowed or not.
|
|
17
|
+
*/
|
|
18
|
+
static randomIntSym(max: number, zero?: boolean): number;
|
|
19
|
+
static randomPrime(max: number): number;
|
|
20
|
+
static randomArray(arr: any[], number?: number): any[];
|
|
21
|
+
static randomItem(arr: any[]): any;
|
|
22
|
+
static shuffleArray(arr: any[]): any[];
|
|
23
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Monom } from '../algebra/monom';
|
|
2
|
+
import { randomMonomConfig } from './rndTypes';
|
|
3
|
+
import { randomCore } from './randomCore';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Create a random monom based on a based configuration
|
|
7
|
+
*/
|
|
8
|
+
export declare class rndMonom extends randomCore {
|
|
9
|
+
protected _config: randomMonomConfig;
|
|
10
|
+
protected _defaultConfig: randomMonomConfig;
|
|
11
|
+
generate: () => Monom;
|
|
12
|
+
constructor(userConfig?: randomMonomConfig);
|
|
13
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Polynom } from '../algebra/polynom';
|
|
2
|
+
import { randomPolynomConfig } from './rndTypes';
|
|
3
|
+
import { randomCore } from './randomCore';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Random polynoms
|
|
7
|
+
*/
|
|
8
|
+
export declare class rndPolynom extends randomCore {
|
|
9
|
+
protected _config: randomPolynomConfig;
|
|
10
|
+
protected _defaultConfig: randomPolynomConfig;
|
|
11
|
+
generate: () => Polynom;
|
|
12
|
+
constructor(userConfig?: randomPolynomConfig);
|
|
13
|
+
factorable: () => Polynom;
|
|
14
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Fraction } from '../coefficients/fraction';
|
|
2
|
+
|
|
3
|
+
export type randomCoefficientConfig = {
|
|
4
|
+
negative?: boolean;
|
|
5
|
+
max?: number;
|
|
6
|
+
reduced?: boolean;
|
|
7
|
+
zero?: boolean;
|
|
8
|
+
natural?: boolean;
|
|
9
|
+
};
|
|
10
|
+
export type randomMonomConfig = {
|
|
11
|
+
letters?: string;
|
|
12
|
+
degree?: number;
|
|
13
|
+
fraction?: boolean | randomCoefficientConfig;
|
|
14
|
+
zero?: boolean;
|
|
15
|
+
};
|
|
16
|
+
export type randomPolynomConfig = randomMonomConfig & {
|
|
17
|
+
unit?: boolean;
|
|
18
|
+
factorable?: boolean;
|
|
19
|
+
allowNullMonom?: boolean;
|
|
20
|
+
numberOfMonoms?: number;
|
|
21
|
+
positive?: boolean;
|
|
22
|
+
};
|
|
23
|
+
export type randomGeometryLineConfig = {
|
|
24
|
+
A: {
|
|
25
|
+
x: number | Fraction;
|
|
26
|
+
y: number | Fraction;
|
|
27
|
+
};
|
|
28
|
+
slope?: Fraction | string | number;
|
|
29
|
+
};
|
|
30
|
+
export type randomGeometryPointConfig = {
|
|
31
|
+
quadrant?: number;
|
|
32
|
+
axis?: string | boolean;
|
|
33
|
+
fraction?: boolean;
|
|
34
|
+
max?: number;
|
|
35
|
+
};
|
|
36
|
+
export type randomGeometryCircleConfig = {
|
|
37
|
+
center?: randomGeometryPointConfig;
|
|
38
|
+
radius?: number;
|
|
39
|
+
pointsOnCircle?: number;
|
|
40
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export type tokenType = {
|
|
2
|
+
[key: string]: {
|
|
3
|
+
precedence: number;
|
|
4
|
+
associative: string;
|
|
5
|
+
type: string;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
export declare const tokenConstant: {
|
|
9
|
+
[Key: string]: number;
|
|
10
|
+
};
|
|
11
|
+
export declare enum ShutingyardType {
|
|
12
|
+
VARIABLE = "variable",
|
|
13
|
+
COEFFICIENT = "coefficient",
|
|
14
|
+
OPERATION = "operation",
|
|
15
|
+
CONSTANT = "constant",
|
|
16
|
+
FUNCTION = "function",
|
|
17
|
+
MONOM = "monom"
|
|
18
|
+
}
|
|
19
|
+
export declare enum ShutingyardMode {
|
|
20
|
+
EXPRESSION = "expression",
|
|
21
|
+
POLYNOM = "polynom",
|
|
22
|
+
SET = "set",
|
|
23
|
+
NUMERIC = "numeric"
|
|
24
|
+
}
|
|
25
|
+
export type Token = {
|
|
26
|
+
token: string;
|
|
27
|
+
tokenType: string;
|
|
28
|
+
};
|
|
29
|
+
export declare class Shutingyard {
|
|
30
|
+
readonly _mode: ShutingyardMode;
|
|
31
|
+
private _rpn;
|
|
32
|
+
private _tokenConfig;
|
|
33
|
+
private _tokenConstant;
|
|
34
|
+
private _tokenKeys;
|
|
35
|
+
private _uniformize;
|
|
36
|
+
constructor(mode?: ShutingyardMode);
|
|
37
|
+
get rpn(): Token[];
|
|
38
|
+
get rpnToken(): string[];
|
|
39
|
+
/**
|
|
40
|
+
* Determin if the token is a defined operation
|
|
41
|
+
* Defined operations: + - * / ^ sin cos tan
|
|
42
|
+
* @param token
|
|
43
|
+
*/
|
|
44
|
+
tokenConfigInitialization(): tokenType;
|
|
45
|
+
/**
|
|
46
|
+
* Get the next token to analyse.
|
|
47
|
+
* @param expr (string) Expression to analyse
|
|
48
|
+
* @param start (number) CUrrent position in the expr string.
|
|
49
|
+
*/
|
|
50
|
+
NextToken(expr: string, start: number): [string, number, string];
|
|
51
|
+
normalize(expr: string): string;
|
|
52
|
+
/**
|
|
53
|
+
* Parse an expression using the shutting yard tree algorithms
|
|
54
|
+
* @param expr (string) Expression to analyse
|
|
55
|
+
* Returns a RPN list of items.
|
|
56
|
+
* @param uniformize
|
|
57
|
+
*/
|
|
58
|
+
parse(expr: string, uniformize?: boolean): Shutingyard;
|
|
59
|
+
}
|
package/dist/pimath.js
CHANGED
|
@@ -796,30 +796,6 @@ class K {
|
|
|
796
796
|
get expression() {
|
|
797
797
|
return this._expression;
|
|
798
798
|
}
|
|
799
|
-
_extractDecimalPart(e) {
|
|
800
|
-
let t = e.toString();
|
|
801
|
-
return t.includes(".") ? (t = t.split(".")[1], t.substring(0, t.length - 2)) : "";
|
|
802
|
-
}
|
|
803
|
-
_numberCorrection(e) {
|
|
804
|
-
const s = this._extractDecimalPart(e);
|
|
805
|
-
if (s === "")
|
|
806
|
-
return e;
|
|
807
|
-
const n = s.match(/9+$/g), o = s.match(/0+$/g);
|
|
808
|
-
if (n && n[0].length >= 6) {
|
|
809
|
-
const l = this._extractDecimalPart(e + 1e-14), a = l.match(/0+$/g);
|
|
810
|
-
if (a && a[0].length >= 6)
|
|
811
|
-
return +(e + 1e-14).toString().split(a[0])[0];
|
|
812
|
-
}
|
|
813
|
-
if (o && o[0].length >= 6) {
|
|
814
|
-
const l = this._extractDecimalPart(e - 1e-14), a = l.match(/9+$/g);
|
|
815
|
-
if (a && a[0].length >= 6)
|
|
816
|
-
return +e.toString().split(o[0])[0];
|
|
817
|
-
}
|
|
818
|
-
return e;
|
|
819
|
-
}
|
|
820
|
-
_addToStack(e, t) {
|
|
821
|
-
e.push(this._numberCorrection(t));
|
|
822
|
-
}
|
|
823
799
|
evaluate(e) {
|
|
824
800
|
const t = [];
|
|
825
801
|
if (this._rpn === null)
|
|
@@ -869,6 +845,30 @@ class K {
|
|
|
869
845
|
return t[0];
|
|
870
846
|
throw `There was a problem parsing: ${this._expression}`;
|
|
871
847
|
}
|
|
848
|
+
_extractDecimalPart(e) {
|
|
849
|
+
let t = e.toString();
|
|
850
|
+
return t.includes(".") ? (t = t.split(".")[1], t.substring(0, t.length - 2)) : "";
|
|
851
|
+
}
|
|
852
|
+
_numberCorrection(e) {
|
|
853
|
+
const s = this._extractDecimalPart(e);
|
|
854
|
+
if (s === "")
|
|
855
|
+
return e;
|
|
856
|
+
const n = s.match(/9+$/g), o = s.match(/0+$/g);
|
|
857
|
+
if (n && n[0].length >= 6) {
|
|
858
|
+
const l = this._extractDecimalPart(e + 1e-14), a = l.match(/0+$/g);
|
|
859
|
+
if (a && a[0].length >= 6)
|
|
860
|
+
return +(e + 1e-14).toString().split(a[0])[0];
|
|
861
|
+
}
|
|
862
|
+
if (o && o[0].length >= 6) {
|
|
863
|
+
const l = this._extractDecimalPart(e - 1e-14), a = l.match(/9+$/g);
|
|
864
|
+
if (a && a[0].length >= 6)
|
|
865
|
+
return +e.toString().split(o[0])[0];
|
|
866
|
+
}
|
|
867
|
+
return e;
|
|
868
|
+
}
|
|
869
|
+
_addToStack(e, t) {
|
|
870
|
+
e.push(this._numberCorrection(t));
|
|
871
|
+
}
|
|
872
872
|
}
|
|
873
873
|
class D {
|
|
874
874
|
constructor() {
|
|
@@ -1205,6 +1205,8 @@ const $ = class $ {
|
|
|
1205
1205
|
return this.zero(), e !== void 0 && this.parse(e), this;
|
|
1206
1206
|
}
|
|
1207
1207
|
// ------------------------------------------
|
|
1208
|
+
// Getter and setter
|
|
1209
|
+
// ------------------------------------------
|
|
1208
1210
|
/**
|
|
1209
1211
|
* Get the coefficient \\(k\\) of the Monom \\(k\\cdot x^{n}\\)
|
|
1210
1212
|
* @returns {Fraction}
|
|
@@ -1212,8 +1214,6 @@ const $ = class $ {
|
|
|
1212
1214
|
get coefficient() {
|
|
1213
1215
|
return this._coefficient;
|
|
1214
1216
|
}
|
|
1215
|
-
// ------------------------------------------
|
|
1216
|
-
// Getter and setter
|
|
1217
1217
|
/**
|
|
1218
1218
|
* Set the coefficient \\(k\\) value of the monom
|
|
1219
1219
|
* @param {Fraction | number | string} F
|
|
@@ -1496,16 +1496,17 @@ class k {
|
|
|
1496
1496
|
r(this, "_varnothing", "\\varnothing");
|
|
1497
1497
|
r(this, "_real", "\\mathbb{R}");
|
|
1498
1498
|
r(this, "_left");
|
|
1499
|
+
// Left part of the equation
|
|
1499
1500
|
r(this, "_right");
|
|
1501
|
+
// Right part of the equation
|
|
1500
1502
|
r(this, "_sign");
|
|
1503
|
+
// Signe of the equation, by default =
|
|
1501
1504
|
r(this, "_solutions");
|
|
1502
|
-
r(this, "hasVariable", (e) => this.variables.includes(e));
|
|
1503
|
-
// ------------------------------------------
|
|
1504
|
-
// Creation / parsing functions
|
|
1505
1505
|
// -----------------------------------------------
|
|
1506
1506
|
r(this, "_randomizeDefaults", {
|
|
1507
1507
|
degree: 2
|
|
1508
1508
|
});
|
|
1509
|
+
r(this, "hasVariable", (e) => this.variables.includes(e));
|
|
1509
1510
|
// ------------------------------------------
|
|
1510
1511
|
r(this, "parse", (e) => {
|
|
1511
1512
|
let t, i;
|
|
@@ -1516,9 +1517,9 @@ class k {
|
|
|
1516
1517
|
return t = e.split(i), this.create(new u(t[0]), new u(t[1]), this._formatSign(i));
|
|
1517
1518
|
});
|
|
1518
1519
|
r(this, "create", (e, t, i) => (this._left = e, this._right = t, this._sign = this._formatSign(i), this));
|
|
1519
|
-
r(this, "clone", () => new k().create(this._left.clone(), this._right.clone(), this._sign + ""));
|
|
1520
1520
|
// -----------------------------------------------
|
|
1521
1521
|
// Equations generators and randomizers
|
|
1522
|
+
r(this, "clone", () => new k().create(this._left.clone(), this._right.clone(), this._sign + ""));
|
|
1522
1523
|
r(this, "randomize", (e, t) => new k().create(new u(), new u(), t));
|
|
1523
1524
|
// -----------------------------------------------
|
|
1524
1525
|
/**
|
|
@@ -1529,12 +1530,12 @@ class k {
|
|
|
1529
1530
|
const i = t.clone();
|
|
1530
1531
|
this._left.subtract(i), this._right.subtract(i);
|
|
1531
1532
|
}), this._left.reorder(), this._right.reorder(), this)));
|
|
1533
|
+
// -----------------------------------------------
|
|
1534
|
+
// Equations operations
|
|
1532
1535
|
/**
|
|
1533
1536
|
* Multiply by the lcm denominator and divide by the gcm numerators.
|
|
1534
1537
|
*/
|
|
1535
1538
|
r(this, "simplify", () => (this.multiply(x.lcm(...this._left.getDenominators(), ...this._right.getDenominators())), this.divide(x.gcd(...this._left.getNumerators(), ...this._right.getNumerators())), this));
|
|
1536
|
-
// -----------------------------------------------
|
|
1537
|
-
// Equations operations
|
|
1538
1539
|
/**
|
|
1539
1540
|
* Reorder the polynom to have only one letter on the left, the rest on the right.
|
|
1540
1541
|
* @param letter
|
|
@@ -1585,10 +1586,10 @@ class k {
|
|
|
1585
1586
|
* Determine if the equation contains more than one letter/variable.
|
|
1586
1587
|
*/
|
|
1587
1588
|
r(this, "isMultiVariable", () => this._left.isMultiVariable || this._right.isMultiVariable);
|
|
1588
|
-
r(this, "letters", () => [.../* @__PURE__ */ new Set([...this._left.letters(), ...this._right.letters()])]);
|
|
1589
1589
|
// -----------------------------------------------
|
|
1590
1590
|
// Equations helpers
|
|
1591
1591
|
// -----------------------------------------------
|
|
1592
|
+
r(this, "letters", () => [.../* @__PURE__ */ new Set([...this._left.letters(), ...this._right.letters()])]);
|
|
1592
1593
|
// -----------------------------------------------
|
|
1593
1594
|
r(this, "solve", () => {
|
|
1594
1595
|
switch (this._solutions = [], this._polynom = this._left.clone().subtract(this._right), this._polynom.degree().value) {
|
|
@@ -1781,23 +1782,20 @@ class k {
|
|
|
1781
1782
|
return this;
|
|
1782
1783
|
return this;
|
|
1783
1784
|
}
|
|
1784
|
-
//
|
|
1785
|
+
// ------------------------------------------
|
|
1786
|
+
// Getter and setter
|
|
1785
1787
|
get left() {
|
|
1786
1788
|
return this._left;
|
|
1787
1789
|
}
|
|
1788
1790
|
set left(e) {
|
|
1789
1791
|
this._left = e;
|
|
1790
1792
|
}
|
|
1791
|
-
// Right part of the equation
|
|
1792
1793
|
get right() {
|
|
1793
1794
|
return this._right;
|
|
1794
1795
|
}
|
|
1795
|
-
// ------------------------------------------
|
|
1796
|
-
// Getter and setter
|
|
1797
1796
|
set right(e) {
|
|
1798
1797
|
this._right = e;
|
|
1799
1798
|
}
|
|
1800
|
-
// Signe of the equation, by default =
|
|
1801
1799
|
get sign() {
|
|
1802
1800
|
return this._sign;
|
|
1803
1801
|
}
|
|
@@ -1838,6 +1836,8 @@ class k {
|
|
|
1838
1836
|
get numberOfVars() {
|
|
1839
1837
|
return this.variables.length;
|
|
1840
1838
|
}
|
|
1839
|
+
// ------------------------------------------
|
|
1840
|
+
// Creation / parsing functions
|
|
1841
1841
|
get randomizeDefaults() {
|
|
1842
1842
|
return this._randomizeDefaults;
|
|
1843
1843
|
}
|
|
@@ -2771,9 +2771,6 @@ const O = class O {
|
|
|
2771
2771
|
r(this, "_x");
|
|
2772
2772
|
// 1st component
|
|
2773
2773
|
r(this, "_y");
|
|
2774
|
-
// ------------------------------------------
|
|
2775
|
-
// Creation / parsing functions
|
|
2776
|
-
// ------------------------------------------
|
|
2777
2774
|
r(this, "parse", (...e) => {
|
|
2778
2775
|
if (this.zero(), e.length === 0)
|
|
2779
2776
|
return this;
|
|
@@ -2791,14 +2788,10 @@ const O = class O {
|
|
|
2791
2788
|
return this._x !== null && (e.x = this._x.clone()), this._y !== null && (e.y = this._y.clone()), e;
|
|
2792
2789
|
});
|
|
2793
2790
|
r(this, "reset", () => (this._x = null, this._y = null, this));
|
|
2794
|
-
r(this, "zero", () => (this.reset(), this._x = new h(null), this._y = new h(null), this));
|
|
2795
|
-
r(this, "one", () => (this._x = new h(), this._y = new h(), this));
|
|
2796
|
-
r(this, "_parseString", (e) => {
|
|
2797
|
-
let t = e.split(/[,;\s]/g);
|
|
2798
|
-
return this.x = new h(t[0] || null), this.y = new h(t[1] || null), this;
|
|
2799
|
-
});
|
|
2800
2791
|
// ------------------------------------------
|
|
2801
2792
|
// Mathematical operations
|
|
2793
|
+
r(this, "zero", () => (this.reset(), this._x = new h(null), this._y = new h(null), this));
|
|
2794
|
+
r(this, "one", () => (this._x = new h(), this._y = new h(), this));
|
|
2802
2795
|
// ------------------------------------------
|
|
2803
2796
|
r(this, "opposed", () => (this._x.opposed(), this._y.opposed(), this));
|
|
2804
2797
|
r(this, "add", (e) => (this._x.add(e.x), this._y.add(e.y), this));
|
|
@@ -2816,10 +2809,10 @@ const O = class O {
|
|
|
2816
2809
|
return this._x.multiply(t), this._y.multiply(t), this;
|
|
2817
2810
|
});
|
|
2818
2811
|
r(this, "divideByScalar", (e) => this.multiplyByScalar(new h(e).invert()));
|
|
2812
|
+
r(this, "simplify", () => this.multiplyByScalar(x.lcm(this._x.denominator, this._y.denominator)).divideByScalar(x.gcd(this._x.numerator, this._y.numerator)));
|
|
2819
2813
|
// ------------------------------------------
|
|
2820
2814
|
// Vector functions
|
|
2821
2815
|
// ------------------------------------------
|
|
2822
|
-
r(this, "simplify", () => this.multiplyByScalar(x.lcm(this._x.denominator, this._y.denominator)).divideByScalar(x.gcd(this._x.numerator, this._y.numerator)));
|
|
2823
2816
|
r(this, "simplifyDirection", () => {
|
|
2824
2817
|
let e = x.lcm(this.x.denominator, this.y.denominator), t = x.gcd(this.x.numerator, this.y.numerator);
|
|
2825
2818
|
return this.x.multiply(e).divide(t), this.y.multiply(e).divide(t), this;
|
|
@@ -2828,6 +2821,10 @@ const O = class O {
|
|
|
2828
2821
|
let s = this.scalarProductWithVector(e).value, n = i ? 1 : 180 / Math.PI;
|
|
2829
2822
|
return t && (s = Math.abs(s)), n * Math.acos(s / (this.norm * e.norm));
|
|
2830
2823
|
});
|
|
2824
|
+
r(this, "_parseString", (e) => {
|
|
2825
|
+
let t = e.split(/[,;\s]/g);
|
|
2826
|
+
return this.x = new h(t[0] || null), this.y = new h(t[1] || null), this;
|
|
2827
|
+
});
|
|
2831
2828
|
this._x = new h().zero(), this._y = new h().zero(), e !== void 0 && this.parse(...e);
|
|
2832
2829
|
}
|
|
2833
2830
|
// ------------------------------------------
|
|
@@ -2857,6 +2854,9 @@ const O = class O {
|
|
|
2857
2854
|
get asPoint() {
|
|
2858
2855
|
return new y(this.x, this.y);
|
|
2859
2856
|
}
|
|
2857
|
+
// ------------------------------------------
|
|
2858
|
+
// Creation / parsing functions
|
|
2859
|
+
// ------------------------------------------
|
|
2860
2860
|
get isNull() {
|
|
2861
2861
|
return this.x.isZero() && this.y.isZero();
|
|
2862
2862
|
}
|
|
@@ -4159,6 +4159,43 @@ class fe {
|
|
|
4159
4159
|
get isLogicalset() {
|
|
4160
4160
|
return !0;
|
|
4161
4161
|
}
|
|
4162
|
+
get rpn() {
|
|
4163
|
+
return this._rpn;
|
|
4164
|
+
}
|
|
4165
|
+
get tex() {
|
|
4166
|
+
let e = [];
|
|
4167
|
+
for (let t of this._rpn)
|
|
4168
|
+
if (t.tokenType === "variable")
|
|
4169
|
+
e.push(t);
|
|
4170
|
+
else
|
|
4171
|
+
switch (t.token) {
|
|
4172
|
+
case "&":
|
|
4173
|
+
if (e.length >= 2) {
|
|
4174
|
+
let i = e.pop(), s = e.pop();
|
|
4175
|
+
s.tokenType === "mix" && (s.token = `( ${s.token} )`), i.tokenType === "mix" && (i.token = `( ${i.token} )`), e.push({ token: `${s.token} \\cap ${i.token}`, tokenType: "mix" });
|
|
4176
|
+
}
|
|
4177
|
+
break;
|
|
4178
|
+
case "|":
|
|
4179
|
+
if (e.length >= 2) {
|
|
4180
|
+
let i = e.pop(), s = e.pop();
|
|
4181
|
+
s.tokenType === "mix" && (s.token = `( ${s.token} )`), i.tokenType === "mix" && (i.token = `( ${i.token} )`), e.push({ token: `${s.token} \\cup ${i.token}`, tokenType: "mix" });
|
|
4182
|
+
}
|
|
4183
|
+
break;
|
|
4184
|
+
case "-":
|
|
4185
|
+
if (e.length >= 2) {
|
|
4186
|
+
let i = e.pop(), s = e.pop();
|
|
4187
|
+
s.tokenType === "mix" && (s.token = `( ${s.token} )`), i.tokenType === "mix" && (i.token = `( ${i.token} )`), e.push({ token: `${s.token} \\setminus ${i.token}`, tokenType: "mix" });
|
|
4188
|
+
}
|
|
4189
|
+
break;
|
|
4190
|
+
case "!":
|
|
4191
|
+
if (e.length >= 1) {
|
|
4192
|
+
let i = e.pop();
|
|
4193
|
+
e.push({ token: `\\overline{ ${i.token} }`, tokenType: "variable" });
|
|
4194
|
+
}
|
|
4195
|
+
break;
|
|
4196
|
+
}
|
|
4197
|
+
return e[0].token;
|
|
4198
|
+
}
|
|
4162
4199
|
evaluate(e, t) {
|
|
4163
4200
|
let i = [], s;
|
|
4164
4201
|
if (t === void 0) {
|
|
@@ -4218,43 +4255,6 @@ class fe {
|
|
|
4218
4255
|
["A", "B", "C", "AB", "AC", "BC", "E"]
|
|
4219
4256
|
);
|
|
4220
4257
|
}
|
|
4221
|
-
get rpn() {
|
|
4222
|
-
return this._rpn;
|
|
4223
|
-
}
|
|
4224
|
-
get tex() {
|
|
4225
|
-
let e = [];
|
|
4226
|
-
for (let t of this._rpn)
|
|
4227
|
-
if (t.tokenType === "variable")
|
|
4228
|
-
e.push(t);
|
|
4229
|
-
else
|
|
4230
|
-
switch (t.token) {
|
|
4231
|
-
case "&":
|
|
4232
|
-
if (e.length >= 2) {
|
|
4233
|
-
let i = e.pop(), s = e.pop();
|
|
4234
|
-
s.tokenType === "mix" && (s.token = `( ${s.token} )`), i.tokenType === "mix" && (i.token = `( ${i.token} )`), e.push({ token: `${s.token} \\cap ${i.token}`, tokenType: "mix" });
|
|
4235
|
-
}
|
|
4236
|
-
break;
|
|
4237
|
-
case "|":
|
|
4238
|
-
if (e.length >= 2) {
|
|
4239
|
-
let i = e.pop(), s = e.pop();
|
|
4240
|
-
s.tokenType === "mix" && (s.token = `( ${s.token} )`), i.tokenType === "mix" && (i.token = `( ${i.token} )`), e.push({ token: `${s.token} \\cup ${i.token}`, tokenType: "mix" });
|
|
4241
|
-
}
|
|
4242
|
-
break;
|
|
4243
|
-
case "-":
|
|
4244
|
-
if (e.length >= 2) {
|
|
4245
|
-
let i = e.pop(), s = e.pop();
|
|
4246
|
-
s.tokenType === "mix" && (s.token = `( ${s.token} )`), i.tokenType === "mix" && (i.token = `( ${i.token} )`), e.push({ token: `${s.token} \\setminus ${i.token}`, tokenType: "mix" });
|
|
4247
|
-
}
|
|
4248
|
-
break;
|
|
4249
|
-
case "!":
|
|
4250
|
-
if (e.length >= 1) {
|
|
4251
|
-
let i = e.pop();
|
|
4252
|
-
e.push({ token: `\\overline{ ${i.token} }`, tokenType: "variable" });
|
|
4253
|
-
}
|
|
4254
|
-
break;
|
|
4255
|
-
}
|
|
4256
|
-
return e[0].token;
|
|
4257
|
-
}
|
|
4258
4258
|
}
|
|
4259
4259
|
const de = {
|
|
4260
4260
|
ShutingYard: P,
|
package/lib/main.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import {Numeric} from "./maths/numeric.ts";
|
|
2
|
+
import {NumExp} from "./maths/numexp.ts";
|
|
3
|
+
import {Shutingyard} from "./maths/shutingyard.ts";
|
|
4
|
+
import {Random} from "./maths/randomization/random.ts";
|
|
5
|
+
import {Fraction} from "./maths/coefficients/fraction.ts";
|
|
6
|
+
import {NthRoot} from "./maths/coefficients/nthRoot.ts";
|
|
7
|
+
import {Monom} from "./maths/algebra/monom.ts";
|
|
8
|
+
import {Polynom} from "./maths/algebra/polynom.ts";
|
|
9
|
+
import {Equation} from "./maths/algebra/equation.ts";
|
|
10
|
+
import {LinearSystem} from "./maths/algebra/linearSystem.ts";
|
|
11
|
+
import {Rational} from "./maths/algebra/rational.ts";
|
|
12
|
+
import {Logicalset} from "./maths/algebra/logicalset.ts";
|
|
13
|
+
import {Vector} from "./maths/geometry/vector.ts";
|
|
14
|
+
import {Line} from "./maths/geometry/line.ts";
|
|
15
|
+
import {Triangle} from "./maths/geometry/triangle.ts";
|
|
16
|
+
import {Circle} from "./maths/geometry/circle.ts";
|
|
17
|
+
import {Point} from "./maths/geometry/point.ts";
|
|
18
|
+
|
|
19
|
+
// Expose as global
|
|
20
|
+
export const PiMath = {
|
|
21
|
+
ShutingYard: Shutingyard,
|
|
22
|
+
Numeric: Numeric,
|
|
23
|
+
NumExp: NumExp,
|
|
24
|
+
Fraction: Fraction,
|
|
25
|
+
Root: NthRoot,
|
|
26
|
+
Monom: Monom,
|
|
27
|
+
Polynom: Polynom,
|
|
28
|
+
Equation: Equation,
|
|
29
|
+
LinearSystem: LinearSystem,
|
|
30
|
+
Rational: Rational,
|
|
31
|
+
Logicalset: Logicalset,
|
|
32
|
+
Random: Random,
|
|
33
|
+
Geometry: {
|
|
34
|
+
Vector: Vector,
|
|
35
|
+
Point: Point,
|
|
36
|
+
Line: Line,
|
|
37
|
+
Triangle: Triangle,
|
|
38
|
+
Circle: Circle
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
// (<any>window).PiMath = PiMath
|