-
Notifications
You must be signed in to change notification settings - Fork 1
/
MathsContxtLAv0_1_Prod.java
10617 lines (10227 loc) · 697 KB
/
MathsContxtLAv0_1_Prod.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 DOEMatrixGen;
import static DOEMatrixGen.Usage.mainRegresssionDiffTest;
import static DOEMatrixGen.Usage.mainRegressionIntegrTest;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.HashMap;
import java.util.Map;
import java.util.function.DoubleUnaryOperator;
import org.apache.log4j.Logger;
/**
*
* @author Rajesh V Pai
*/
/*
* Version :6.0 (Backup Version:Ver 20.0.3)
* Fully Functional Simple Expression Mapping & Differentiation
*
* Notes:
* Constants, Factors (x alone term) and Polynomials of x
* Simple Expression reduces x^0.0 & x^1.0, 5^1.0 , 5^0.0
* Whole Program (Simple Expression & Differentiation)Unit Test Cases are passing
* 1)Known Issues:
* a)(Constant in braces)*Function does not work for Simple Expression & DiffExpr
* ://String Exprn = "7.0*x^6.0+5.0*x^4.0+2.0*x^1.0+(21.0)*sin(21.0*x)+ 25.0";
* b)0.0*Function is not being reduced in Simple Expression & DiffExpr
* ://String Exprn = "7.0*x^6.0+5.0*x^4.0+2.0*x^1.0+0.0*cos(37.0)+7.0";
* c)Higher Order cos function fails as there is a (-1.0)* to sin function in
* the mapping Hash Map variablesDiff (line 149) in function (MyFuncDiff()).
* ://String Exprn = "+0.0*(-1.0)*sin(37.0)";
* d)Addition in function argument does not work
* ://String Exprn = "x^7 + x^5 + x^2 - sin(37+7.0*x) + 25.0";
*
*
* 2) Release Notes:
* a) Simple Expression does not work with Trailing Constants
* b) Functions work if not at the end of String Expression else we get a Parse Error
* due to "\n\r" mapping at the end of a string (pos will be <= str.length)
* c) Public interface ConstAddSubExprn has been added to remove trailing 0.0 or 1.0 etc.
* These need to be expanded to Generic Aggragators of like exponent Terms
* (e.g add all the x terms , all the constants etc placed any where in the Equation)
* d) Does not work with Palindromic Equations:
* String Exprn = " 25.0 + x - x^4 -x^5 -x^8 + x^8 + x^5 + x^4 - x - 25.0";
* Power of x has to decrease from Left to Right with Constant at the end.
* Same Equation with Terms Re-arranged works.
String Exprn = " x^8 - x^8 + x^5 -x^5 + x^4 - x^4 - x + x - 25.0 + 25.0";
* e) Equations cannot start with "-" Term as first term.
String Exprn = " -x^8 + x^8 + x^5 -x^5 + x^4 - x^4 - x + x - 25.0 + 25.0";
* same Equation works with First Term Positive:
String Exprn = " +x^8 - x^8 + x^5 -x^5 + x^4 - x^4 - x + x - 25.0 + 25.0";
* f) Palindromic Equations can have just 1 constant Term:Below is not allowed
String Exprn = " x^8 - x^8 + x^5 -x^5 + x^4 - x^4 - x + x - 25.0 + 20.0";
Below Palindromic Equation works:(Constants must be pre calculated and then put in the equation)
String Exprn = " x^8 - x^8 + x^5 -x^5 + x^4 - x^4 - x + x - 5.0";
* 3) Untested:
* a) Independent Variable (e.g z,a,c,xyz)
* b) Functions (Sine, Cos etc)
* c) Parenthesis
*
* 4) Discovery:
* a) First Order Diff for Functions & Parenthesis works.
* b) Simple Expression drops constants in Parenthesis e.g:sin(1+2.0*x)=sin(2.0*x)
* c) Diff needs Simple Expression to work with Trailing Constants (sin(2x)=cos(2x)*2: F'(u)= F'(x)*du/dx
*/
// Taken from stackoverflow.com (Expression):Evaluating a math
// expression with variables (java 8):Created by StackOverflow User:Boann
// Taken from stackoverflow.com:Evaluating a math
// expression given in string form [closed]
//http://stackoverflow.com/questions/3422673/evaluating-a-math-expression-given-in-string-form
// Taken from stackoverflow.com (Expression):Evaluating a math
// expression with variables (java 8) Created by User :Mike Scholtes
//http://stackoverflow.com/questions/40975678/evaluating-a-math-expression-with-variables-java-8
public class MathsContxtLAv0_1_Prod {
public static Logger log = Logger.getLogger( MathsContxtLAv0_1_Prod.class.getName());
static Map<String, Double> variables = new HashMap<>();
private static Map<String, DoubleUnaryOperator> functions = new HashMap<>();
private static Long[] PrimeArray = new Long[10000];
private static int LastIndex = 1;
static String BC_SplitterDiff = "[\\^\\(\\/\\*\\-\\+\\)]";
static Map<String, String> variablesDiff = new HashMap<>();
static Map<String, String> variablesIntegr = new HashMap<>();
private static Map<String, String> functionsDiff = new HashMap<>();
private static Map<String, String> functionsSimple = new HashMap<>();
private static Map<String, String> functionsIntegr = new HashMap<>();
// Maximum number of Double Fractional Digits displayed in Equation
private static int MaximumFractionDigits = 25;
// Maximum number of Integer Digits displayed in Equation
private static int MaximumIntegerDigits = 50;
private static enum HighLevelContext {
Null, Expression, Operand, Factor, Base, End, Sign, Function, Variable, FunctionArgument, Numbers, ParaExpression, ParenthesisOpen, ParenthesisClose, DiffWithRespTo
}
private static enum LowLevelOperator {
Null, Plus, Minus, Mult, Div, Expnt, End, ParenthesisOpen, ParenthesisClose, SignMinus, SignPlus, FuncNvar, Numbers, Function, Variable, Compact
}
private static enum MixedLevelDiffContext {
Null, Diff, StringTerm, Constant, End, Sign,
}
private static enum HighLevelRules {
Null, End,
ConstantRule,// (af)' = af'
SumRule, // (f + g)' = f' + g'
SubractionRule, // (f-g)' = f' - g'
ProductRule, //(f(x)*(g(x))' = f'*g(x) + f(x)*g'(x)
QuotientRule, // (f/g)'= (f'g -g'f)/(g*g):Can be derived from Product Rule
ExponentRule, // a*x^n = a*n*x^(n-1)
ParenthesisOpen,
ParenthesisClose,
FunctionRule,
TermRule
}
private static enum LowLevelRules {
Null, Plus, Minus, Mult, Div, Expnt, End, ParenthesisOpen, ParenthesisClose, SignMinus, SignPlus, FuncNvar, Numbers, Function, Variable
}
private static int LookNum = 5;
private static String[] LookAheadString = new String[LookNum * 5];
private static HighLevelContext[] LookAheadCntxt = new HighLevelContext[LookNum];
private static LowLevelOperator[] LookAheadOp = new LowLevelOperator[LookNum];
private static MixedLevelDiffContext[] LookAheadDiffCntxt = new MixedLevelDiffContext[LookNum];
private static HighLevelRules[] LookAheadHighRules = new HighLevelRules[LookNum];
private static LowLevelRules[] LookAheadLowRules = new LowLevelRules[LookNum];
static int LookAhead_Oppos = 0;
static int LookAhead_Stringpos = 0;
static int LookAhead_Cntxtpos = 0;
static int LookAhead_LowRulespos = 0;
static int LookAhead_HighRulespos = 0;
// Simple Expression & Simple Term character Index and Character Variable
private static int pos = -1, ch;
private static int chNext, chTerm, posTerm = -1;
private static String Str;
//LAConstDiff Expression character Index and Character Variable
private static int posLADiff = -1, chLADiff;
private static String StrLADiff;
//Diff Expression character Index and Character Variable
private static int posDiff = -1, chDiff;
private static String StrDiff;
//Diff Expression character Index and Character Variable
private static int posIntegr = -1, chIntegr;
private static String StrIntegr;
// Algebra & AlgebraTerm character Index and Character Variable
private static int posFunF = -1, chFunF,posFunFLocal=-1;
private static int posFunG = -1, chFunG,posFunGLocal=-1;
private static int chAlgeTerm, posAlgeTerm = -1;
private static String StrFunF;
private static String StrFunG;
private static String StrAlgeTerm;
private static int posLA = -1, chLA;
private static int posVar = -1, chVar;
private static int posSign = -1, chSign, chTermSign;
private static int posOrder = -1, chOrder;
private static int posBraces = -1, chBraces;
private static int posIndConst = -1, chIndConst;
private static int SavedOperator = 0;
private static int ParenthesisOperator = 0;
private static int LookAheadOperator = 0;
private static int loadstringpos = 0;
private static int loadoppos = 0;
private static int loadCntxtpos = 0;
private static int LookAheadVariable = 0;
private static String StrTerm;
private static String StrSign;
private static String StrLA;
private static String StrVar;
private static String StrIndConst;
private static String StrOrder;
private static String StrBraces;
private static int NumCoeff = 0;
private static int CoeffCoeff = 0;
//Global Common Flags for each Interface
private static boolean ParenthesisFlag = false;
private static boolean NormalNotPareFlag = true;
private static boolean FuncArgFlag = false;
private static boolean ParanExprFlag = false;
private static boolean NormalExprnFlag = true;
private static int ParenthesisHighLvlNum = 0;
private static int ParenthesisCurrNum = 0;
private static boolean NegateGotFlag = false;
// SimpleTerm Interface Variables
private static boolean ComplexAssignFlag = false;
private static boolean GotVariableFlag = false;
private static int GotVariablePos = 0;
private static boolean GotExpntNumFlag = false;
private static int TermOperatorPos = -1;
private static double TermOutput = 0.0;
private static double TermOutputIndConst = 0.0;
private static boolean GotIndConstFlag = false;
private static int GotIndConstPos = 0;
private static String TempIndConstBase = "";
private static boolean TempIndConstStrSet = false;
private static boolean TrailConstantFlag = false;
private static int TrailConstantOperator = -1;
private static int timesLoop = 0;
private static boolean ContainsIndConstFlag = false;
private static boolean TermOutputSetFlag = false;
private static int LATermOperatorBraces = -1;
private static int LAPreTermOperator = -1;
private static int LATermOperator = -1;
private static int LAVarTermOperator = -1;
private static int LAPreIndConstOperator = -1;
private static int LAIndConstOperator = -1;
private static int LAMAPOperator = -1;
private static int LADyYByDxMAPOperator = -1;
private static boolean LAVarSimpleMapFlag = false;
private static boolean LAVarComplexMapFlag = false;
private static int LADiffTermOperator = -1;
private static int LADiffFactorOperator = -1;
private static int LADiffIndConstOperator = -1;
private static String LastInvokedFlag = "";
private static int LastInvokedPos = -1;
private static int LastLADiffIndConstAidPos = -1;
private static int LastLADiffConstCoeffAidPos = -1;
private static boolean ParseMapposModFlag = false;
private static boolean ZeroTermSignFlag = false;
// Maximum Order of the Term or Expression
private static double MaxTermOutput = 0.0;
private static String FunctionStr = "";
//IsAConstant Return Type
private static String StrIsAConstant = "";
//Function Argument Flag
private static boolean GotBracesVarFlag = false;
// Diff Interface Variables
private static String FactorsExpr = "";
private static String FactorsDiffExpr = "";
private static String FunctionExpr = "";
private static String FunctionDiffExpr = "";
private static String ParanExpr = "";
private static String ParanDiffExpr = "";
public static void MyFuncExpress() {
functions.put("sqrt", x -> Math.sqrt(x));
functions.put("sin", x -> Math.sin(Math.toRadians(x)));
functions.put("cos", x -> Math.cos(Math.toRadians(x)));
functions.put("tan", x -> Math.tan(Math.toRadians(x)));
functions.put("round", x -> Math.round(x));
functions.put("abs", x -> Math.abs(x));
functions.put("ceil", x -> Math.ceil(x));
functions.put("floor", x -> Math.floor(x));
functions.put("log", x -> Math.log(x));
functions.put("exp", x -> Math.exp(x));
//TODO:More Unary Functions to be added
}
public static void MyFuncDiff() {
functionsDiff.put("sin", "cos");
functionsDiff.put("cos", "-sin");
functionsDiff.put("tan", "sec^2.0");
functionsDiff.put("log", "log");
functionsDiff.put("exp", "exp");
//TODO:More Differential Unary Functions to be added
}
public static void MyFuncSimple() {
functionsSimple.put("sin", "sin");
functionsSimple.put("cos", "cos");
functionsSimple.put("tan", "tan");
functionsSimple.put("log", "log");
functionsSimple.put("ln", "ln");
functionsSimple.put("exp", "exp");
//TODO:More Simple Unary Functions to be added
}
public static void MyFuncIntegr() {
functionsIntegr.put("sin", "-cos");
functionsIntegr.put("cos", "sin");
//functionsIntegr.put("tan", "sec^2.0");
//functionsIntegr.put("log", "log");
functionsIntegr.put("exp", "exp");
//TODO:More Differential Unary Functions to be added
}
static void nextChar() {
++pos;
ch = (pos < Str.length()) ? Str.charAt(pos) : -1;
//if (ch == -1) pos=Str.length();
}
static void prevChar() {
--pos;
ch = (pos >= 0) ? Str.charAt(pos) : -1;
}
static boolean eat(int CharToEat) {
while (ch == ' ') {
nextChar();
}
if (ch == CharToEat) {
nextChar();
return true;
}
return false;
}
static String eatAll(String Temp, int CharToEat) {
String MyTempString = "";
if (Temp.equalsIgnoreCase("")) {
Temp = Str;
}
for (int i = 0; (i < Temp.length());) {
if (CharToEat == Temp.charAt(i)) {
i++;
} else {
MyTempString = MyTempString + Temp.charAt(i);
i++;
}
}
return MyTempString;
}
static void nextCharDiff() {
++posDiff;
chDiff = (posDiff < StrDiff.length()) ? StrDiff.charAt(posDiff) : -1;
//if (chDiff == -1) posDiff=Str.length();
}
static void prevCharDiff() {
--posDiff;
chDiff = (posDiff >= 0) ? StrDiff.charAt(posDiff) : -1;
}
static boolean eatDiff(int CharToEat) {
while (chDiff == ' ') {
nextCharDiff();
}
if (chDiff == CharToEat) {
nextCharDiff();
return true;
}
return false;
}
static void nextCharIntegr() {
++posIntegr;
chIntegr = (posIntegr < StrIntegr.length()) ? StrIntegr.charAt(posIntegr) : -1;
//if (chDiff == -1) posDiff=Str.length();
}
static void prevCharIntegr() {
--posIntegr;
chIntegr = (posIntegr >= 0) ? StrIntegr.charAt(posIntegr) : -1;
}
static boolean eatIntegr(int CharToEat) {
while (chIntegr == ' ') {
nextCharIntegr();
}
if (chIntegr == CharToEat) {
nextCharIntegr();
return true;
}
return false;
}
static boolean FatalCharSet(int CurrChar, String CharSet) {
CharSequence Temp = "" + CurrChar;
if (!CharSet.contains(Temp)) {
return true;
}
return false;
}
static boolean loadparams(int mypos) {
int i = 0;
for (i = 0; i < LookAhead_Stringpos; i += 5) {
if (LookAheadString[i + 1].equalsIgnoreCase("" + mypos)) {
loadstringpos = i;
//loadoppos = Integer.parseInt(LookAheadString[i + 3]);
//loadCntxtpos = Integer.parseInt(LookAheadString[i + 4]);
return true;
}
}
return false;
}
static void ParseMap(String AlgoName, int strlength, int StartPos, int DiffLength, String DiffWithRespTo) {
if (AlgoName.equalsIgnoreCase("LookAheadVar:parseVar")) {
log.info("ParseMap:Initial:AlgoName=" + AlgoName + " pos=" + pos + " ch=" + (char) ch + " posTerm=" + posTerm + " chTerm=" + (char) chTerm + " posVar=" + posVar + " chVar=" + (char) chVar + " posLA=" + posLA + " chLA=" + (char) chLA);
log.info("ParseMap:Initial:AlgoName=" + AlgoName + " GotVariableFlag=" + GotVariableFlag + " ComplexAssignFlag=" + ComplexAssignFlag + " GotVariablePos=" + GotVariablePos + " TrailConstantFlag=" + TrailConstantFlag);
if (TrailConstantFlag == false) {
if (posVar < (StrVar.length())) {
posTerm = posVar + 1;
chTerm = chVar;
} else {
posTerm = -1;
chTerm = -1;
}
} else {
if ((TrailConstantFlag == true) && (GotVariableFlag == true) || (ComplexAssignFlag == true)) {
posLA = GotVariablePos;
if (posLA < StrVar.length()) {
posTerm = posLA;
chTerm = StrTerm.charAt(posTerm);
chLA = chTerm;
} else {
posTerm = -1;
chTerm = -1;
}
}
}
log.info("ParseMap:Final:AlgoName=" + AlgoName + " pos=" + pos + " ch=" + (char) ch + " posTerm=" + posTerm + " chTerm=" + (char) chTerm + " posVar=" + posVar + " chVar=" + (char) chVar + " posLA=" + posLA + " chLA=" + (char) chLA);
log.info("ParseMap:Final:AlgoName=" + AlgoName + " GotVariableFlag=" + GotVariableFlag + " ComplexAssignFlag=" + ComplexAssignFlag + " GotVariablePos=" + GotVariablePos + " TrailConstantFlag=" + TrailConstantFlag);
} else if (AlgoName.equalsIgnoreCase("LookAheadConst:parseLA")) {
log.info("ParseMap:Initial:AlgoName=" + AlgoName + " pos=" + pos + " ch=" + (char) ch + " posTerm=" + posTerm + " chTerm=" + (char) chTerm + " posVar=" + posVar + " chVar=" + (char) chVar + " posLA=" + posLA + " chLA=" + (char) chLA + " LATermOperator=" + (char) LATermOperator);
log.info("ParseMap:Initial:AlgoName=" + AlgoName + " GotVariableFlag=" + GotVariableFlag + " ComplexAssignFlag=" + ComplexAssignFlag + " GotVariablePos=" + GotVariablePos + " TrailConstantFlag=" + TrailConstantFlag);
if ((GotVariableFlag == true) || (ComplexAssignFlag == true)) {
posVar = GotVariablePos;
if ((posVar >= 0) && (posVar < StrLA.length())) {
chTerm = StrLA.charAt(posVar);
} else {
posTerm = -1;
chTerm = -1;
}
} else if (TrailConstantFlag == true) {
if (posLA < StrVar.length()) {
posTerm = posLA;
chTerm = StrTerm.charAt(posTerm);
chLA = chTerm;
} else {
posTerm = -1;
chTerm = -1;
}
}
log.info("ParseMap:Final:AlgoName=" + AlgoName + " pos=" + pos + " ch=" + (char) ch + " posTerm=" + posTerm + " chTerm=" + (char) chTerm + " posVar=" + posVar + " chVar=" + (char) chVar + " posLA=" + posLA + " chLA=" + (char) chLA + " LATermOperator=" + (char) LATermOperator);
log.info("ParseMap:Final:AlgoName=" + AlgoName + " GotVariableFlag=" + GotVariableFlag + " ComplexAssignFlag=" + ComplexAssignFlag + " GotVariablePos=" + GotVariablePos + " TrailConstantFlag=" + TrailConstantFlag);
} else if (AlgoName.equalsIgnoreCase("SimpleTerm:parseSimple")) {
log.info("ParseMap:Initial:AlgoName=" + AlgoName + " pos=" + pos + " ch=" + (char) ch + " posTerm=" + posTerm + " chTerm=" + (char) chTerm + " posVar=" + posVar + " chVar=" + (char) chVar + " posLA=" + posLA + " chLA=" + (char) chLA + " posSign=" + posSign + " chSign=" + (char) chSign);
if (((posSign) <= strlength) && (GotBracesVarFlag == false)) {
if (pos < 0) {
pos = (posSign);
ch = Str.charAt(pos);
log.info("ParseMap:Sign:Sign:<0:AlgoName=" + AlgoName);
} else if (pos + (posSign) < Str.length()) {
pos = pos + (posSign);
ch = Str.charAt(pos);
log.info("ParseMap:Sign:Sign:AlgoName=" + AlgoName);
} else if (((posVar >= 0) && (StrVar != null)) && (pos + (posVar) < Str.length())) {
pos = pos + (posVar);
ch = Str.charAt(pos);
log.info("ParseMap:Sign:LA:AlgoName=" + AlgoName);
} else if (((posVar >= 0) && (StrVar != null)) && (pos + (posVar) < Str.length())) {
pos = pos + (posVar);
ch = Str.charAt(pos);
log.info("ParseMap:Sign:Var:AlgoName=" + AlgoName);
} else {
pos = -1;
ch = -1;
}
chSign = ch;
chTerm = ch;
log.info("ParseMap:Sign:AlgoName=" + AlgoName + " pos=" + pos + " ch=" + (char) ch + " posTerm=" + posTerm + " chTerm=" + (char) chTerm + " posVar=" + posVar + " chVar=" + (char) chVar + " posLA=" + posLA + " chLA=" + (char) chLA + " posSign=" + posSign + " chSign=" + (char) chSign);
} else if ((pos + (posVar) < Str.length()) && (GotBracesVarFlag == true)) {
pos = pos + (posVar);
ch = Str.charAt(pos);
posTerm = -1;
chTerm = -1;
log.info("ParseMap:Var:AlgoName=" + AlgoName + " pos=" + pos + " ch=" + (char) ch + " posTerm=" + posTerm + " chTerm=" + (char) chTerm + " posVar=" + posVar + " chVar=" + (char) chVar + " posLA=" + posLA + " chLA=" + (char) chLA + " posSign=" + posSign + " chSign=" + (char) chSign);
} else {
pos = -1;
ch = -1;
posTerm = -1;
chTerm = -1;
log.info("ParseMap:Else:AlgoName=" + AlgoName + " pos=" + pos + " ch=" + (char) ch + " posTerm=" + posTerm + " chTerm=" + (char) chTerm + " posVar=" + posVar + " chVar=" + (char) chVar + " posLA=" + posLA + " chLA=" + (char) chLA + " posSign=" + posSign + " chSign=" + (char) chSign);
}
log.info("ParseMap:Final:AlgoName=" + AlgoName + " pos=" + pos + " ch=" + (char) ch + " posTerm=" + posTerm + " chTerm=" + (char) chTerm + " posVar=" + posVar + " chVar=" + (char) chVar + " posLA=" + posLA + " chLA=" + (char) chLA + " posSign=" + posSign + " chSign=" + (char) chSign);
} else if (AlgoName.equalsIgnoreCase("LookAheadSign:parseSign")) {
log.info("ParseMap:Initial:AlgoName=" + AlgoName + " pos=" + pos + " ch=" + (char) ch + " posTerm=" + posTerm + " chTerm=" + (char) chTerm + " posVar=" + posVar + " chVar=" + (char) chVar + " posLA=" + posLA + " chLA=" + (char) chLA + " chTermSign=" + (char) chTermSign + " chSign=" + (char) chSign + " strlength=" + strlength);
if ((strlength == -1) && (chTermSign == 0) && (chTerm == '+')) {
chTermSign = '-';
log.info("ParseMap:Rule1:AlgoName=" + AlgoName + " pos=" + pos + " ch=" + (char) ch + " posTerm=" + posTerm + " chTerm=" + (char) chTerm + " posVar=" + posVar + " chVar=" + (char) chVar + " posLA=" + posLA + " chLA=" + (char) chLA + " chTermSign=" + (char) chTermSign + " chSign=" + (char) chSign + " strlength=" + strlength);
} else if ((strlength == 1) && (chTermSign == 0) && (chTerm == '+')) {
chTermSign = '+';
log.info("ParseMap:Rule2:AlgoName=" + AlgoName + " pos=" + pos + " ch=" + (char) ch + " posTerm=" + posTerm + " chTerm=" + (char) chTerm + " posVar=" + posVar + " chVar=" + (char) chVar + " posLA=" + posLA + " chLA=" + (char) chLA + " chTermSign=" + (char) chTermSign + " chSign=" + (char) chSign + " strlength=" + strlength);
} else if ((strlength == 0) && (chSign == '+')) {
chTermSign = '+';
log.info("ParseMap:Rule3:AlgoName=" + AlgoName + " pos=" + pos + " ch=" + (char) ch + " posTerm=" + posTerm + " chTerm=" + (char) chTerm + " posVar=" + posVar + " chVar=" + (char) chVar + " posLA=" + posLA + " chLA=" + (char) chLA + " chTermSign=" + (char) chTermSign + " chSign=" + (char) chSign + " strlength=" + strlength);
} else if ((strlength == 0) && (chSign == '-')) {
chTermSign = '-';
log.info("ParseMap:Rule4:AlgoName=" + AlgoName + " pos=" + pos + " ch=" + (char) ch + " posTerm=" + posTerm + " chTerm=" + (char) chTerm + " posVar=" + posVar + " chVar=" + (char) chVar + " posLA=" + posLA + " chLA=" + (char) chLA + " chTermSign=" + (char) chTermSign + " chSign=" + (char) chSign + " strlength=" + strlength);
} //First Term Code for Sign Computation
else if ((strlength == 1) && (chTermSign == 0) && (pos == 0) && (chTerm == '-')) {
chTermSign = '-';
log.info("ParseMap:Rule5.1:First Term Rule:AlgoName=" + AlgoName + " pos=" + pos + " ch=" + (char) ch + " posTerm=" + posTerm + " chTerm=" + (char) chTerm + " posVar=" + posVar + " chVar=" + (char) chVar + " posLA=" + posLA + " chLA=" + (char) chLA + " chTermSign=" + (char) chTermSign + " chSign=" + (char) chSign + " strlength=" + strlength);
} else if ((strlength == 1) && (chTermSign == 0) && (pos == 0)) {
chTermSign = '+';
log.info("ParseMap:Rule5.2:First Term Rule:AlgoName=" + AlgoName + " pos=" + pos + " ch=" + (char) ch + " posTerm=" + posTerm + " chTerm=" + (char) chTerm + " posVar=" + posVar + " chVar=" + (char) chVar + " posLA=" + posLA + " chLA=" + (char) chLA + " chTermSign=" + (char) chTermSign + " chSign=" + (char) chSign + " strlength=" + strlength);
} //Last Term Code for Sign Computation
else if ((strlength == 1) && (chTermSign == 0) && (chTerm == '-')) {
chTermSign = '-';
log.info("ParseMap:Rule6:Last Term Rule:AlgoName=" + AlgoName + " pos=" + pos + " ch=" + (char) ch + " posTerm=" + posTerm + " chTerm=" + (char) chTerm + " posVar=" + posVar + " chVar=" + (char) chVar + " posLA=" + posLA + " chLA=" + (char) chLA + " chTermSign=" + (char) chTermSign + " chSign=" + (char) chSign + " strlength=" + strlength);
} else if (((chLA != 0) && (chLA != -1)) && (StrSign != null) && (!StrSign.equalsIgnoreCase("")) && (StartPos > 0) && ((StrSign.charAt(0) != '+') && (StrSign.charAt(0) != '-'))) {
chTermSign = chLA;
log.info("ParseMap:Rule7:Last Term Rule:AlgoName=" + AlgoName + " pos=" + pos + " ch=" + (char) ch + " posTerm=" + posTerm + " chTerm=" + (char) chTerm + " posVar=" + posVar + " chVar=" + (char) chVar + " posLA=" + posLA + " chLA=" + (char) chLA + " chTermSign=" + (char) chTermSign + " chSign=" + (char) chSign + " strlength=" + strlength);
} else if (((chVar != 0) && (chVar != -1)) && (StrSign != null) && (!StrSign.equalsIgnoreCase("")) && (StartPos > 0) && ((StrSign.charAt(0) != '+') && (StrSign.charAt(0) != '-'))) {
chTermSign = chVar;
log.info("ParseMap:Rule8:Last Term Rule:AlgoName=" + AlgoName + " pos=" + pos + " ch=" + (char) ch + " posTerm=" + posTerm + " chTerm=" + (char) chTerm + " posVar=" + posVar + " chVar=" + (char) chVar + " posLA=" + posLA + " chLA=" + (char) chLA + " chTermSign=" + (char) chTermSign + " chSign=" + (char) chSign + " strlength=" + strlength);
} //Middle Terms Code for Sign Computation
else if ((strlength == 1) && (chTermSign == 0) && (chTerm == '-') && (chSign != 0) & (chSign != -1)) {
chTermSign = '-';
log.info("ParseMap:Rule9:Middle Term Rule:AlgoName=" + AlgoName + " pos=" + pos + " ch=" + (char) ch + " posTerm=" + posTerm + " chTerm=" + (char) chTerm + " posVar=" + posVar + " chVar=" + (char) chVar + " posLA=" + posLA + " chLA=" + (char) chLA + " chTermSign=" + (char) chTermSign + " chSign=" + (char) chSign + " strlength=" + strlength);
} else if ((strlength == 1) && (chTermSign == 0) && (chTerm == '+')) {
chTermSign = '+';
log.info("ParseMap:Rule10:Middle Term Rule:AlgoName=" + AlgoName + " pos=" + pos + " ch=" + (char) ch + " posTerm=" + posTerm + " chTerm=" + (char) chTerm + " posVar=" + posVar + " chVar=" + (char) chVar + " posLA=" + posLA + " chLA=" + (char) chLA + " chTermSign=" + (char) chTermSign + " chSign=" + (char) chSign + " strlength=" + strlength);
} else if ((strlength == -1) && (chTermSign == 0) && (ch == '-') && (pos == 0)) {
chTermSign = '+';
log.info("ParseMap:Rule11:AlgoName=" + AlgoName + " pos=" + pos + " ch=" + (char) ch + " posTerm=" + posTerm + " chTerm=" + (char) chTerm + " posVar=" + posVar + " chVar=" + (char) chVar + " posLA=" + posLA + " chLA=" + (char) chLA + " chTermSign=" + (char) chTermSign + " chSign=" + (char) chSign + " strlength=" + strlength);
} else if ((strlength == -1) && (chTermSign == 0) && (ch == '-') && (chTerm == '-')) {
chTermSign = '+';
log.info("ParseMap:Rule12:AlgoName=" + AlgoName + " pos=" + pos + " ch=" + (char) ch + " posTerm=" + posTerm + " chTerm=" + (char) chTerm + " posVar=" + posVar + " chVar=" + (char) chVar + " posLA=" + posLA + " chLA=" + (char) chLA + " chTermSign=" + (char) chTermSign + " chSign=" + (char) chSign + " strlength=" + strlength);
} else if ((strlength == -1) && (chTermSign == 0)) {
chTermSign = '-';
log.info("ParseMap:Rule13:Last Term Rule:AlgoName=" + AlgoName + " pos=" + pos + " ch=" + (char) ch + " posTerm=" + posTerm + " chTerm=" + (char) chTerm + " posVar=" + posVar + " chVar=" + (char) chVar + " posLA=" + posLA + " chLA=" + (char) chLA + " chTermSign=" + (char) chTermSign + " chSign=" + (char) chSign + " strlength=" + strlength);
} else if ((strlength == 1) && (chTerm == '-')) {
chTermSign = '-';
log.info("ParseMap:Rule14:Last Term Rule:AlgoName=" + AlgoName + " pos=" + pos + " ch=" + (char) ch + " posTerm=" + posTerm + " chTerm=" + (char) chTerm + " posVar=" + posVar + " chVar=" + (char) chVar + " posLA=" + posLA + " chLA=" + (char) chLA + " chTermSign=" + (char) chTermSign + " chSign=" + (char) chSign + " strlength=" + strlength);
}
if ((chTermSign == 0) && (strlength == -1)) {
chTermSign = '-';
log.info("ParseMap:Rule15:Last Term Rule:AlgoName=" + AlgoName + " pos=" + pos + " ch=" + (char) ch + " posTerm=" + posTerm + " chTerm=" + (char) chTerm + " posVar=" + posVar + " chVar=" + (char) chVar + " posLA=" + posLA + " chLA=" + (char) chLA + " chTermSign=" + (char) chTermSign + " chSign=" + (char) chSign + " strlength=" + strlength);
} else if ((chTermSign == 0) && (strlength == 1)) {
chTermSign = '+';
if ((chSign == -1) || (chSign == 0)) {
ch = -1;
chTerm = -1;
posTerm = -1;
}
log.info("ParseMap:Rule16:Last Term Rule:AlgoName=" + AlgoName + " pos=" + pos + " ch=" + (char) ch + " posTerm=" + posTerm + " chTerm=" + (char) chTerm + " posVar=" + posVar + " chVar=" + (char) chVar + " posLA=" + posLA + " chLA=" + (char) chLA + " chTermSign=" + (char) chTermSign + " chSign=" + (char) chSign + " strlength=" + strlength);
}
log.info("ParseMap:Final:AlgoName=" + AlgoName + " pos=" + pos + " ch=" + (char) ch + " posTerm=" + posTerm + " chTerm=" + (char) chTerm + " posVar=" + posVar + " chVar=" + (char) chVar + " posLA=" + posLA + " chLA=" + (char) chLA + " chTermSign=" + (char) chTermSign + " chSign=" + (char) chSign + " strlength=" + strlength);
} else if (AlgoName.equalsIgnoreCase("LookAheadConst:parseLA:LAAlone")) {
log.info("ParseMap:Initial:AlgoName=" + AlgoName + " pos=" + pos + " ch=" + (char) ch + " posTerm=" + posTerm + " chTerm=" + (char) chTerm + " posVar=" + posVar + " chVar=" + (char) chVar + " posLA=" + posLA + " chLA=" + (char) chLA + " LATermOperator=" + (char) LATermOperator);
log.info("ParseMap:Initial:AlgoName=" + AlgoName + " GotVariableFlag=" + GotVariableFlag + " ComplexAssignFlag=" + ComplexAssignFlag + " GotVariablePos=" + GotVariablePos + " TrailConstantFlag=" + TrailConstantFlag);
if ((StrLA != null) && (StrLA.equalsIgnoreCase("")) && (posLA < (StrLA.length() - 1)) && (chLA != -1) && (timesLoop == 0)) {
posTerm = posLA + 1;
chTerm = StrLA.charAt(posTerm);
} else if ((chLA == -1) || (posLA == -1)) {
posTerm = -1;
chTerm = -1;
} else if ((timesLoop == 2) && ((chVar != -1) && (posVar != -1))) {
posTerm = posVar + 1;
chTerm = StrTerm.charAt(posTerm);
log.info("ParseMap:Initial:AlgoName=" + AlgoName + " Reached posVar=" + posVar + " chVar=" + (char) chVar + " posTerm=" + posTerm + " chTerm=" + (char) chTerm);
}
log.info("ParseMap:Final:AlgoName=" + AlgoName + " pos=" + pos + " ch=" + (char) ch + " posTerm=" + posTerm + " chTerm=" + (char) chTerm + " posVar=" + posVar + " chVar=" + (char) chVar + " posLA=" + posLA + " chLA=" + (char) chLA + " LATermOperator=" + (char) LATermOperator);
log.info("ParseMap:Final:AlgoName=" + AlgoName + " GotVariableFlag=" + GotVariableFlag + " ComplexAssignFlag=" + ComplexAssignFlag + " GotVariablePos=" + GotVariablePos + " TrailConstantFlag=" + TrailConstantFlag);
} else if (AlgoName.equalsIgnoreCase("LookAheadBraces:parseBraces")) {
log.info("ParseMap:Initial:AlgoName=" + AlgoName + " pos=" + pos + " ch=" + (char) ch + " posTerm=" + posTerm + " chTerm=" + (char) chTerm + " posVar=" + posVar + " chVar=" + (char) chVar + " posLA=" + posLA + " chLA=" + (char) chLA + " posBraces=" + posBraces + " chBraces=" + (char) chBraces);
log.info("ParseMap:Initial:AlgoName=" + AlgoName + " GotVariableFlag=" + GotVariableFlag + " ComplexAssignFlag=" + ComplexAssignFlag + " GotVariablePos=" + GotVariablePos + " TrailConstantFlag=" + TrailConstantFlag);
if (posBraces < StrBraces.length()) {
posTerm = posBraces + 1;
chTerm = StrTerm.charAt(posTerm);
}
log.info("ParseMap:Final:AlgoName=" + AlgoName + " pos=" + pos + " ch=" + (char) ch + " posTerm=" + posTerm + " chTerm=" + (char) chTerm + " posVar=" + posVar + " chVar=" + (char) chVar + " posLA=" + posLA + " chLA=" + (char) chLA + " posBraces=" + posBraces + " chBraces=" + (char) chBraces);
log.info("ParseMap:Final:AlgoName=" + AlgoName + " GotVariableFlag=" + GotVariableFlag + " ComplexAssignFlag=" + ComplexAssignFlag + " GotVariablePos=" + GotVariablePos + " TrailConstantFlag=" + TrailConstantFlag);
} else if (AlgoName.equalsIgnoreCase("LookAheadConst:parseLADiff:Diff")) {
log.info("ParseMap:Initial:AlgoName=" + AlgoName + " posDiff=" + posDiff + " chDiff=" + (char) chDiff + " posLADiff=" + posLADiff + " chLADiff=" + (char) chLADiff + " GotVariablePos=" + GotVariablePos + " GotIndConstPos=" + GotIndConstPos + " DiffLength=" + DiffLength + " LastLADiffIndConstAidPos=" + LastLADiffIndConstAidPos);
log.info("ParseMap:Final:AlgoName=" + AlgoName + " GotVariableFlag=" + GotVariableFlag + " ComplexAssignFlag=" + ComplexAssignFlag + " GotVariablePos=" + GotVariablePos + " TrailConstantFlag=" + TrailConstantFlag + " ContainsIndConstFlag=" + ContainsIndConstFlag);
log.info("ParseMap:Initial:AlgoName=" + AlgoName + " StrLADiff=" + StrLADiff.substring(posLADiff));
log.info("ParseMap:Initial:AlgoName=" + AlgoName + " StrDiff=" + StrDiff.substring(posDiff));
if ((ContainsIndConstFlag == true) && (posDiff < StrDiff.length()) && (LastLADiffIndConstAidPos >= 0)) {
posDiff = posDiff + LastLADiffIndConstAidPos;
while ((posDiff < StrDiff.length()) && (StrDiff.charAt(posDiff) != '*') && (StrDiff.charAt(posDiff) != '/')) {
prevCharDiff();
}
if (posDiff < StrDiff.length()) {
chDiff = StrDiff.charAt(posDiff);
} else {
posDiff = StrDiff.length();
chDiff = -1;
}
}
log.info("ParseMap:Final:AlgoName=" + AlgoName + " StrLADiff=" + StrLADiff.substring(posLADiff));
log.info("ParseMap:Final:AlgoName=" + AlgoName + " GotVariableFlag=" + GotVariableFlag + " ComplexAssignFlag=" + ComplexAssignFlag + " GotVariablePos=" + GotVariablePos + " TrailConstantFlag=" + TrailConstantFlag + " ContainsIndConstFlag=" + ContainsIndConstFlag);
log.info("ParseMap:Final:AlgoName=" + AlgoName + " StrDiff=" + StrDiff.substring(posDiff));
log.info("ParseMap:Final:AlgoName=" + AlgoName + " posDiff=" + posDiff + " chDiff=" + (char) chDiff + " posLA=" + posLA + " chLA=" + (char) chLA + " GotVariablePos=" + GotVariablePos + " GotIndConstPos=" + GotIndConstPos + " DiffLength=" + DiffLength + " LastLADiffIndConstAidPos=" + LastLADiffIndConstAidPos);
} else if (AlgoName.equalsIgnoreCase("LookAheadConst:parseLADiff:Integration")) {
log.info("ParseMap:Initial:AlgoName=" + AlgoName + " posIntegr=" + posIntegr + " chIntegr=" + (char) chIntegr + " posLADiff=" + posLADiff + " chLA=" + (char) chLADiff + " GotVariablePos=" + GotVariablePos + " GotIndConstPos=" + GotIndConstPos + " DiffLength=" + DiffLength + " LastLADiffIndConstAidPos=" + LastLADiffIndConstAidPos + " LastLADiffConstCoeffAidPos=" + LastLADiffConstCoeffAidPos);
log.info("ParseMap:Initial:AlgoName=" + AlgoName + " GotExpntNumFlag=" + GotExpntNumFlag + " ContainsIndConstFlag=" + ContainsIndConstFlag);
log.info("ParseMap:Initial:AlgoName=" + AlgoName + " StrIntegr=" + StrIntegr.substring(posIntegr));
if ((ContainsIndConstFlag == true) && (posIntegr < StrIntegr.length()) && (LastLADiffIndConstAidPos >= 0)) {
posIntegr = posIntegr + LastLADiffIndConstAidPos - 1;
while ((posIntegr < StrIntegr.length()) && (StrIntegr.charAt(posIntegr) != '*') && (StrIntegr.charAt(posIntegr) != '/')) {
prevCharIntegr();
}
if (posIntegr < StrIntegr.length()) {
chIntegr = StrIntegr.charAt(posIntegr);
} else {
posIntegr = StrIntegr.length();
chIntegr = -1;
}
chIntegr = StrIntegr.charAt(posIntegr);
} else if (LastLADiffConstCoeffAidPos >= 0) {
if (LastLADiffConstCoeffAidPos < StrIntegr.length()) {
posIntegr = LastLADiffConstCoeffAidPos - DiffLength;
}
while ((posIntegr < StrIntegr.length()) && (StrIntegr.charAt(posIntegr) != '*') && (StrIntegr.charAt(posIntegr) != '/')) {
prevCharIntegr();
}
if (posIntegr < StrIntegr.length()) {
chIntegr = StrIntegr.charAt(posIntegr);
} else {
posIntegr = StrIntegr.length();
chIntegr = -1;
}
ParseMapposModFlag = true;
log.info("ParseMap:LastLADiffConstCoeffAidPos>0:AlgoName=" + AlgoName + " StrIntegr=" + StrIntegr.substring(posIntegr));
log.info("ParseMap:LastLADiffConstCoeffAidPos:AlgoName=" + AlgoName + " posIntegr=" + posIntegr + " chIntegr=" + (char) chIntegr + " posLA=" + posLA + " chLA=" + (char) chLA + " GotVariablePos=" + GotVariablePos + " GotIndConstPos=" + GotIndConstPos + " DiffLength=" + DiffLength + " LastLADiffIndConstAidPos=" + LastLADiffIndConstAidPos + " LastLADiffConstCoeffAidPos=" + LastLADiffConstCoeffAidPos);
} else {
if (posIntegr < StrIntegr.length()) {
chIntegr = StrIntegr.charAt(posIntegr);
} else {
posIntegr = StrIntegr.length();
chIntegr = -1;
}
log.info("ParseMap:Else:AlgoName=" + AlgoName + " StrIntegr=" + StrIntegr.substring(posIntegr));
log.info("ParseMap:Else:AlgoName=" + AlgoName + " posIntegr=" + posIntegr + " chIntegr=" + (char) chIntegr + " posLA=" + posLA + " chLA=" + (char) chLA + " GotVariablePos=" + GotVariablePos + " GotIndConstPos=" + GotIndConstPos + " DiffLength=" + DiffLength + " LastLADiffIndConstAidPos=" + LastLADiffIndConstAidPos + " LastLADiffConstCoeffAidPos=" + LastLADiffConstCoeffAidPos);
}
log.info("ParseMap:Final:AlgoName=" + AlgoName + " GotExpntNumFlag=" + GotExpntNumFlag + " ContainsIndConstFlag=" + ContainsIndConstFlag);
log.info("ParseMap:Final:AlgoName=" + AlgoName + " GotVariableFlag=" + GotVariableFlag + " ComplexAssignFlag=" + ComplexAssignFlag + " GotVariablePos=" + GotVariablePos + " TrailConstantFlag=" + TrailConstantFlag + " ContainsIndConstFlag=" + ContainsIndConstFlag);
log.info("ParseMap:Final:AlgoName=" + AlgoName + " StrIntegr=" + StrIntegr.substring(posIntegr));
log.info("ParseMap:Final:AlgoName=" + AlgoName + " posIntegr=" + posIntegr + " chIntegr=" + (char) chIntegr + " posLA=" + posLA + " chLA=" + (char) chLA + " GotVariablePos=" + GotVariablePos + " GotIndConstPos=" + GotIndConstPos + " DiffLength=" + DiffLength + " LastLADiffIndConstAidPos=" + LastLADiffIndConstAidPos + " LastLADiffConstCoeffAidPos=" + LastLADiffConstCoeffAidPos);
} else if (AlgoName.equalsIgnoreCase("Integr:parseTermIntegr:")) {
log.info("ParseMap:Initial:AlgoName=" + AlgoName + " posIntegr=" + posIntegr + " chIntegr=" + (char) chIntegr + " posLADiff=" + posLADiff + " chLA=" + (char) chLADiff + " GotVariablePos=" + GotVariablePos + " GotIndConstPos=" + GotIndConstPos + " DiffLength=" + DiffLength + " LastLADiffIndConstAidPos=" + LastLADiffIndConstAidPos + " LastLADiffConstCoeffAidPos=" + LastLADiffConstCoeffAidPos);
log.info("ParseMap:Initial:AlgoName=" + AlgoName + " StrIntegr(posIntegr)=" + StrIntegr.substring(posIntegr));
if (posIntegr == -1) {
chIntegr = StrIntegr.charAt(0);
} else {
chIntegr = StrIntegr.charAt(posIntegr - 1);
}
log.info("ParseMap:Final:AlgoName=" + AlgoName + " StrIntegr(posIntegr)=" + StrIntegr.substring(posIntegr) + " posIntegr=" + posIntegr + " chIntegr=" + (char) chIntegr);
log.info("ParseMap:Final:AlgoName=" + AlgoName + " posIntegr=" + posIntegr + " chIntegr=" + (char) chIntegr + " posLA=" + posLA + " chLA=" + (char) chLA + " GotVariablePos=" + GotVariablePos + " GotIndConstPos=" + GotIndConstPos + " DiffLength=" + DiffLength + " LastLADiffIndConstAidPos=" + LastLADiffIndConstAidPos + " LastLADiffConstCoeffAidPos=" + LastLADiffConstCoeffAidPos);
} else if (AlgoName.equalsIgnoreCase("SimpleAlgebra:parseSimple:StrFunF")) {
log.info("ParseMap:Initial:AlgoName=" + AlgoName + " pos=" + pos + " ch=" + (char) ch + " posFunF=" + posFunF + " chFunF=" + (char) chFunF);
pos=posFunF;
Str=StrFunF;
if ((pos >=0)&&(pos < Str.length()))
ch=Str.charAt(pos);
else ch=-1;
log.fatal("ParseMap:Final:AlgoName=" + AlgoName + " pos=" + pos + " ch=" + (char) ch + " posFunF=" + posFunF + " chFunF=" + (char) chFunF);
}
else if (AlgoName.equalsIgnoreCase("SimpleAlgebra:parseSimple:StrFunF-SteadyState")) {
log.fatal("ParseMap:Initial:AlgoName=" + AlgoName + " pos=" + pos + " ch=" + (char) ch + " posFunF=" + posFunF + " chFunF=" + (char) chFunF);
pos=posFunF;
Str=StrFunF;
ch=Str.charAt(pos);
log.fatal("ParseMap:Final:AlgoName=" + AlgoName + " StrFunF=" + StrFunF + " pos=" + pos + " posFunF=" + posFunF + " posFunFLocal=" + posFunFLocal);
log.fatal("ParseMap:Final:AlgoName=" + AlgoName + " StrFunG=" + StrFunG + " posFunG=" + posFunG);
log.fatal("ParseMap:Final:AlgoName=" + AlgoName + " pos=" + pos + " ch=" + (char) ch + " posFunF=" + posFunF + " chFunF=" + (char) chFunF);
}
else if (AlgoName.equalsIgnoreCase("SimpleAlgebra:parseSimple:StrFunG")) {
log.info("ParseMap:Initial:AlgoName=" + AlgoName + " pos=" + pos + " ch=" + (char) ch + " posFunG=" + posFunG + " chFunG=" + (char) chFunG);
pos=posFunG;
Str=StrFunG;
if ((pos >=0)&&(pos < Str.length()))
ch=Str.charAt(pos);
else ch=Str.charAt(0);
log.fatal("ParseMap:Final:AlgoName=" + AlgoName + " pos=" + pos + " ch=" + (char) ch + " posFunG=" + posFunG + " chFunG=" + (char) chFunG);
}
}
static void ParseStore(String AlgoName) {
if (AlgoName.equalsIgnoreCase("StrFunF")) {
log.info("ParseStore:Initial:AlgoName=" + AlgoName + " pos=" + pos + " ch=" + (char) ch + " posFunF=" + posFunF + " chFunF=" + (char) chFunF);
if ((pos!=-1)&&(posFunF >= 0)&&((pos >=0)&&(pos < Str.length()) ) ) {
chFunF=StrFunF.charAt(0);
Str=StrFunF;
posFunF=pos;
ch=Str.charAt(pos);
}else {
chFunF=StrFunF.charAt(0);
Str=StrFunF;
pos=0;
posFunF=0;
ch=Str.charAt(0);
}
StrFunF=Str;
chFunF=Str.charAt(pos);
log.info("ParseStore:Final:AlgoName=" + AlgoName +" Str=" + Str.substring(pos));
log.info("ParseStore:Final:AlgoName=" + AlgoName + " pos=" + pos + " ch=" + (char) ch + " posFunF=" + posFunF + " chFunF=" + (char) chFunF + " posTerm=" + posTerm + " chTerm=" + (char) chTerm + " posVar=" + posVar + " chVar=" + (char) chVar + " posLA=" + posLA + " chLA=" + (char) chLA);
}else if (AlgoName.equalsIgnoreCase("StrFunG")) {
log.info("ParseStore:Initial:AlgoName=" + AlgoName + " pos=" + pos + " ch=" + (char) ch + " posFunG=" + posFunG + " chFunG=" + (char) chFunG);
if ((pos!=-1)&&(posFunG >= 0)&&((pos >=0)&&(pos < Str.length()) ) ) {
chFunG=StrFunG.charAt(0);
Str=StrFunG;
posFunG=pos;
ch=Str.charAt(pos);
}
else {
chFunG=StrFunG.charAt(0);
Str=StrFunG;
pos=0;
posFunG=0;
ch=Str.charAt(pos);
}
StrFunG=Str;
chFunG=Str.charAt(pos);
log.info("ParseStore:Final:AlgoName=" + AlgoName +" Str=" + Str.substring(pos));
log.info("ParseStore:Final:AlgoName=" + AlgoName + " pos=" + pos + " ch=" + (char) ch + " posFunG=" + posFunG + " chFunG=" + (char) chFunG + " posTerm=" + posTerm + " chTerm=" + (char) chTerm + " posVar=" + posVar + " chVar=" + (char) chVar + " posLA=" + posLA + " chLA=" + (char) chLA);
}else if (AlgoName.equalsIgnoreCase("StrFunF-Inf")) {
log.info("ParseStore:Initial:AlgoName=" + AlgoName + " pos=" + pos + " ch=" + (char) ch + " posFunF=" + posFunF + " chFunF=" + (char) chFunF);
if ((pos!=-1)&&(posFunF >= 0)&&((pos >=0)&&(pos < Str.length()) ) ) {
chFunF=StrFunF.charAt(0);
Str=StrFunF;
pos=posFunF;
ch=Str.charAt(pos);
}else {
chFunF=StrFunF.charAt(0);
Str=StrFunF;
pos=posFunF;
ch=Str.charAt(pos);
}
StrFunF=Str;
chFunF=Str.charAt(pos);
log.info("ParseStore:Final:AlgoName=" + AlgoName +" Str=" + Str.substring(pos));
log.info("ParseStore:Final:AlgoName=" + AlgoName + " pos=" + pos + " ch=" + (char) ch + " posFunF=" + posFunF + " chFunF=" + (char) chFunF + " posTerm=" + posTerm + " chTerm=" + (char) chTerm + " posVar=" + posVar + " chVar=" + (char) chVar + " posLA=" + posLA + " chLA=" + (char) chLA);
}else if (AlgoName.equalsIgnoreCase("StrFunG-Inf")) {
log.info("ParseStore:Initial:AlgoName=" + AlgoName + " pos=" + pos + " ch=" + (char) ch + " posFunG=" + posFunG + " chFunG=" + (char) chFunG);
if ((pos!=-1)&&(posFunG >= 0)&&((pos >=0)&&(pos < Str.length()) ) ) {
chFunG=StrFunG.charAt(0);
Str=StrFunG;
pos=posFunG;
ch=Str.charAt(pos);
}
else {
chFunG=StrFunG.charAt(0);
Str=StrFunG;
pos=posFunG;
ch=Str.charAt(pos);
}
StrFunG=Str;
chFunG=Str.charAt(pos);
log.info("ParseStore:Final:AlgoName=" + AlgoName +" Str=" + Str.substring(pos));
log.info("ParseStore:Final:AlgoName=" + AlgoName + " pos=" + pos + " ch=" + (char) ch + " posFunG=" + posFunG + " chFunG=" + (char) chFunG + " posTerm=" + posTerm + " chTerm=" + (char) chTerm + " posVar=" + posVar + " chVar=" + (char) chVar + " posLA=" + posLA + " chLA=" + (char) chLA);
}else if (AlgoName.equalsIgnoreCase("StrFunG-Inf-SteadyState")) {
log.info("ParseStore:Initial:AlgoName=" + AlgoName + " pos=" + pos + " ch=" + (char) ch + " posFunG=" + posFunG + " chFunG=" + (char) chFunG);
if ((pos!=-1)&&(posFunG >= 0)&&((pos >=0)&&(pos < StrFunG.length()) ) ) {
log.info("ParseStore:Initial:AlgoName=" + AlgoName + "Rule1");
chFunG=StrFunG.charAt(posFunG);
Str=StrFunG;
posFunG=pos;
ch=Str.charAt(pos);
}else if (pos==-1){
log.info("ParseStore:Initial:AlgoName=" + AlgoName + "Rule2");
Str=StrFunG;
ch=Str.charAt(posFunG);
pos=posFunG;
}else if ((posFunG == -1 )&&(pos !=-1)){
log.info("ParseStore:Initial:AlgoName=" + AlgoName + "Rule3");
Str=StrFunG;
ch=Str.charAt(pos);
posFunG=pos;
chFunG=StrFunG.charAt(posFunG);
}else{
pos=0;
posFunG=0;
Str=StrFunG;
}
log.info("ParseStore:Final:AlgoName=" + AlgoName +" Str=" + Str.substring(pos));
log.info("ParseStore:Final:AlgoName=" + AlgoName + " pos=" + pos + " ch=" + (char) ch + " posFunG=" + posFunG + " chFunG=" + (char) chFunG + " posTerm=" + posTerm + " chTerm=" + (char) chTerm + " posVar=" + posVar + " chVar=" + (char) chVar + " posLA=" + posLA + " chLA=" + (char) chLA);
}
}
public static String RemoveEDbl(double Number) {
String StrNumber = "" + Number;
if ((StrNumber.contains("E")) || (StrNumber.contains("e"))) {
NumberFormat formatter = new DecimalFormat();
formatter.setMaximumFractionDigits(MaximumFractionDigits);
formatter.setMaximumIntegerDigits(MaximumIntegerDigits);
log.info("RemoveEDbl:Number=" + Number);
log.info("RemoveEDbl:Formatted Number=" + formatter.format(Number));
return formatter.format(Number);
}
return (StrNumber);
}
public static String StrRemoveEDbl(String Number) {
if ((Number.contains("E")) || (Number.contains("e"))) {
NumberFormat formatter = new DecimalFormat("#.##");
formatter.setMaximumFractionDigits(MaximumFractionDigits);
formatter.setMaximumIntegerDigits(MaximumIntegerDigits);
log.info("StrRemoveEDbl:Number=" + Number);
log.info("StrRemoveEDbl:Formatted Number=" + formatter.format(Number));
return formatter.format(Number);
}
return Number;
}
static void LookAheadFunc_Opr(int i, int mypos, String CallingExpr) {
int j = 0;
int mych = 0;
if (CallingExpr.equalsIgnoreCase("")) {
mych = ch;
} else if (CallingExpr.equalsIgnoreCase("Diff")) {
mych = chDiff;
} else if (CallingExpr.equalsIgnoreCase("Integr")) {
mych = chIntegr;
}
LookAheadOp[j] = LowLevelOperator.Null;
j++;
for (; ((j <= i) && (j < LookAheadOp.length)); j++) {
while (mych == ' ') {
if (CallingExpr.equalsIgnoreCase("")) {
nextChar();
mych = ch;
} else if (CallingExpr.equalsIgnoreCase("Diff")) {
nextCharDiff();
mych = chDiff;
} else if (CallingExpr.equalsIgnoreCase("Integr")) {
nextCharIntegr();
mych = chIntegr;
}
}
switch (mych) {
case '+':
LookAheadOp[j] = LowLevelOperator.Plus;
break;
case '-':
LookAheadOp[j] = LowLevelOperator.Minus;
// if ((LookAheadOp[j - 1] == LowLevelOperator.Mult)
// || (LookAheadOp[j - 1] == LowLevelOperator.Div)
// || (LookAheadOp[j - 1] == LowLevelOperator.Null)) {
// LookAheadOp[j] = LowLevelOperator.Compact;
// }
break;
case '*':
LookAheadOp[j] = LowLevelOperator.Mult;
break;
case '/':
LookAheadOp[j] = LowLevelOperator.Div;
break;
case '^':
LookAheadOp[j] = LowLevelOperator.Expnt;
break;
case '(':
LookAheadOp[j] = LowLevelOperator.ParenthesisOpen;
break;
case ')':
LookAheadOp[j] = LowLevelOperator.ParenthesisClose;
break;
case 0:
LookAheadOp[j] = LowLevelOperator.Null;
break;
case -1:
LookAheadOp[j] = LowLevelOperator.End;
break;
}
if (IsNumber(mych)) { //numbers
LookAheadOp[j] = LowLevelOperator.Numbers;
while (IsNumber(mych)) {
if (CallingExpr.equalsIgnoreCase("")) {
nextChar();
mych = ch;
} else if (CallingExpr.equalsIgnoreCase("Diff")) {
nextCharDiff();
mych = chDiff;
} else if (CallingExpr.equalsIgnoreCase("Integr")) {
nextCharIntegr();
mych = chIntegr;
}
if ((mych == 'E') || (mych == 'e')) {
if (CallingExpr.equalsIgnoreCase("")) {
nextChar();
mych = ch;
} else if (CallingExpr.equalsIgnoreCase("Diff")) {
nextCharDiff();
mych = chDiff;
} else if (CallingExpr.equalsIgnoreCase("Integr")) {
nextCharIntegr();
mych = chIntegr;
}
if ((mych == '-') || (mych == '+')) {
if (CallingExpr.equalsIgnoreCase("")) {
nextChar();
mych = ch;
} else if (CallingExpr.equalsIgnoreCase("Diff")) {
nextCharDiff();
mych = chDiff;
} else if (CallingExpr.equalsIgnoreCase("Integr")) {
nextCharIntegr();
mych = chIntegr;
}
}
}
}
if (CallingExpr.equalsIgnoreCase("")) {
prevChar();
mych = ch;
} else if (CallingExpr.equalsIgnoreCase("Diff")) {
prevCharDiff();
mych = chDiff;
} else if (CallingExpr.equalsIgnoreCase("Integr")) {
prevCharIntegr();
mych = chIntegr;
}
} else if (IsVariable(mych)) {
LookAheadOp[j] = LowLevelOperator.FuncNvar;
while ((IsVariable(mych)) || (IsNumber(mych))) {
if (CallingExpr.equalsIgnoreCase("")) {
nextChar();
mych = ch;
} else if (CallingExpr.equalsIgnoreCase("Diff")) {
nextCharDiff();
mych = chDiff;
} else if (CallingExpr.equalsIgnoreCase("Integr")) {
nextCharIntegr();
mych = chIntegr;
}
}
if (CallingExpr.equalsIgnoreCase("")) {
prevChar();
mych = ch;
} else if (CallingExpr.equalsIgnoreCase("Diff")) {
prevCharDiff();
mych = chDiff;
} else if (CallingExpr.equalsIgnoreCase("Integr")) {
prevCharIntegr();
mych = chIntegr;
}
}
if ((mych != -1) && (mych != 0)) {
if (CallingExpr.equalsIgnoreCase("")) {
nextChar();
mych = ch;
} else if (CallingExpr.equalsIgnoreCase("Diff")) {
nextCharDiff();
mych = chDiff;
} else if (CallingExpr.equalsIgnoreCase("Integr")) {
nextCharIntegr();
mych = chIntegr;
}
} else if (mych == 0) {
if (CallingExpr.equalsIgnoreCase("")) {
mych = Str.charAt(pos);
} else if (CallingExpr.equalsIgnoreCase("Diff")) {
mych = StrDiff.charAt(posDiff);
} else if (CallingExpr.equalsIgnoreCase("Integr")) {
mych = StrIntegr.charAt(posIntegr);
}
} else if (mych == -1) {
break;//Exit For Loop
}
}
LookAheadOp[j++] = LowLevelOperator.End;
LookAhead_Oppos = j;
for (int k = 0; k < j; k++) {
log.info("LookAheadFunc_Opr:LookAheadOp[" + k + "]=" + LookAheadOp[k]);
}
}
static void LookAheadFunc_String(int i, int mypos, String CallingExpr) {
boolean CompactorFlag = false;
int startXPos = 0;
int Xpos = 0;
int mych = 0;
LookAhead_Stringpos = 0;
int j = 0, x = 2, k = 0;
for (; j <= i; j++) {
while (mych == ' ') {
if (CallingExpr.equalsIgnoreCase("")) {
nextChar();
mych = ch;
} else if (CallingExpr.equalsIgnoreCase("Diff")) {
nextCharDiff();
mych = chDiff;
} else if (CallingExpr.equalsIgnoreCase("Integr")) {
nextCharIntegr();
mych = chIntegr;
}
}
if (IsNumber(mych)) { //numbers
int startpos = pos;