@@ -34,7 +34,7 @@ public MathFuncNode Root
3434 protected set ;
3535 }
3636
37- public MathFunc ( string str , string v = null , bool simplify = true , bool calculateConstants = false )
37+ public MathFunc ( string str , string v = null , bool simplify = true , bool precompile = false )
3838 {
3939 if ( ! Helper . Parser . Parse ( str ) )
4040 throw new Exception ( "Impossible to parse input string" ) ;
@@ -56,7 +56,7 @@ public MathFunc(string str, string v = null, bool simplify = true, bool calculat
5656 Root . Sort ( ) ;
5757 if ( simplify )
5858 Root = Simplify ( Root ) ;
59- if ( calculateConstants )
59+ if ( precompile )
6060 Root = RationalToDouble ( Root ) ;
6161 }
6262
@@ -68,7 +68,7 @@ public MathFunc(MathFuncNode root,
6868 {
6969 }
7070
71- public MathFunc ( MathFuncNode left , MathFuncNode right ,
71+ public MathFunc ( MathFuncNode left , MathFuncNode right ,
7272 VarNode variable = null , IEnumerable < ConstNode > parameters = null ,
7373 bool simplify = true , bool calculateConstants = false )
7474 {
@@ -91,7 +91,7 @@ public MathFunc(MathFuncNode left, MathFuncNode right,
9191 Root = RationalToDouble ( Root ) ;
9292 }
9393
94- public MathFuncNode Calculate ( KnownFuncType ? funcType , IList < ValueNode > args )
94+ public ValueNode SimplifyValues ( KnownFuncType ? funcType , IList < ValueNode > args )
9595 {
9696 Rational < long > result ;
9797 double temp = 0.0 ;
@@ -144,9 +144,6 @@ public MathFuncNode Calculate(KnownFuncType? funcType, IList<ValueNode> args)
144144 case KnownFuncType . Diff :
145145 return new ValueNode ( 0 ) ;
146146
147- default :
148- return null ;
149-
150147 case KnownFuncType . Sqrt :
151148 temp = Math . Sqrt ( args [ 0 ] . DoubleValue ) ;
152149 break ;
@@ -214,6 +211,9 @@ public MathFuncNode Calculate(KnownFuncType? funcType, IList<ValueNode> args)
214211 case KnownFuncType . Abs :
215212 temp = Math . Abs ( args [ 0 ] . DoubleValue ) ;
216213 break ;
214+
215+ default :
216+ return null ;
217217 }
218218
219219 if ( Rational < long > . FromDecimal ( ( decimal ) temp , out result , 12 , false , 2 , 8 ) )
@@ -306,7 +306,7 @@ public bool IsValue
306306 {
307307 get
308308 {
309- return Root . IsValue ;
309+ return Root . IsValueOrCalculated ;
310310 }
311311 }
312312
0 commit comments