-
Notifications
You must be signed in to change notification settings - Fork 0
/
Usage.java
1018 lines (921 loc) · 50.6 KB
/
Usage.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Calculus;
import Calculus.MathsContxtLAv0_1.DiffExpr;
import Calculus.MathsContxtLAv0_1.Expression;
import Calculus.MathsContxtLAv0_1.FoG;
import Calculus.MathsContxtLAv0_1.FoGLowLvL;
import Calculus.MathsContxtLAv0_1.IntegrExpr;
import static Calculus.MathsContxtLAv0_1.MyFuncDiff;
import static Calculus.MathsContxtLAv0_1.MyFuncExpress;
import static Calculus.MathsContxtLAv0_1.MyFuncIntegr;
import static Calculus.MathsContxtLAv0_1.MyFuncSimple;
import Calculus.MathsContxtLAv0_1.OrderVar;
import Calculus.MathsContxtLAv0_1.Predicate;
import Calculus.MathsContxtLAv0_1.SimpleAlgebra;
import Calculus.MathsContxtLAv0_1.SimpleAlgebraHghLvl;
import Calculus.MathsContxtLAv0_1.SimpleExpression;
import static Calculus.MathsContxtLAv0_1.eatAll;
import static Calculus.MathsContxtLAv0_1.parse;
import static Calculus.MathsContxtLAv0_1.parseAlgebra;
import static Calculus.MathsContxtLAv0_1.parseAlgebraHghLvl;
import static Calculus.MathsContxtLAv0_1.parseDiff;
import static Calculus.MathsContxtLAv0_1.parseFoG;
import static Calculus.MathsContxtLAv0_1.parseFoGLowLvL;
import static Calculus.MathsContxtLAv0_1.parseIntegr;
import static Calculus.MathsContxtLAv0_1.parseOrder;
import static Calculus.MathsContxtLAv0_1.parsePredicate;
import static Calculus.MathsContxtLAv0_1.parseSimple;
import static Calculus.MathsContxtLAv0_1.variablesDiff;
import static Calculus.TestHarness.PassFailTestCaseString;
import static Calculus.TestHarness.PassFailTestCaseValue;
import static Calculus.TestHarness.TestPredicate;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.Scanner;
import org.apache.log4j.Logger;
/**
*
* @author Administrator
*/
public class Usage {
public static Logger log = Logger.getLogger(Usage.class.getName());
public static String DiffWithRespTo = "x";
public static int MaxDiffOrder = 6;
public static int MaxIntegreOrder = 6;
static String EqnUnderTest;
// Differentiation Mapping
static String[] EqnSolArrayMap1;
static String[] EqnSolArrayDiffAlone;
static String[] EqnSolArrayMap2;
// Integration Mapping
static String[] EqnSolArrayMap3;
static String[] EqnSolArrayIntegrAlone;
static String[] EqnSolArrayMap4;
static String[] EqnSolArrayIntegr_BeforeDiff;
static String[] EqnSolArrayDiff_AfterIntegr;
static String[] EqnSolArrayDiff_BeforeIntegr;
static String[] EqnSolArrayIntegr_AfterDiff;
static int[] EqnSolOrder;
static int TestCase = 0;
static int EndTestCase = 0;
static int LastTestCaseHarness=110007;
static int TestCaseLoopTimes = 110007;
static String EqnRegressionDiffStatus = "All RED";
static String EqnRegressionIntegreStatus = "All RED";
static String TestCaseName = "Standard";
static String TestCaseMatrixID = "Standard";
public static String FailingLowLevelUnitTestCases() {
//UnStructured Testing Test Cases
//String Exprn="x^2 - x +2 + y^3 + y + 4";
//HighLevel Unit Test for Whole Program
//14th Order Diff
/* ************************************************************************ */
//Failing Test Cases: Low Level Analysed/Debugged Failure
//Simple Basic Equation
//String Exprn = ;
//Simple Basic Equation
String Exprn = "x^8 + x^5 + x^4 - x - 25.0";
//Palindromic String-Equation Test
//String Exprn = " 25.0 + x - x^4 -x^5 -x^8 + x^8 + x^5 + x^4 - x - 25.0";
//Palindromic String-Equation Test-Rearranged
//String Exprn = " x^8 -x^8 + x^5 -x^5 + x^4 - x^4 + 25.0 + x - x - 25.0";
//Test for LookAheadFuncMultDiv
//Straight Numbers Leading + Trailing Co-eff :(LookAheadFuncMultDiv & ConstExprn)
//(Polynomials)
//String Exprn = "1/x^8 + 1/x^5 + 1/x^4 - 25.0";
//Functions
//String Exprn = "(2*x+1)*x^9 + x^7 + x^5 + x^2 - sin(x^2)- sin(2*x+5) ";
//String Exprn = "sin(2.0*7.0*x)+25.0";
//Parenthesis
//String Exprn = "(x^8+2*x+1) + x^7 - sin(x^4+ 2*x+ 5) ";
//Parenthesis with Constants
//String Exprn="(114.70000000000073*(x-11)+28843.09)*(x-1)*(x-2)*(x-3)*(x-4)*(x-5)*(x-6)*(x-7)*(x-8)*(x-9)*(x-10)*(1.0)*(x-12)*(x-13)*(x-14)*(x-15)*(x-16)*(x-17)*(x-18)*(x-19)*(x-20)*(x-21)";
//Addition Subtraction
//String Exprn = "(x^8+2*x+1) + x^7 - (x^4+ 2*x+ 5) ";
//Multiplication Division
//String Exprn = "(x^8+2*x+1) + x^7 - (x^4+ 2*x+ 5) ";
//Parenthesis within Parenthesis
//Add Operation
//Subtraction
//Divide Operation
//Multiplication
//Constants
//String Exprn="11.0*12.0*x*13.0*14.0";
return Exprn;
}
public static String FailingTestHarnessDiff(String AlgoName,int j) {
//Equation Component Testing
//1) Variables :L=3:Single Letter, Multi Letter, with Numerics
//2) Coefficient:L=9:0.0,0,1.0,1,-1.0,-1,5,-5,-5.0
//3) Exponent:L=6: +ve,-ve,0,1,Independent Constants, Long Form (x * x*x)
//4) Operator:L=2: *,/
//5) Constants:L=3: Start of Expr, Middle (2-5) Terms, End Term
//6) Independent Constants:L=3:Single Letter, Multi Letter, with Numerics
//7) Expression
//8) Term:L=3: Start Term, Middle (2-5) Terms, End Term
//9) Term Sign:L=3: +ve, -ve, No Sign
//10) Exponent Sign:L=3: +ve, -ve, No Sign
//11) Coefficient Sign:L=3: +ve, -ve, No Sign
//12) Variable Sign:L=3: +ve, -ve, No Sign
//13) Parenthesis:L=3 : 1st Term, 2nd Term , 3-5 Terms
//14) Functions:L5: Sin, Cos, Tan, Log, Ln
//15) Argument of Functions:L=4: Expr Alone(3 types), Expr with Inner Function
if((j >= 100)&&(j <= 105))
TestHarness.SanityTestCases(AlgoName,j);
else if((j >= 5019)&&(j <= 5042))
TestHarnessUnitTest.UnitTestCases(AlgoName,j);
//
// Variants
//
else if ((j >= 10001)&&(j <= 10005))
TestHarnessNames.Names(j);
else if((j >= 20001)&&(j <= 20092))
TestHarnessCoefficients.Coefficients(AlgoName,j);
else if((j >= 30001)&&(j <= 30011))
TestHarness.Exponent(AlgoName,j);
else if((j >= 40001)&&(j <= 40034))
TestHarnessSignedX.SignedX(AlgoName,j);
else if((j >= 50001)&&(j <= 50029))
TestHarnessIndConstant.IndConstant(AlgoName,j);
else if((j >= 80001)&&(j <= 80012))
TestHarness.Parenthesis(AlgoName,j);
else if((j >= 110001)&&(j <= 110007))
TestHarness.SoftwareEngg(AlgoName,j);
else {
switch (j) {
//Function Test Cases
case 90001:
TestHarness.TestCaseDiff90001();
break;
//Function Argument Test Cases
case 100001:
TestHarness.TestCaseDiff100001();
break;
default:
System.out.println(ConsoleColors.RED +"FailingTestHarnessDiff:j= " + j + ": Infinite Loop"+ ConsoleColors.RESET);
break;
}
}
return EqnUnderTest;
}
public static void mainPredicate(String[] args) {
Map<String, Double> variables = new HashMap<>();
String Exprn = TestPredicate();
String DiffWithRespTo = "x";
Predicate expValue;
MyFuncExpress();
Exprn = eatAll(Exprn, ' ');
int i = 1;
for (double x = -2, y = 7; i < 10; y++, x++, i++) {
variables.put("x", x);
variables.put("y", y);
System.out.println("main: x=" + x + " Exprn=" + Exprn);
expValue = parsePredicate(Exprn, variables);
System.out.println(" main:Result(Simplified Diff Value)=" + expValue.eval());
System.out.print(System.lineSeparator());
}
}
public static void mainDiff(String... args) {
Map<String, Double> variables = new HashMap<>();
Map<String, String> variablesDiff = new HashMap<>();
//String Exprn = eatAll(TestCases(), ' ');
//String Exprn = eatAll(HighLevelUnitTestCases(), ' ');
//String Exprn = eatAll(FailingHighLevelUnitTestCases(), ' ');
String Exprn = eatAll(FailingLowLevelUnitTestCases(), ' ');
SimpleExpression expSimple;
Expression expValue;
DiffExpr exp;
MyFuncExpress();
MyFuncDiff();
MyFuncSimple();
String DiffWithRespTo = "x";
String Constant = "C";
//String DiffWithRespTo = "Xn";
variablesDiff.put(DiffWithRespTo, DiffWithRespTo);
String StrexpSimpleExpress = "";
int i = 1;
for (double x = 1, y = 7; i < 5; y++, x++, i++) {
variables.put(DiffWithRespTo, x);
variables.put("y", y);
variables.put(Constant, 5.0);
System.out.println("main: x=" + x + " Exprn=" + Exprn);
expSimple = parseSimple(Exprn, variables, variablesDiff, DiffWithRespTo);
expValue = parse(Exprn, variables, DiffWithRespTo);
System.out.println(" main:Result(Expn Value)=" + expValue.eval());
StrexpSimpleExpress = expSimple.SimpleExpr();
System.out.println("main: x=" + x + " Basic Simple Exprn=" + StrexpSimpleExpress);
expValue = parse(StrexpSimpleExpress, variables, DiffWithRespTo);
System.out.println("main: x=" + x + " Basic Simple (Exprn Value)=" + expValue.eval());
exp = parseDiff(Exprn, variables, variablesDiff, DiffWithRespTo);
StrexpSimpleExpress = exp.DiffExpr();
System.out.println(" main:Result(Diff Equation)(" + i + " th order)=> " + StrexpSimpleExpress);
expValue = parse(StrexpSimpleExpress, variables, DiffWithRespTo);
System.out.println(" main:Result(Diff Value)=" + expValue.eval());
expSimple = parseSimple(StrexpSimpleExpress, variables, variablesDiff, DiffWithRespTo);
StrexpSimpleExpress = expSimple.SimpleExpr();
System.out.println(" main:Result(Simplified Diff Equation)(" + i + " th order)=> " + StrexpSimpleExpress);
expValue = parse(StrexpSimpleExpress, variables, DiffWithRespTo);
System.out.println(" main:Result(Simplified Diff Value)=" + expValue.eval());
System.out.print(System.lineSeparator());
expValue = parse(Exprn, variables, DiffWithRespTo);
System.out.println(" main:Result(Expn Value)=" + expValue.eval());
Exprn = StrexpSimpleExpress;
}
}
public static void mainIntegral(String... args) {
Map<String, Double> variables = new HashMap<>();
Map<String, String> variablesIntegr = new HashMap<>();
//String Exprn = eatAll(TestCases(), ' ');
//String Exprn = eatAll(HighLevelUnitTestCases(), ' ');
//String Exprn = eatAll(FailingHighLevelUnitTestCases(), ' ');
String Exprn = eatAll(FailingLowLevelUnitTestCases(), ' ');
SimpleExpression expSimple;
Expression expValue;
IntegrExpr expIntgr;
MyFuncExpress();
MyFuncSimple();
MyFuncIntegr();
String DiffWithRespTo = "x";
String Constant = "C";
//String DiffWithRespTo = "Xn";
String StrexpIntegrExpress = "";
String StrexpSimpleExpress = "";
variablesIntegr.put(DiffWithRespTo, DiffWithRespTo);
variablesIntegr.put(Constant, Constant);
StrexpIntegrExpress = Exprn;
int i = 1;
for (double x = -20, y = 7; i < 5; y++, x++, i++) {
variables.put(DiffWithRespTo, x);
variables.put("y", y);
variables.put(Constant, 5.0);
System.out.println("main: x=" + x + " Basic Simple Exprn=" + StrexpIntegrExpress);
expValue = parse(StrexpIntegrExpress, variables, DiffWithRespTo);
System.out.println("main: x=" + x + " Basic Simple (Exprn Value)=" + expValue.eval());
expIntgr = parseIntegr(StrexpIntegrExpress, variables, variablesDiff, DiffWithRespTo);
StrexpIntegrExpress = expIntgr.IntegrExpr();
System.out.println(" main:Result(Integral Equation)(" + i + " th order)=> " + StrexpIntegrExpress);
expValue = parse(StrexpIntegrExpress, variables, DiffWithRespTo);
System.out.println(" main:Result(Integral Value)=" + expValue.eval());
expSimple = parseSimple(StrexpIntegrExpress, variables, variablesDiff, DiffWithRespTo);
StrexpIntegrExpress = expSimple.SimpleExpr();
System.out.println(" main:Result(Simplified Integral Equation)(" + i + " th order)=> " + StrexpIntegrExpress);
expValue = parse(StrexpIntegrExpress, variables, DiffWithRespTo);
System.out.println(" main:Result(Simplified Integral Value)=" + expValue.eval());
expValue = parse(Exprn, variables, DiffWithRespTo);
System.out.println(" main:Result(Expn Value)=" + expValue.eval());
System.out.print(System.lineSeparator());
}
}
public static String RandomEquation(String a, String c, String RandVar) {
String Exprn = a + " * " + RandVar + "^7" + " + " + RandVar + "^5" + " + " + RandVar + "^2" + " - " + RandVar + " + " + c;
Exprn = eatAll(Exprn, ' ');
return Exprn;
}
public static String BrownianMotionEquation(String N, String ETA, String r, String R, String T, String x, String t, String RandVar) {
String Exprn = N + "*" + "sqrt((3*" + N + "*" + ETA + "*" + r + ")/(2*" + R + "*" + T + "))" + "*" + "exp((-3*" + Math.PI + "*" + ETA + "*" + N + "*" + r + "*" + x + "^2)/(2*" + R + "*" + T + "*" + t + "))";
Exprn = eatAll(Exprn, ' ');
return Exprn;
}
public static String FormEquation(long Xn,long MgtACoeff, long Mgtc, long MgtbCoeff,String TechDiffWithRespTo, int MgtMaxExponent) {
//if(Xn==0) MaxExponent=5;
//else MaxExponent=(int)Xn;
long bCoeffStore=MgtbCoeff;
//log.fatal("FormEquation: MgtbCoeff=" + MgtbCoeff );
String Exprn = MgtACoeff + " * " + TechDiffWithRespTo + "^" + (MgtMaxExponent );
for (int i = MgtMaxExponent - 1; i > 1; i--) {
if(MgtbCoeff >2)
Exprn = Exprn + " + " + MgtbCoeff + "*" + TechDiffWithRespTo + "^" + i;
else {
Exprn = Exprn + " + " + MgtbCoeff + "*" + TechDiffWithRespTo + "^" + i;
MgtbCoeff=bCoeffStore;
}
//MgtbCoeff=GetPrimeNumber(MgtbCoeff,i);
MgtbCoeff++;
//log.fatal("FormEquation: MgtbCoeff=" + MgtbCoeff + " i=" + i);
}
if(MgtbCoeff > 2)
Exprn =Exprn + " + " + MgtbCoeff + "*" + TechDiffWithRespTo;
else
Exprn =Exprn + " + " + TechDiffWithRespTo;
Exprn = Exprn + " + " + Mgtc;
Exprn = eatAll(Exprn, ' ');
log.warn("FormEquation:Exprn=" + Exprn);
return Exprn;
}
public static void mainRegresssionDiffTest(int MaxOrder, TestHarness TestData) {
String Exprn = "";
Map<String, Double> variables = new HashMap<>();
Map<String, String> variablesDiff = new HashMap<>();
//String Exprn = eatAll(TestCases(), ' ');
//String Exprn = eatAll(HighLevelUnitTestCases(), ' ');
//String Exprn = eatAll(FailingHighLevelUnitTestCases(), ' ');
//String Exprn = eatAll(FailingLowLevelUnitTestCases(), ' ');
//Exprn = eatAll(Exprn, ' ');
SimpleExpression expSimple;
Expression expValue;
DiffExpr exp;
OrderVar expOrder;
MyFuncExpress();
MyFuncDiff();
MyFuncSimple();
String Constant = "C";
//String DiffWithRespTo = "Xn";
String StrexpSimpleExpressMap1 = "";
String StrexpDiffExpress = "";
String StrexpSimpleExpressMap2 = "";
String myOrder = "";
double ExprnexpValue = 0;
double DblexpValueMap1 = 0;
double DblexpDiffValue = 0;
double DblexpValueMap2 = 0;
int j = TestCase;
boolean TestCasePassStrFlag = false;
boolean TestCasePassValFlag = false;
boolean TestCasePassHighLevelFlag = true;
HashMap<Integer, String> FailedTestCases = new HashMap<Integer, String>();
HashMap<Integer, String> ExceptionTestCases = new HashMap<Integer, String>();
int MaxIndexFail = 0;
int MaxIndexExcept = 0;
int MaxOrder1 = MaxOrder;
int i = 1;
int TotalTestCases = 0;
String OverallRegressionStatus = "Diff:Pass All (5019 to 100001) Except Test Cases: "
+ "\n" + "TestCases:Unit Test Cases" + " All Passing"
+ "\n" + "TestCases:Names " + " All Passing"
+ "\n" + "TestCases:Coefficients " + " 20016 , 20017"
+ "\n" + "TestCases:Exponent " + " 30006 to 30008";
System.out.print(ConsoleColors.BLUE + "Diff Overall Regression Status" + OverallRegressionStatus + ConsoleColors.RESET);
System.out.print(System.lineSeparator());
if(EndTestCase > LastTestCaseHarness)
EndTestCase=LastTestCaseHarness;
while (j <= EndTestCase) {
EqnUnderTest = "";
String TempExprn = "";
TempExprn = FailingTestHarnessDiff("mainDiffTest",j);
if (MaxOrder == -1) {
MaxOrder1 = MaxDiffOrder; //From Test Case
} else if (MaxOrder >= MaxDiffOrder) {
MaxOrder1 = MaxDiffOrder;
} else {
MaxOrder1 = MaxOrder;
}
if ((!EqnUnderTest.equalsIgnoreCase("")) && (TempExprn != null) && (!TempExprn.equalsIgnoreCase(""))) {
Exprn = eatAll(TempExprn, ' ');
} else {
j = RegressionControl(j);
System.out.println(ConsoleColors.RED + "mainDiffTest: j=" + j + " TestCase=" + TestCase);
continue;
}
System.out.println(ConsoleColors.YELLOW + "Test Case " + TestCase + " EndTestCase=" + EndTestCase + " j=" + j + ConsoleColors.RESET);
System.out.println(ConsoleColors.BLUE + "Test Case " + TestCase + " Exprn=" + Exprn + ConsoleColors.RESET);
System.out.println(ConsoleColors.BLUE + "Test Case Name=" + TestCaseName + ConsoleColors.RESET);
System.out.println(ConsoleColors.BLUE + "Test Case Name=" + TestCaseMatrixID + ConsoleColors.RESET);
System.out.println(ConsoleColors.BLUE + "Regression Status : Test Case should be " + EqnRegressionDiffStatus + ConsoleColors.RESET);
i = 1;
TotalTestCases++;
TestCasePassHighLevelFlag=true;
String StageMapping = "";
variablesDiff.put(DiffWithRespTo, DiffWithRespTo);
try {
for (double x = 1, y = 7; i < MaxOrder1; y++, x++, i++) {
TestCasePassStrFlag = false;
TestCasePassValFlag = false;
variables.put(DiffWithRespTo, x);
variables.put("y", y);
variables.put("a", 1.0);
variables.put("b", 2.0);//variables.put("b", 0.0);
variables.put("c", -1.0);
variables.put("d", 2.0);
variables.put("p", 3.0);
variables.put("q", 0.0);
variables.put("r", -1.0);
variables.put("s", 2.0);
variables.put(Constant, 5.0);
StageMapping = "Basic Mapping";
expOrder = parseOrder(Exprn, DiffWithRespTo);
myOrder = expOrder.eval();
System.out.println("main: " + DiffWithRespTo + "=" + x + " Exprn=" + Exprn + " Order=" + myOrder);
expSimple = parseSimple(Exprn, variables, variablesDiff, DiffWithRespTo);
StrexpSimpleExpressMap1 = expSimple.SimpleExpr();
System.out.println("main: " + DiffWithRespTo + "=" + x + " Basic Simple Exprn=" + StrexpSimpleExpressMap1);
expValue = parse(StrexpSimpleExpressMap1, variables, DiffWithRespTo);
ExprnexpValue = expValue.eval();
System.out.println(" main:Result(Expn Value)=" + ExprnexpValue);
expValue = parse(StrexpSimpleExpressMap1, variables, DiffWithRespTo);
DblexpValueMap1 = expValue.eval();
System.out.println("main: " + DiffWithRespTo + "=" + x + " Basic Simple (Exprn Value)=" + DblexpValueMap1);
StageMapping = "Differentiation";
exp = parseDiff(StrexpSimpleExpressMap1, variables, variablesDiff, DiffWithRespTo);
StrexpDiffExpress = exp.DiffExpr();
System.out.println(" main:Result(Diff Equation)(" + i + " th order)=> " + StrexpDiffExpress);
StageMapping = "Differentiation Mapping";
expSimple = parseSimple(StrexpDiffExpress, variables, variablesDiff, DiffWithRespTo);
StrexpSimpleExpressMap2 = expSimple.SimpleExpr();
expValue = parse(StrexpDiffExpress, variables, DiffWithRespTo);
DblexpDiffValue = expValue.eval();
System.out.println("main: " + DiffWithRespTo + "=" + x + " Result(Diff Value)=" + DblexpDiffValue);
System.out.println(" main:Result(Simplified Diff Equation)(" + i + " th order)=> " + StrexpSimpleExpressMap2);
expValue = parse(StrexpSimpleExpressMap2, variables, DiffWithRespTo);
DblexpValueMap2 = expValue.eval();
System.out.println("main: " + DiffWithRespTo + "=" + x + " Result(Simplified Diff Value)=" + expValue.eval());
System.out.print(System.lineSeparator());
if (PassFailTestCaseString(TestCase, i, "Diff" , Exprn, StrexpSimpleExpressMap1, StrexpDiffExpress, StrexpSimpleExpressMap2, EqnUnderTest, EqnSolArrayMap1[i], EqnSolArrayDiffAlone[i], EqnSolArrayMap2[i])) {
System.out.println(ConsoleColors.GREEN + " main:Test Case Status=" + "Pass STRING TEST Complete" + ConsoleColors.RESET);
TestCasePassStrFlag = true;
} else {
System.out.println(ConsoleColors.RED + " main:Test Case Status=" + "FAIL STRING TEST Complete" + ConsoleColors.RESET);
if(TestCasePassHighLevelFlag==true)
TestCasePassHighLevelFlag=false;
}
if (PassFailTestCaseValue(TestCase, i, "Diff",Exprn, ExprnexpValue, DblexpValueMap1, DblexpDiffValue, DblexpValueMap2,variables)) {
System.out.println(ConsoleColors.GREEN + " main:Test Case Status=" + "Pass VALUE TEST Complete" + ConsoleColors.RESET);
TestCasePassValFlag = true;
} else {
System.out.println(ConsoleColors.RED + " main:Test Case Status=" + "FAIL VALUE TEST Complete" + ConsoleColors.RESET);
if(TestCasePassHighLevelFlag==true)
TestCasePassHighLevelFlag=false;
}
Exprn = StrexpSimpleExpressMap2;
System.out.print(System.lineSeparator());
if ((TestCasePassStrFlag == true) && (TestCasePassValFlag == true))
;//Do Nothing : Test Case Passed
else {
String Temp = FailedTestCases.get(MaxIndexFail);
String HashVal = "";
if ((Temp != null) && (!Temp.equalsIgnoreCase(""))) {
HashVal = Temp + "," + ":Order=" + (i ) + ":Str=" + TestCasePassStrFlag + ":Val=" + TestCasePassValFlag;
} else {
HashVal = "TestCase=" + TestCase + ":Order=" + (i ) + ":Str=" + TestCasePassStrFlag + ":Val=" + TestCasePassValFlag;
}
FailedTestCases.put(MaxIndexFail, HashVal);
//i=MaxOrder1;
}
}
} catch (Exception MyException) {
System.out.print(System.lineSeparator());
System.out.print(System.lineSeparator());
MyException.printStackTrace();
System.out.println(ConsoleColors.RED + "TestCase " + TestCase + " Failed at Order=" + i + " due to Exception at Stage=" + StageMapping + "." + ConsoleColors.RESET);
System.out.print(System.lineSeparator());
String Temp = FailedTestCases.get(MaxIndexFail);
String HashVal = "";
if ((Temp != null) && (!Temp.equalsIgnoreCase(""))) {
HashVal = Temp + "," + ":Order=" + (i ) + ":Str=" + TestCasePassStrFlag + ":Val=" + TestCasePassValFlag;
} else {
HashVal = "TestCase=" + TestCase + ":Order=" + (i ) + ":Str=" + TestCasePassStrFlag + ":Val=" + TestCasePassValFlag;
}
FailedTestCases.put(MaxIndexFail, HashVal);
String Temp1 = ExceptionTestCases.get(MaxIndexExcept);
String HashVal1 = "";
if ((Temp1 != null) && (!Temp1.equalsIgnoreCase(""))) {
HashVal1 = Temp1 + "," + ":Order=" + (i ) ;
} else {
HashVal1 = "TestCase=" + TestCase + ":Order=" + (i ) ;
}
ExceptionTestCases.put(MaxIndexExcept, HashVal);
MaxIndexExcept++;
//i=MaxOrder1;
TestCasePassHighLevelFlag=false;
}
System.out.print(System.lineSeparator());
if (TestCaseLoopTimes == 1) {
break;
} else {
j = RegressionControl(j);
//System.out.println(ConsoleColors.RED +"mainDiffTest: j="+ j + " TestCase=" + TestCase);
}
if (TestCasePassHighLevelFlag==false) MaxIndexFail++;
}
System.out.println(ConsoleColors.RED + "mainDiffTest: TestCase Summary : Total Failed=" + MaxIndexFail + " Out of Run TestCases=" + TotalTestCases + " Failed Test Cases are:" + ConsoleColors.RESET);
for (int y = 0; y < MaxIndexFail; y++) {
System.out.print(ConsoleColors.RED + " " + FailedTestCases.get(y) + ", " + ConsoleColors.RESET);
if ((y !=0)&&(y % 5 == 0) ) {
System.out.print(System.lineSeparator());
}
}
System.out.print(System.lineSeparator());
System.out.println(ConsoleColors.RED + "mainDiffTest: Exception TestCase Summary : Total Exceptions=" + MaxIndexExcept + " Exception Test Cases are:" + ConsoleColors.RESET);
for (int y = 0; y < MaxIndexExcept; y++) {
System.out.print(ConsoleColors.RED + " " + ExceptionTestCases.get(y) + ", " + ConsoleColors.RESET);
if ((y !=0)&&(y % 5 == 0)) {
System.out.print(System.lineSeparator());
}
}
System.out.print(System.lineSeparator());
}
public static int RegressionControl(int j) {
if ((j >= 100) && (j < 105)) {
j++;
} else if ((j >= 5019) && (j < 5042)) {
j++;
} else if ((j >= 10001) && (j < 10005)) {
j++;
} else if ((j >= 20001) && (j < 20092)) {
j++;
} else if ((j >= 30001) && (j < 30011)) {
j++;
} else if ((j >= 40001) && (j < 40034)) {
j++;
}else if ((j >= 50001) && (j < 50029)) {
j++;
}else if( (j >= 80001) && (j < 80012)){
j++;
} else if( (j >= 110001) && (j < 110007)){
j++;
} else if (j == 90001) {
j = 100001;
}else if (j == 100001) {
j = 110001;
}else if (j == 110007) {
j = 120001;
}
// else if ((j >= 90001) && (j < 90002)) {
// j++;
// } else if ((j >= 100001) && (j < 100002)) {
// j++;
// }
//Bypass Gaps Section
else if ((j < 100)) {
j = 100;
}else if ((j == 105)) {
j = 5019;
}else if (j == 5042) {
j = 10001;
} else if (j == 10005) {
j = 20001;
} else if (j == 20092) {
j = 30001;
} else if (j == 30011) {
j = 40001;
}else if (j == 40034) {
j = 50001;
}else if (j == 50029) {
j = 80001;
} else if (j == 80012) {
j = 90001;
}
else {
System.out.println(ConsoleColors.RED + "RegressionControl:j= " + j + ": Infinite Loop" + ConsoleColors.RESET);
}
return j;
}
public static void mainRegressionIntegrTest(int MaxOrder, TestHarness TestData) {
String Exprn = "";
Map<String, Double> variables = new HashMap<>();
Map<String, String> variablesDiff = new HashMap<>();
//String Exprn = eatAll(TestCases(), ' ');
//String Exprn = eatAll(HighLevelUnitTestCases(), ' ');
//String Exprn = eatAll(FailingHighLevelUnitTestCases(), ' ');
//String Exprn = eatAll(FailingLowLevelUnitTestCases(), ' ');
//Exprn = eatAll(Exprn, ' ');
SimpleExpression expSimple;
Expression expValue;
IntegrExpr exp;
OrderVar expOrder;
MyFuncExpress();
MyFuncDiff();
MyFuncSimple();
MyFuncIntegr();
String Constant = "C";
//String DiffWithRespTo = "Xn";
String StrexpSimpleExpressMap1 = "";
String StrexpDiffExpress = "";
String StrexpSimpleExpressMap2 = "";
String myOrder = "";
double ExprnexpValue = 0;
double DblexpValueMap1 = 0;
double DblexpDiffValue = 0;
double DblexpValueMap2 = 0;
int j = TestCase;
boolean TestCasePassStrFlag = false;
boolean TestCasePassValFlag = false;
boolean TestCasePassHighLevelFlag = true;
HashMap<Integer, String> FailedTestCases = new HashMap<Integer, String>();
HashMap<Integer, String> ExceptionTestCases = new HashMap<Integer, String>();
int MaxIndexFail = 0;
int MaxIndexExcept = 0;
int MaxOrder1 = MaxOrder;
int i = 1;
int TotalTestCases=0;
String OverallRegressionStatus = "Integral:"
+ "\n" + "TestCases:Unit Test Cases" + " 24"
+ "\n" + "TestCases:Names "
+ "\n" + "TestCases:Coefficients " + " 20016, 20017 "
+ "\n" + "TestCases:Exponent " + " 30002 to 30008";
System.out.print(ConsoleColors.BLUE + "Integral Overall Regression Status =" + OverallRegressionStatus + ConsoleColors.RESET);
System.out.print(System.lineSeparator());
if(EndTestCase > LastTestCaseHarness)
EndTestCase=LastTestCaseHarness;
while (j <= EndTestCase) {
EqnUnderTest = "";
String TempExprn = "";
TempExprn = FailingTestHarnessDiff("mainIntegrTest",j);
if (MaxOrder == -1) {
MaxOrder1 = MaxIntegreOrder; //From Test Case
} else if (MaxOrder > MaxIntegreOrder) {
MaxOrder1 = MaxIntegreOrder;
} else {
MaxOrder1 = MaxOrder;
}
if ((!EqnUnderTest.equalsIgnoreCase("")) && (TempExprn != null) && (!TempExprn.equalsIgnoreCase(""))) {
Exprn = eatAll(TempExprn, ' ');
} else {
j = RegressionControl(j);
System.out.println(ConsoleColors.RED + "mainIntegrTest: j=" + j + " TestCase=" + TestCase);
continue;
}
System.out.println(ConsoleColors.BLUE + "Test Case " + TestCase + " Exprn=" + Exprn + ConsoleColors.RESET);
System.out.println(ConsoleColors.BLUE + "Test Case Name=" + TestCaseName + ConsoleColors.RESET);
System.out.println(ConsoleColors.BLUE + "Test Case Name=" + TestCaseMatrixID + ConsoleColors.RESET);
System.out.println(ConsoleColors.BLUE + "Integral Regression Status : Test Case should be " + EqnRegressionIntegreStatus + ConsoleColors.RESET);
i = 1;
TotalTestCases++;
TestCasePassHighLevelFlag=true;
String StageMapping = "";
variablesDiff.put(DiffWithRespTo, DiffWithRespTo);
try {
for (double x = 1, y = 7; i < MaxOrder1; y++, /*x++,*/ i++) {
TestCasePassStrFlag = false;
TestCasePassValFlag = false;
variables.put(DiffWithRespTo, x);
variables.put("y", y);
variables.put("a", 1.0);
variables.put("b", 2.0);//variables.put("b", 0.0);
variables.put("c", -1.0);
variables.put("d", 2.0);
variables.put("p", 1.0);
variables.put("q", 0.0);
variables.put("r", -1.0);
variables.put("s", 2.0);
variables.put(Constant, 5.0);
StageMapping = "Basic Mapping";
expOrder = parseOrder(Exprn, DiffWithRespTo);
myOrder = expOrder.eval();
System.out.println("main: " + DiffWithRespTo + "=" + x + " Exprn=" + Exprn + " Order=" + myOrder);
expSimple = parseSimple(Exprn, variables, variablesDiff, DiffWithRespTo);
StrexpSimpleExpressMap1 = expSimple.SimpleExpr();
System.out.println("main: " + DiffWithRespTo + "=" + x + " Basic Simple Exprn=" + StrexpSimpleExpressMap1);
expValue = parse(StrexpSimpleExpressMap1, variables, DiffWithRespTo);
ExprnexpValue = expValue.eval();
System.out.println(" main:Result(Expn Value)=" + ExprnexpValue);
expValue = parse(StrexpSimpleExpressMap1, variables, DiffWithRespTo);
DblexpValueMap1 = expValue.eval();
System.out.println("main: " + DiffWithRespTo + "=" + x + " Basic Simple (Exprn Value)=" + DblexpValueMap1);
StageMapping = "Integration";
exp = parseIntegr(StrexpSimpleExpressMap1, variables, variablesDiff, DiffWithRespTo);
StrexpDiffExpress = exp.IntegrExpr();
System.out.println(" main:Result(Integral Equation)(" + i + " th order)=> " + StrexpDiffExpress);
StageMapping = "Integration Mapping";
expSimple = parseSimple(StrexpDiffExpress, variables, variablesDiff, DiffWithRespTo);
StrexpSimpleExpressMap2 = expSimple.SimpleExpr();
System.out.println(" main:Result(Simplified Integral Equation)(" + i + " th order)=> " + StrexpSimpleExpressMap2);
expValue = parse(StrexpDiffExpress, variables, DiffWithRespTo);
DblexpDiffValue = expValue.eval();
System.out.println("main: " + DiffWithRespTo + "=" + x + " Result(Integral Value)=" + DblexpDiffValue);
expValue = parse(StrexpSimpleExpressMap2, variables, DiffWithRespTo);
DblexpValueMap2 = expValue.eval();
System.out.println("main: " + DiffWithRespTo + "=" + x + " Result(Simplified Integral Value)=" + expValue.eval());
System.out.print(System.lineSeparator());
if (PassFailTestCaseString(TestCase, i, "Integre" , Exprn, StrexpSimpleExpressMap1, StrexpDiffExpress, StrexpSimpleExpressMap2, EqnUnderTest, EqnSolArrayMap3[i], EqnSolArrayIntegrAlone[i], EqnSolArrayMap4[i])) {
System.out.println(ConsoleColors.GREEN + " main:Test Case Status=" + "Pass STRING TEST Complete" + ConsoleColors.RESET);
TestCasePassStrFlag = true;
} else {
System.out.println(ConsoleColors.RED + " main:Test Case Status=" + "FAIL STRING TEST Complete" + ConsoleColors.RESET);
if(TestCasePassHighLevelFlag==true)
TestCasePassHighLevelFlag=false;
}
if (PassFailTestCaseValue(TestCase, i, "Integre" , Exprn, ExprnexpValue, DblexpValueMap1, DblexpDiffValue, DblexpValueMap2,variables)) {
System.out.println(ConsoleColors.GREEN + " main:Test Case Status=" + "Pass VALUE TEST Complete" + ConsoleColors.RESET);
TestCasePassValFlag = true;
} else {
System.out.println(ConsoleColors.RED + " main:Test Case Status=" + "FAIL VALUE TEST Complete" + ConsoleColors.RESET);
if(TestCasePassHighLevelFlag==true)
TestCasePassHighLevelFlag=false;
}
Exprn = StrexpSimpleExpressMap2;
System.out.print(System.lineSeparator());
if ((TestCasePassStrFlag == true) && (TestCasePassValFlag == true))
;//Do Nothing : Test Case Passed
else {
String Temp = FailedTestCases.get(MaxIndexFail);
String HashVal = "";
if ((Temp != null) && (!Temp.equalsIgnoreCase(""))) {
HashVal = Temp + "," + ":Order=" + (i ) + ":Str=" + TestCasePassStrFlag + ":Val=" + TestCasePassValFlag;
} else {
HashVal = "TestCase=" + TestCase + ":Order=" + (i ) + ":Str=" + TestCasePassStrFlag + ":Val=" + TestCasePassValFlag;
}
FailedTestCases.put(MaxIndexFail, HashVal);
//i=MaxOrder1;
}
}
} catch (Exception MyException) {
System.out.print(System.lineSeparator());
System.out.print(System.lineSeparator());
MyException.printStackTrace();
System.out.println(ConsoleColors.RED + "TestCase " + TestCase + " Failed at Order=" + i + " due to Exception at Stage=" + StageMapping + "." + ConsoleColors.RESET);
System.out.print(System.lineSeparator());
String Temp = FailedTestCases.get(MaxIndexFail);
String HashVal = "";
if ((Temp != null) && (!Temp.equalsIgnoreCase(""))) {
HashVal = Temp + "," + ":Order=" + (i ) + ":Str=" + TestCasePassStrFlag + ":Val=" + TestCasePassValFlag;
} else {
HashVal = "TestCase=" + TestCase + ":Order=" + (i ) + ":Str=" + TestCasePassStrFlag + ":Val=" + TestCasePassValFlag;
}
FailedTestCases.put(MaxIndexFail, HashVal);
String Temp1 = ExceptionTestCases.get(MaxIndexExcept);
String HashVal1 = "";
if ((Temp1 != null) && (!Temp1.equalsIgnoreCase(""))) {
HashVal1 = Temp1 + "," + ":Order=" + (i ) ;
} else {
HashVal1 = "TestCase=" + TestCase + ":Order=" + (i ) ;
}
ExceptionTestCases.put(MaxIndexExcept, HashVal);
MaxIndexExcept++;
i=MaxOrder1;
TestCasePassHighLevelFlag=false;
}
System.out.print(System.lineSeparator());
if (TestCaseLoopTimes == 1) {
break;
} else {
j = RegressionControl(j);
}
if (TestCasePassHighLevelFlag==false) MaxIndexFail++;
}
for(int a=0; a < 10; a++)
System.out.print(System.lineSeparator());
System.out.println(ConsoleColors.RED + "mainIntegrTest: TestCase Summary : Total Failed=" + MaxIndexFail + " Out of Run TestCases=" + TotalTestCases + " Failed Test Cases are:" + ConsoleColors.RESET);
for (int y = 0; y < MaxIndexFail; y++) {
System.out.print(ConsoleColors.RED + " " + FailedTestCases.get(y) + ", " + ConsoleColors.RESET);
if ((y !=0)&&(y % 5 == 0)) {
System.out.print(System.lineSeparator());
}
}
System.out.print(System.lineSeparator());
System.out.println(ConsoleColors.RED + "mainIntegrTest: Exception TestCase Summary : Total Exceptions=" + MaxIndexExcept + " Exception Test Cases are:" + ConsoleColors.RESET);
for (int y = 0; y < MaxIndexExcept; y++) {
System.out.print(ConsoleColors.RED + " " + ExceptionTestCases.get(y) + ", " + ConsoleColors.RESET);
if ((y !=0)&&(y % 5 == 0)) {
System.out.print(System.lineSeparator());
}
}
System.out.print(System.lineSeparator());
}
public static void mainUser(String... args) {
System.out.println(ConsoleColors.BLUE + "Differentiation / Integration:" + ConsoleColors.RESET);
String TechDiffWithRespTo=DiffWithRespTo;
String xExprn = "Enter*Your*Equation/Here:x^2+25:";
Scanner scanner = new Scanner(System.in);
System.out.print(xExprn);
xExprn=scanner.nextLine();
xExprn = eatAll(xExprn, ' ');
System.out.print("You Entered Equation:Example:x^2+25:"+xExprn);
System.out.print(System.lineSeparator());
System.out.print("DiffWithRespTo:[" + TechDiffWithRespTo+"]:");
TechDiffWithRespTo=scanner.nextLine();
if(TechDiffWithRespTo.equalsIgnoreCase(""))
TechDiffWithRespTo=DiffWithRespTo;
//TechDiffWithRespTo = eatAll(TechDiffWithRespTo, ' ');
if (xExprn.contains(TechDiffWithRespTo)) {
System.out.print("You Entered Primary Variable:"+TechDiffWithRespTo);
System.out.print(System.lineSeparator());
}
else {
System.out.println("You Entered Equation:"+xExprn);
System.out.println("You Entered Primary Variable:"+TechDiffWithRespTo + " but Equation entered does not contain " + TechDiffWithRespTo);
System.out.println("Proceeding with Entered Values");
}
System.out.print("Diff And Integration Order:");
String Temp=scanner.nextLine();
int TechDiffOrder=2;
if (!Temp.equalsIgnoreCase(""))
TechDiffOrder=Integer.parseInt(Temp);
System.out.print("You Entered Diff And Integration Order:"+(TechDiffOrder));
System.out.print(System.lineSeparator());
System.out.println(ConsoleColors.BLUE + "Differentiation Started:" + ConsoleColors.RESET);
UserDiff( xExprn, "mainUser", TechDiffOrder, TechDiffWithRespTo) ;
System.out.print(System.lineSeparator());
System.out.print(System.lineSeparator());
System.out.print(System.lineSeparator());
System.out.println(ConsoleColors.BLUE + "Integration Started:" + ConsoleColors.RESET);
UserIntegr( xExprn, "mainUser", TechDiffOrder, TechDiffWithRespTo) ;
}
public static String UserDiff(String Exprn, String AlgoName, int TechDiffOrder, String TechDiffWithRespTo) {
Map<String, Double> variables = new HashMap<>();
Map<String, String> variablesDiff = new HashMap<>();
MyFuncExpress();
MyFuncDiff();
MyFuncSimple();
SimpleExpression expSimple;
Expression expValue;
String StrexpSimpleExpress = "";
String StrexpDiffExpress = "";
int TechDiffOrderIndex = 1;
expValue = parse(Exprn, variables, TechDiffWithRespTo);
for (; (TechDiffOrderIndex <= TechDiffOrder) ; TechDiffOrderIndex++) {
variables.put(TechDiffWithRespTo, 1.0);
expSimple = parseSimple(Exprn, variables, variablesDiff, TechDiffWithRespTo);
StrexpSimpleExpress = expSimple.SimpleExpr();
System.out.println("UserDiff: TechDiffWithRespTo=" + TechDiffWithRespTo + " Basic Simple Exprn=" + StrexpSimpleExpress);
DiffExpr exp = parseDiff(StrexpSimpleExpress, variables, variablesDiff, TechDiffWithRespTo);
StrexpDiffExpress = exp.DiffExpr();
System.out.println("UserDiff:Result(Diff Equation)(" + TechDiffOrderIndex + " th order)=> " + StrexpDiffExpress);
expSimple = parseSimple(StrexpDiffExpress, variables, variablesDiff, TechDiffWithRespTo);
StrexpSimpleExpress = expSimple.SimpleExpr();
System.out.println("UserDiff: TechDiffWithRespTo=" + TechDiffWithRespTo + " Basic Simple Exprn=" + StrexpSimpleExpress);
expValue = parse(StrexpSimpleExpress, variables, TechDiffWithRespTo);
System.out.println("UserDiff:Result(Value)(" + TechDiffWithRespTo + "=" + variables.get(TechDiffWithRespTo) + ")=" + expValue.eval());
Exprn = StrexpSimpleExpress;
}
return StrexpSimpleExpress;
}
public static String UserIntegr(String Exprn, String AlgoName, int TechDiffOrder, String TechDiffWithRespTo) {
Map<String, Double> variables = new HashMap<>();
Map<String, String> variablesDiff = new HashMap<>();
MyFuncExpress();
MyFuncDiff();
MyFuncSimple();
variablesDiff.put(TechDiffWithRespTo, TechDiffWithRespTo);
SimpleExpression expSimple;
Expression expValue;
IntegrExpr exp;
String StrexpSimpleExpress = "";
String StrexpDiffExpress = "";
int TechDiffOrderIndex = 1;
expValue = parse(Exprn, variables, TechDiffWithRespTo);
for (; (TechDiffOrderIndex <= TechDiffOrder) ; TechDiffOrderIndex++) {
variables.put(TechDiffWithRespTo, 1.0);
expSimple = parseSimple(Exprn, variables, variablesDiff, TechDiffWithRespTo);
StrexpSimpleExpress = expSimple.SimpleExpr();
System.out.println("UserIntegr: TechDiffWithRespTo=" + TechDiffWithRespTo + " Basic Simple Exprn=" + StrexpSimpleExpress);
exp = parseIntegr(StrexpSimpleExpress, variables, variablesDiff, TechDiffWithRespTo);
StrexpDiffExpress = exp.IntegrExpr();
System.out.println("UserIntegr:Result(Integr Equation)(" + TechDiffOrderIndex + " th order)=> " + StrexpDiffExpress);
expSimple = parseSimple(StrexpDiffExpress, variables, variablesDiff, TechDiffWithRespTo);
StrexpSimpleExpress = expSimple.SimpleExpr();
System.out.println("UserIntegr: TechDiffWithRespTo=" + TechDiffWithRespTo + " Basic Simple Exprn=" + StrexpSimpleExpress);
expValue = parse(StrexpSimpleExpress, variables, TechDiffWithRespTo);
System.out.println("UserIntegr:Result(Value)(" + TechDiffWithRespTo + "=" + variables.get(TechDiffWithRespTo) + ")=" + expValue.eval());
Exprn = StrexpSimpleExpress;
}
return StrexpSimpleExpress;
}
public static void mainAlgebraUser(String... args){
Map<String, Double> variables = new HashMap<>();
Map<String, String> variablesDiff = new HashMap<>();
String StrexpSimpleExpress = "";
SimpleExpression expSimple;
String FuncF="x^2+25";
String FuncG="2*x+98";
//SimpleAlgebra F;
SimpleAlgebraHghLvl F;
FoG FuncComp;
//FoGLowLvL FuncComp;
String TechDiffWithRespTo=DiffWithRespTo;
System.out.println(ConsoleColors.BLUE + "Algebra / Function Composition:" + ConsoleColors.RESET);
System.out.print("Enter*Your* First Equation/Here:x^2+25:");
Scanner scanner = new Scanner(System.in);
FuncF=scanner.nextLine();
FuncF = eatAll(FuncF, ' ');
System.out.println("You Entered First Equation:Example:x^2+25:"+FuncF);
System.out.print(System.lineSeparator());
System.out.print("Enter*Your* Second Equation/Here:x^2+25:");
FuncG=scanner.nextLine();
FuncG = eatAll(FuncG, ' ');
System.out.println("You Entered Second Equation:Example:x^2+25:"+FuncG);
System.out.print(System.lineSeparator());
System.out.print("DiffWithRespTo:[" + TechDiffWithRespTo+"]:");
TechDiffWithRespTo=scanner.nextLine();
if(TechDiffWithRespTo.equalsIgnoreCase(""))
TechDiffWithRespTo=DiffWithRespTo;
TechDiffWithRespTo = eatAll(TechDiffWithRespTo, ' ');
if ((FuncF.contains(TechDiffWithRespTo))&&(FuncF.contains(TechDiffWithRespTo))) {
System.out.print("You Entered Primary Variable:"+TechDiffWithRespTo);
System.out.print(System.lineSeparator());
}
else {
System.out.println("You Entered First Equation:"+FuncF);
System.out.println("You Entered Second Equation:"+FuncG);
System.out.println("You Entered Primary Variable:"+TechDiffWithRespTo + " but Equation entered does not contain " + TechDiffWithRespTo);
System.out.println("Proceeding with Entered Values");
}
//F=parseAlgebra(FuncF, FuncG, "*", variables, TechDiffWithRespTo);