|
4 | 4 | */ |
5 | 5 | package com.github.gbenroscience.parser; |
6 | 6 |
|
7 | | -import com.github.gbenroscience.util.FunctionManager; |
8 | | -import com.github.gbenroscience.util.Serializer; |
9 | | -import com.github.gbenroscience.util.VariableManager; |
10 | | -import com.github.gbenroscience.interfaces.Savable; |
11 | | -import com.github.gbenroscience.interfaces.Solvable; |
12 | 7 | import java.util.ArrayDeque; |
13 | | -import com.github.gbenroscience.logic.DRG_MODE; |
14 | | -import com.github.gbenroscience.math.Main; |
15 | | -import com.github.gbenroscience.parser.methods.Declarations; |
16 | | -import com.github.gbenroscience.parser.methods.Help; |
17 | | -import com.github.gbenroscience.parser.methods.Method; |
18 | | - |
19 | | -import com.github.gbenroscience.math.Maths; |
20 | | - |
21 | 8 | import java.util.ArrayList; |
22 | 9 | import java.util.Arrays; |
23 | 10 | import java.util.Deque; |
| 11 | +import java.util.HashMap; |
24 | 12 | import java.util.InputMismatchException; |
25 | 13 | import java.util.Iterator; |
26 | | - |
27 | 14 | import java.util.List; |
| 15 | +import java.util.Map; |
| 16 | +import java.util.Stack; |
28 | 17 |
|
29 | | -import static com.github.gbenroscience.parser.Variable.*; |
30 | | -import static com.github.gbenroscience.parser.Number.*; |
31 | | -import static com.github.gbenroscience.parser.Operator.*; |
32 | | - |
| 18 | +import com.github.gbenroscience.interfaces.Savable; |
| 19 | +import com.github.gbenroscience.interfaces.Solvable; |
| 20 | +import com.github.gbenroscience.logic.DRG_MODE; |
| 21 | +import com.github.gbenroscience.math.Main; |
| 22 | +import com.github.gbenroscience.math.Maths; |
33 | 23 | import com.github.gbenroscience.math.matrix.expressParser.Matrix; |
34 | | - |
| 24 | +import static com.github.gbenroscience.parser.Number.fastParseDouble; |
| 25 | +import static com.github.gbenroscience.parser.Number.isNumber; |
| 26 | +import static com.github.gbenroscience.parser.Operator.isAssignmentOperator; |
| 27 | +import static com.github.gbenroscience.parser.Operator.isBinaryOperator; |
| 28 | +import static com.github.gbenroscience.parser.Operator.isBracket; |
| 29 | +import static com.github.gbenroscience.parser.Operator.isComma; |
| 30 | +import static com.github.gbenroscience.parser.Operator.isLogicOperator; |
| 31 | +import static com.github.gbenroscience.parser.Operator.isOpeningBracket; |
| 32 | +import static com.github.gbenroscience.parser.Operator.isUnaryPostOperator; |
| 33 | +import static com.github.gbenroscience.parser.Operator.isUnaryPreOperator; |
| 34 | +import static com.github.gbenroscience.parser.Operator.validateAll; |
35 | 35 | import static com.github.gbenroscience.parser.TYPE.ALGEBRAIC_EXPRESSION; |
36 | 36 | import static com.github.gbenroscience.parser.TYPE.MATRIX; |
| 37 | +import static com.github.gbenroscience.parser.TYPE.VECTOR; |
| 38 | +import static com.github.gbenroscience.parser.Variable.isVariableString; |
37 | 39 | import com.github.gbenroscience.parser.benchmarks.GG; |
38 | | -import com.github.gbenroscience.parser.methods.MethodRegistry; |
| 40 | +import com.github.gbenroscience.parser.methods.Declarations; |
| 41 | +import com.github.gbenroscience.parser.methods.Help; |
| 42 | +import com.github.gbenroscience.parser.methods.Method; |
| 43 | +import com.github.gbenroscience.parser.methods.MethodRegistry; |
39 | 44 | import com.github.gbenroscience.parser.turbo.tools.FastCompositeExpression; |
40 | | -import com.github.gbenroscience.parser.turbo.tools.MatrixTurboEvaluator; |
41 | | -import java.util.HashMap; |
42 | | -import java.util.Map; |
43 | | -import java.util.Stack; |
44 | | -import static com.github.gbenroscience.parser.TYPE.VECTOR; |
| 45 | +import com.github.gbenroscience.parser.turbo.tools.MatrixTurboEvaluator; |
45 | 46 | import com.github.gbenroscience.parser.turbo.tools.ScalarTurboEvaluator; |
46 | 47 | import com.github.gbenroscience.parser.turbo.tools.TurboExpressionEvaluator; |
| 48 | +import com.github.gbenroscience.util.FunctionManager; |
| 49 | +import com.github.gbenroscience.util.Serializer; |
| 50 | +import com.github.gbenroscience.util.VariableManager; |
47 | 51 |
|
48 | 52 | /** |
49 | 53 | * |
@@ -2488,9 +2492,10 @@ public static void main1(String... args) { |
2488 | 2492 | static class Test_Strength_Reduction { |
2489 | 2493 |
|
2490 | 2494 | public static void main(String... args) { |
2491 | | - System.out.println("=".repeat(80)); |
| 2495 | + String rpt = STRING.repeat("=", 80); |
| 2496 | + System.out.println( rpt ); |
2492 | 2497 | System.out.println("SAFE CONSTANT FOLDING WITH STRENGTH REDUCTION"); |
2493 | | - System.out.println("=".repeat(80)); |
| 2498 | + System.out.println(rpt); |
2494 | 2499 |
|
2495 | 2500 | testConstantFolding(); |
2496 | 2501 | testWithVariables(); |
@@ -2569,9 +2574,10 @@ private static void testComplexExpression() { |
2569 | 2574 | static class Test { |
2570 | 2575 |
|
2571 | 2576 | public static void main(String... args) { |
2572 | | - System.out.println("=".repeat(80)); |
| 2577 | + String rpt = STRING.repeat("=", 80); |
| 2578 | + System.out.println(rpt); |
2573 | 2579 | System.out.println("POSTFIX EVALUATION ACCURACY TESTS"); |
2574 | | - System.out.println("=".repeat(80)); |
| 2580 | + System.out.println(rpt); |
2575 | 2581 |
|
2576 | 2582 | // Test 1: Basic arithmetic |
2577 | 2583 | testExpression("2+3", 5.0, "Basic addition"); |
@@ -2627,9 +2633,9 @@ public static void main(String... args) { |
2627 | 2633 | testExpression("1*1", 1.0, "One multiplication"); |
2628 | 2634 | testExpression("5-5", 0.0, "Subtraction to zero"); |
2629 | 2635 |
|
2630 | | - System.out.println("\n" + "=".repeat(80)); |
| 2636 | + System.out.println("\n" + rpt); |
2631 | 2637 | System.out.println("ACCURACY TEST SUMMARY"); |
2632 | | - System.out.println("=".repeat(80)); |
| 2638 | + System.out.println(rpt); |
2633 | 2639 | } |
2634 | 2640 |
|
2635 | 2641 | private static void testExpression(String expr, double expected, String description) { |
|
0 commit comments