math-exercises 3.0.201 → 3.0.202
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/lib/exercises/math/dataRepresentations/scatterPlot/index.d.ts +2 -0
- package/lib/exercises/math/dataRepresentations/scatterPlot/index.d.ts.map +1 -1
- package/lib/exercises/math/dataRepresentations/scatterPlot/index.js +2 -2
- package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotFillDataTableFromScatterPlotData.js +2 -2
- package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotFillDataTableWithDataClassesFromScatterPlotData.d.ts.map +1 -1
- package/lib/exercises/math/dataRepresentations/scatterPlot/scatterPlotFillDataTableWithDataClassesFromScatterPlotData.js +9 -2
- package/lib/exercises/math/derivation/derivative/exp/secondDerivativeOfExpoFunction.js +1 -1
- package/lib/exercises/math/derivation/derivative/trigo/index.d.ts +1 -0
- package/lib/exercises/math/derivation/derivative/trigo/index.d.ts.map +1 -1
- package/lib/exercises/math/derivation/derivative/trigo/index.js +1 -1
- package/lib/exercises/math/derivation/derivative/trigo/sinCosDerivativeRewriteUsingCos2PlusSin2Equals1.d.ts.map +1 -1
- package/lib/exercises/math/derivation/derivative/trigo/sinCosDerivativeRewriteUsingCos2PlusSin2Equals1.js +1 -1
- package/lib/exercises/math/derivation/problems/index.d.ts +1 -0
- package/lib/exercises/math/derivation/problems/index.d.ts.map +1 -1
- package/lib/exercises/math/derivation/problems/index.js +1 -1
- package/lib/exercises/math/derivation/problems/problemMaximizeProfitFindProduction.d.ts.map +1 -1
- package/lib/exercises/math/derivation/problems/problemMaximizeProfitFindProduction.js +31 -21
- package/lib/exercises/math/derivation/tangent/derivativeEquationSolvingByManipulatingLineY.d.ts.map +1 -1
- package/lib/exercises/math/derivation/tangent/derivativeEquationSolvingByManipulatingLineY.js +8 -128
- package/lib/exercises/math/derivation/tangent/index.d.ts +1 -0
- package/lib/exercises/math/derivation/tangent/index.d.ts.map +1 -1
- package/lib/exercises/math/derivation/tangent/index.js +1 -1
- package/lib/exercises/math/derivation/variations/index.d.ts +1 -0
- package/lib/exercises/math/derivation/variations/index.d.ts.map +1 -1
- package/lib/exercises/math/derivation/variations/index.js +1 -1
- package/lib/exercises/math/derivation/variations/signVarTableQuotientFExp.d.ts.map +1 -1
- package/lib/exercises/math/derivation/variations/signVarTableQuotientFExp.js +47 -20
- package/lib/exercises/math/equaDiff/equaDiffAyPlusB.d.ts.map +1 -1
- package/lib/exercises/math/equaDiff/equaDiffAyPlusB.js +29 -6
- package/lib/exercises/math/equaDiff/equaDiffCheckSolutionFirstOrder.d.ts.map +1 -1
- package/lib/exercises/math/equaDiff/equaDiffCheckSolutionFirstOrder.js +33 -0
- package/lib/exercises/math/equaDiff/exponentialDifferentialEquation.d.ts +7 -0
- package/lib/exercises/math/equaDiff/exponentialDifferentialEquation.d.ts.map +1 -0
- package/lib/exercises/math/equaDiff/exponentialDifferentialEquation.js +86 -0
- package/lib/exercises/math/equaDiff/exponentialDifferentialEquationWithIC.d.ts.map +1 -1
- package/lib/exercises/math/equaDiff/exponentialDifferentialEquationWithIC.js +35 -7
- package/lib/exercises/math/equaDiff/index.d.ts +1 -1
- package/lib/exercises/math/equaDiff/index.d.ts.map +1 -1
- package/lib/exercises/math/equaDiff/index.js +1 -1
- package/lib/exercises/math/functions/integral/integralExpU.d.ts.map +1 -1
- package/lib/exercises/math/functions/integral/integralExpU.js +48 -0
- package/lib/exercises/math/functions/integral/integralFractions.d.ts.map +1 -1
- package/lib/exercises/math/functions/integral/integralFractions.js +52 -0
- package/lib/exercises/math/functions/integral/integralTrinomials.d.ts.map +1 -1
- package/lib/exercises/math/functions/integral/integralTrinomials.js +40 -0
- package/lib/exercises/math/functions/logarithm/log10Simplifying.js +2 -2
- package/lib/exercises/math/functions/logarithm/powerEquation.js +1 -1
- package/lib/exercises/math/geometry/parametric/extractVectorFromParametricLine.d.ts.map +1 -1
- package/lib/exercises/math/geometry/parametric/extractVectorFromParametricLine.js +30 -25
- package/lib/exercises/math/geometry/parametric/pointFromParametricLine.d.ts.map +1 -1
- package/lib/exercises/math/geometry/parametric/pointFromParametricLine.js +52 -5
- package/lib/exercises/math/integration/fromExpr/areaBetweenCrossingCurvesFixedPosFromExpr.d.ts.map +1 -1
- package/lib/exercises/math/integration/fromExpr/areaBetweenCrossingCurvesFixedPosFromExpr.js +26 -35
- package/lib/exercises/math/integration/fromExpr/index.d.ts +1 -0
- package/lib/exercises/math/integration/fromExpr/index.d.ts.map +1 -1
- package/lib/exercises/math/integration/fromExpr/index.js +1 -1
- package/lib/exercises/math/primitive/constantPrimitive.d.ts.map +1 -1
- package/lib/exercises/math/primitive/constantPrimitive.js +25 -1
- package/lib/exercises/math/primitive/exponentialPrimitive.d.ts.map +1 -1
- package/lib/exercises/math/primitive/exponentialPrimitive.js +17 -0
- package/lib/exercises/math/primitive/polynomialPrimitive.d.ts.map +1 -1
- package/lib/exercises/math/primitive/polynomialPrimitive.js +17 -1
- package/lib/exercises/math/primitive/sinCosPrimitive.d.ts.map +1 -1
- package/lib/exercises/math/primitive/sinCosPrimitive.js +20 -1
- package/lib/exercises/math/primitive/usualPrimitives.d.ts.map +1 -1
- package/lib/exercises/math/primitive/usualPrimitives.js +1 -0
- package/lib/exercises/math/sets/cartesianProduct/findCardinalOfCartesianProductOfFiniteSets.js +4 -4
- package/lib/exercises/math/sets/cartesianProduct/findCardinalOfCartesianProductOfFiniteSetsFromSituation.js +3 -3
- package/lib/exercises/math/sets/cartesianProduct/proposeElementInCartesianProductOfFiniteSets.js +4 -4
- package/lib/exercises/math/spaceGeometry/basis/spaceCoordinatesOfPointInCubeCoordSystemFromVecPath.js +1 -1
- package/lib/exercises/math/spaceGeometry/orthogonalProjection/findOrthogonalProjectionOfPointOnPlane.d.ts.map +1 -1
- package/lib/exercises/math/spaceGeometry/orthogonalProjection/findOrthogonalProjectionOfPointOnPlane.js +12 -25
- package/lib/exercises/math/spaceGeometry/orthogonalProjection/index.d.ts +1 -1
- package/lib/exercises/math/spaceGeometry/orthogonalProjection/index.d.ts.map +1 -1
- package/lib/exercises/math/spaceGeometry/orthogonalProjection/index.js +1 -2
- package/lib/exercises/math/spaceGeometry/planes/findNormalVectorFromPlanePointsCoords.d.ts.map +1 -1
- package/lib/exercises/math/spaceGeometry/planes/findNormalVectorFromPlanePointsCoords.js +11 -26
- package/lib/exercises/math/spaceGeometry/planes/index.d.ts +1 -0
- package/lib/exercises/math/spaceGeometry/planes/index.d.ts.map +1 -1
- package/lib/exercises/math/spaceGeometry/planes/index.js +1 -1
- package/lib/exercises/math/spaceGeometry/planes/planePlaneRelativePositions.d.ts.map +1 -1
- package/lib/exercises/math/spaceGeometry/planes/planePlaneRelativePositions.js +11 -25
- package/lib/exercises/math/spaceGeometry/scalarProduct/angleFromScalarProductFromSpacePointCoords.d.ts.map +1 -1
- package/lib/exercises/math/spaceGeometry/scalarProduct/angleFromScalarProductFromSpacePointCoords.js +25 -5
- package/lib/exercises/math/spaceGeometry/scalarProduct/index.d.ts +1 -0
- package/lib/exercises/math/spaceGeometry/scalarProduct/index.d.ts.map +1 -1
- package/lib/exercises/math/spaceGeometry/scalarProduct/index.js +1 -1
- package/lib/exercises/math/spaceGeometry/vectors/findLinearDecompositionWrtCoplanarUVFromCoords.js +2 -2
- package/lib/exercises/math/trigonometry/functions/equationCosOnRandomInterval.d.ts.map +1 -1
- package/lib/exercises/math/trigonometry/functions/equationCosOnRandomInterval.js +87 -24
- package/lib/exercises/pc/mathExosInPC.d.ts +1 -1
- package/lib/exercises/pc/mathExosInPC.d.ts.map +1 -1
- package/lib/exercises/pc/mathExosInPC.js +1 -1
- package/lib/index.d.ts +55 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/math/geometry/spaceVector.d.ts +2 -0
- package/lib/math/geometry/spaceVector.d.ts.map +1 -1
- package/lib/math/geometry/spaceVector.js +40 -0
- package/lib/math/utils/polynomial/polynomialUtils.d.ts +2 -2
- package/lib/math/utils/polynomial/polynomialUtils.d.ts.map +1 -1
- package/lib/math/utils/polynomial/polynomialUtils.js +5 -2
- package/lib/tests/exoTest.js +1 -1
- package/lib/tests/questionTest.d.ts.map +1 -1
- package/lib/tests/questionTest.js +7 -3
- package/lib/tests/singleExo.test.d.ts.map +1 -1
- package/lib/tests/singleExo.test.js +2 -2
- package/lib/tree/utilities/nodeComparator.d.ts +1 -1
- package/lib/tree/utilities/nodeComparator.d.ts.map +1 -1
- package/lib/tree/utilities/nodeComparator.js +6 -4
- package/lib/tree/utilities/nodeSimplifier.d.ts +1 -0
- package/lib/tree/utilities/nodeSimplifier.d.ts.map +1 -1
- package/lib/tree/utilities/nodeSimplifier.js +40 -0
- package/package.json +1 -1
|
@@ -106,7 +106,7 @@ export function createNodeFPolynomialFromCoeffs(arrNodeCoeff, isFilterOutTopZero
|
|
|
106
106
|
* @param arrPoint
|
|
107
107
|
* @returns coeffN x^N + ... + coeff2 x^2 + coeff1 x^1 + coeff0
|
|
108
108
|
*/
|
|
109
|
-
export function createNodeFTrinomFromPoints(nodeA, arrPoint) {
|
|
109
|
+
export function createNodeFTrinomFromPoints(nodeA, arrPoint, isShouldSimplify = false, simplifyOptionsPass1 = {}, simplifyOptionsPass2 = {}) {
|
|
110
110
|
const [[nodeX1, nodeY1], [nodeX2, nodeY2]] = arrPoint.map((point) => [
|
|
111
111
|
point.x,
|
|
112
112
|
point.y,
|
|
@@ -118,7 +118,10 @@ export function createNodeFTrinomFromPoints(nodeA, arrPoint) {
|
|
|
118
118
|
//{c=y1-(ax1^2+bx1)
|
|
119
119
|
const nodeB = frac(substract(substract(nodeY1, nodeY2), multiply(nodeA, substract(square(nodeX1), square(nodeX2)))), substract(nodeX1, nodeX2));
|
|
120
120
|
const nodeC = substract(nodeY1, add(multiply(nodeA, square(nodeX1)), multiply(nodeB, nodeX1)));
|
|
121
|
-
const
|
|
121
|
+
const [nodeARefined, nodeBRefined, nodeCRefined] = isShouldSimplify
|
|
122
|
+
? [nodeA, nodeB, nodeC].map((node) => node.simplify(simplifyOptionsPass1).simplify(simplifyOptionsPass2))
|
|
123
|
+
: [nodeA, nodeB, nodeC];
|
|
124
|
+
const nodePolynomial = createNodeFPolynomialFromCoeffs([nodeCRefined, nodeBRefined, nodeARefined], true);
|
|
122
125
|
return nodePolynomial;
|
|
123
126
|
}
|
|
124
127
|
/**
|
package/lib/tests/exoTest.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"questionTest.d.ts","sourceRoot":"","sources":["../../src/tests/questionTest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AA0BjE,eAAO,MAAM,YAAY,GACvB,KAAK,QAAQ,CAAC,MAAM,CAAC,EACrB,UAAU,QAAQ,CAAC,MAAM,CAAC;;;
|
|
1
|
+
{"version":3,"file":"questionTest.d.ts","sourceRoot":"","sources":["../../src/tests/questionTest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AA0BjE,eAAO,MAAM,YAAY,GACvB,KAAK,QAAQ,CAAC,MAAM,CAAC,EACrB,UAAU,QAAQ,CAAC,MAAM,CAAC;;;CAuV3B,CAAC"}
|
|
@@ -203,8 +203,11 @@ export const questionTest = (exo, question) => {
|
|
|
203
203
|
throw new Error(`exo ${exo.id} has no keys`);
|
|
204
204
|
const answer = question.answer;
|
|
205
205
|
const before = Date.now();
|
|
206
|
+
if (!exo.isAnswerValid)
|
|
207
|
+
throw new Error(`exo ${exo.id} has no isAnswerValid`);
|
|
206
208
|
console.log("will test vea : ", exo.id);
|
|
207
|
-
if (!exo.isAnswerValid(answer, { answer, ...question.identifiers }, question.options)
|
|
209
|
+
if (!exo.isAnswerValid(answer, { answer, ...question.identifiers }, question.options) ||
|
|
210
|
+
exo.isAnswerValid("N.S.P", { answer, ...question.identifiers }, question.options)) {
|
|
208
211
|
throw new Error(`exo ${exo.id} has invalid VEA, ids ${jsonIds}, answer ${question.answer}`);
|
|
209
212
|
}
|
|
210
213
|
const after = Date.now();
|
|
@@ -235,8 +238,9 @@ export const questionTest = (exo, question) => {
|
|
|
235
238
|
throw new Error(`exo ${exo.id} has invalid props, ${props.map((p) => p.statement)}`);
|
|
236
239
|
}
|
|
237
240
|
else {
|
|
238
|
-
if (rightAnswers !== 1)
|
|
239
|
-
throw new Error(`exo ${exo.id} has invalid props`);
|
|
241
|
+
if (rightAnswers !== 1) {
|
|
242
|
+
throw new Error(`exo ${exo.id} has invalid props, rightAnswers: ${rightAnswers}`);
|
|
243
|
+
}
|
|
240
244
|
}
|
|
241
245
|
props.forEach((prop) => {
|
|
242
246
|
if (prop.statement.includes("undefined"))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"singleExo.test.d.ts","sourceRoot":"","sources":["../../src/tests/singleExo.test.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"singleExo.test.d.ts","sourceRoot":"","sources":["../../src/tests/singleExo.test.ts"],"names":[],"mappings":"AAGA,OAAO,6BAA6B,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import "../prototypesEnhancement.js";
|
|
2
2
|
import { exoTest } from "./exoTest.js";
|
|
3
|
-
import {
|
|
3
|
+
import { problemMaximizeProfitFindProduction, } from "../exercises/math/index.js";
|
|
4
4
|
try {
|
|
5
5
|
for (let i = 0; i < 1000; i++)
|
|
6
|
-
exoTest(
|
|
6
|
+
exoTest(problemMaximizeProfitFindProduction);
|
|
7
7
|
}
|
|
8
8
|
catch (err) {
|
|
9
9
|
throw err;
|
|
@@ -5,7 +5,7 @@ export declare abstract class NodeComparator {
|
|
|
5
5
|
static compareViaSub: <T extends AlgebraicNode>(node1: T, node2: T) => -1 | 0 | 1;
|
|
6
6
|
static isEqualViaSub: (node1: AlgebraicNode, node2: AlgebraicNode) => boolean;
|
|
7
7
|
static isEqualViaFrac: (node1: AlgebraicNode, node2: AlgebraicNode) => boolean;
|
|
8
|
-
static isEqualViaRandomEvaluations(node1: AlgebraicNode, node2: AlgebraicNode, nbRandomEvaluations: number): boolean;
|
|
8
|
+
static isEqualViaRandomEvaluations(node1: AlgebraicNode, node2: AlgebraicNode, nbRandomEvaluations: number, precision?: number): boolean;
|
|
9
9
|
static isNodeInDiscreteSet: (node: AlgebraicNode, nodeDiscreteSet: DiscreteSetNode) => boolean;
|
|
10
10
|
static isTupleInCartesianProductOfDiscreteSets: (tuple: Tuple, arrDiscreteSet: DiscreteSetNode[]) => boolean;
|
|
11
11
|
static isEqualTuple: (tuple1: Tuple, tuple2: Tuple) => boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeComparator.d.ts","sourceRoot":"","sources":["../../../src/tree/utilities/nodeComparator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAGjD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAI1D,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"nodeComparator.d.ts","sourceRoot":"","sources":["../../../src/tree/utilities/nodeComparator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAGjD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAI1D,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAKnE,8BAAsB,cAAc;IAGlC,MAAM,CAAC,aAAa,GAAI,CAAC,SAAS,aAAa,EAC7C,OAAO,CAAC,EACR,OAAO,CAAC,KACP,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CA4DX;IAEF,MAAM,CAAC,aAAa,GAClB,OAAO,aAAa,EACpB,OAAO,aAAa,KACnB,OAAO,CAER;IAIF,MAAM,CAAC,cAAc,GACnB,OAAO,aAAa,EACpB,OAAO,aAAa,KACnB,OAAO,CAgBR;IAIF,MAAM,CAAC,2BAA2B,CAChC,KAAK,EAAE,aAAa,EACpB,KAAK,EAAE,aAAa,EACpB,mBAAmB,EAAE,MAAM,EAC3B,SAAS,GAAE,MAAU;IAiEvB,MAAM,CAAC,mBAAmB,GACxB,MAAM,aAAa,EACnB,iBAAiB,eAAe,aAI9B;IAEJ,MAAM,CAAC,uCAAuC,GAC5C,OAAO,KAAK,EACZ,gBAAgB,eAAe,EAAE,aAQjC;IAIF,MAAM,CAAC,YAAY,GAAI,QAAQ,KAAK,EAAE,QAAQ,KAAK,aAIjD;IAEF,MAAM,CAAC,iBAAiB,GAAI,OAAO,KAAK,EAAE,UAAU,KAAK,EAAE,aAMzD;CACH"}
|
|
@@ -5,6 +5,7 @@ import { frac } from "../nodes/operators/fractionNode.js";
|
|
|
5
5
|
import { substract } from "../nodes/operators/substractNode.js";
|
|
6
6
|
import { NodeRewriter } from "./nodeRewriter.js";
|
|
7
7
|
import { NodeSimplifier } from "./nodeSimplifier.js";
|
|
8
|
+
import { round } from "../../math/utils/round.js";
|
|
8
9
|
export class NodeComparator {
|
|
9
10
|
//via sub
|
|
10
11
|
static compareViaSub = (node1, node2) => {
|
|
@@ -89,7 +90,7 @@ export class NodeComparator {
|
|
|
89
90
|
});
|
|
90
91
|
};
|
|
91
92
|
//via random evaluations
|
|
92
|
-
static isEqualViaRandomEvaluations(node1, node2, nbRandomEvaluations) {
|
|
93
|
+
static isEqualViaRandomEvaluations(node1, node2, nbRandomEvaluations, precision = 8) {
|
|
93
94
|
const getSafeEvaluationDictForEqualityCheck = (node1, node2, nbSafeX = 4) => {
|
|
94
95
|
const dict = {};
|
|
95
96
|
let counter = -1;
|
|
@@ -125,9 +126,10 @@ export class NodeComparator {
|
|
|
125
126
|
return dict;
|
|
126
127
|
};
|
|
127
128
|
return Object.values(getSafeEvaluationDictForEqualityCheck(node1, node2, nbRandomEvaluations)).every((arrSafeEval) => {
|
|
128
|
-
return arrSafeEval
|
|
129
|
-
.
|
|
130
|
-
|
|
129
|
+
return arrSafeEval.slice(1).every((safeEval) => {
|
|
130
|
+
const valueSubRounded = round(substract(arrSafeEval[0].value, safeEval.value).evaluate(), precision);
|
|
131
|
+
return valueSubRounded === 0;
|
|
132
|
+
});
|
|
131
133
|
});
|
|
132
134
|
}
|
|
133
135
|
//discreteSets, etc.
|
|
@@ -11,5 +11,6 @@ export declare abstract class NodeSimplifier {
|
|
|
11
11
|
isMultiTopLevel: boolean;
|
|
12
12
|
}, toTexOpts?: ToTexOptions) => string[];
|
|
13
13
|
static simplifyByVibrating(algebraicNode: AlgebraicNode, nbVibrations?: number, isTowardsDistribute?: boolean): AlgebraicNode;
|
|
14
|
+
static simplifyByInfiltrating(algebraicNode: AlgebraicNode, simplifyOpts: SimplifyOptions): AlgebraicNode;
|
|
14
15
|
}
|
|
15
16
|
//# sourceMappingURL=nodeSimplifier.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeSimplifier.d.ts","sourceRoot":"","sources":["../../../src/tree/utilities/nodeSimplifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAiB3E,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAKhD,8BAAsB,cAAc;IAClC,MAAM,CAAC,QAAQ,GAAI,CAAC,SAAS,aAAa,EACxC,eAAe,CAAC,EAChB,cAAc,eAAe,EAC7B,eAAc,YAIb,KACA,MAAM,CAsBP;IAEF,MAAM,CAAC,iBAAiB,GAAI,eAAe,aAAa,sCAmCtD;IAEF,MAAM,CAAC,8BAA8B,GAAI,OAAO,aAAa,EAAE,qBAK7D;IAEF,MAAM,CAAC,eAAe,GAAI,CAAC,SAAS,aAAa,EAC/C,eAAe,CAAC,EAChB,cAAc,eAAe,EAC7B,iBAAgB;QACd,eAAe,EAAE,OAAO,CAAC;KAG1B,EACD,YAAW,YAIV,KACA,aAAa,EAAE,CA4JhB;IAEF,MAAM,CAAC,gBAAgB,GACrB,MAAM,aAAa,EACnB,eAAc,eAAoB,EAClC,iBAAgB;QACd,eAAe,EAAE,OAAO,CAAC;KAG1B,EACD,YAAW,YAIV,cAQD;IAEF,MAAM,CAAC,mBAAmB,CACxB,aAAa,EAAE,aAAa,EAC5B,YAAY,GAAE,MAAU,EACxB,mBAAmB,GAAE,OAAc,GAClC,aAAa;
|
|
1
|
+
{"version":3,"file":"nodeSimplifier.d.ts","sourceRoot":"","sources":["../../../src/tree/utilities/nodeSimplifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAiB3E,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAKhD,8BAAsB,cAAc;IAClC,MAAM,CAAC,QAAQ,GAAI,CAAC,SAAS,aAAa,EACxC,eAAe,CAAC,EAChB,cAAc,eAAe,EAC7B,eAAc,YAIb,KACA,MAAM,CAsBP;IAEF,MAAM,CAAC,iBAAiB,GAAI,eAAe,aAAa,sCAmCtD;IAEF,MAAM,CAAC,8BAA8B,GAAI,OAAO,aAAa,EAAE,qBAK7D;IAEF,MAAM,CAAC,eAAe,GAAI,CAAC,SAAS,aAAa,EAC/C,eAAe,CAAC,EAChB,cAAc,eAAe,EAC7B,iBAAgB;QACd,eAAe,EAAE,OAAO,CAAC;KAG1B,EACD,YAAW,YAIV,KACA,aAAa,EAAE,CA4JhB;IAEF,MAAM,CAAC,gBAAgB,GACrB,MAAM,aAAa,EACnB,eAAc,eAAoB,EAClC,iBAAgB;QACd,eAAe,EAAE,OAAO,CAAC;KAG1B,EACD,YAAW,YAIV,cAQD;IAEF,MAAM,CAAC,mBAAmB,CACxB,aAAa,EAAE,aAAa,EAC5B,YAAY,GAAE,MAAU,EACxB,mBAAmB,GAAE,OAAc,GAClC,aAAa;IAehB,MAAM,CAAC,sBAAsB,CAC3B,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,eAAe,GAC5B,aAAa;CAyDjB"}
|
|
@@ -209,4 +209,44 @@ export class NodeSimplifier {
|
|
|
209
209
|
return this.simplifyByVibrating(nodeSimplified, nbVibrations - 1, !isTowardsDistribute);
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
|
+
static simplifyByInfiltrating(algebraicNode, simplifyOpts) {
|
|
213
|
+
const outNode = (() => {
|
|
214
|
+
if (isOperatorNode(algebraicNode)) {
|
|
215
|
+
const [nodeLeft, nodeRight] = [
|
|
216
|
+
algebraicNode.leftChild,
|
|
217
|
+
algebraicNode.rightChild,
|
|
218
|
+
];
|
|
219
|
+
const isCanDiveDeeper = [nodeLeft, nodeRight].every((nodeChild) => isOperatorNode(nodeChild) || isFunctionNode(nodeChild));
|
|
220
|
+
if (isCanDiveDeeper) {
|
|
221
|
+
const [nodeLeftSimplified, nodeRightSimplified] = [
|
|
222
|
+
nodeLeft,
|
|
223
|
+
nodeRight,
|
|
224
|
+
].map((nodeChild) => this.simplifyByInfiltrating(nodeChild, simplifyOpts));
|
|
225
|
+
const funcMother = NodeRewriter.getArrCreateNodeFromChildrenFunction(algebraicNode).find(() => true);
|
|
226
|
+
return funcMother([nodeLeftSimplified, nodeRightSimplified]).simplify(simplifyOpts);
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
return algebraicNode.simplify(simplifyOpts);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
else if (isFunctionNode(algebraicNode)) {
|
|
233
|
+
const nodeChild = algebraicNode.child;
|
|
234
|
+
const isCanDiveDeeper = [nodeChild].every((nodeChild) => isOperatorNode(nodeChild) || isFunctionNode(nodeChild));
|
|
235
|
+
if (isCanDiveDeeper) {
|
|
236
|
+
const [nodeChildSimplified] = [nodeChild].map((nodeChild) => this.simplifyByInfiltrating(nodeChild, simplifyOpts));
|
|
237
|
+
const funcMother = NodeRewriter.getArrCreateNodeFromChildrenFunction(algebraicNode).find(() => true);
|
|
238
|
+
return funcMother([nodeChildSimplified]).simplify(simplifyOpts);
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
return algebraicNode.simplify(simplifyOpts);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
else {
|
|
245
|
+
return algebraicNode.simplify(simplifyOpts);
|
|
246
|
+
}
|
|
247
|
+
})();
|
|
248
|
+
// console.log("simplifyByInfiltrating", "nodeIn:", algebraicNode.toTex());
|
|
249
|
+
// console.log("simplifyByInfiltrating", "nodeOut:", outNode.toTex());
|
|
250
|
+
return outNode;
|
|
251
|
+
}
|
|
212
252
|
}
|