public SetVariable ( string name, double value ) : |
||
name | string | |
value | double | |
return |
// private float a = 0f; float fx(float s, float t) { // return (1.25f+0.5f*Mathf.Cos(s))*Mathf.Cos(t); // return Mathf.Cos(s); // var exp = solver.SymbolicateExpression(sfx,new string[]{"s", "t", "a"}); fxexp.SetVariable("t", t); fxexp.SetVariable("s", s); fxexp.SetVariable("a", a); return((float)fxexp.Evaluate()); // return s; }
public Expression SymbolicateExpression(string formula, string[] localVariables = null) { Expression newExpression = new Expression(); if (localVariables != null) { foreach (var localVariableName in localVariables) { if (localVariableName[0] == '$') { newExpression.SetVariable(localVariableName.Substring(1, localVariableName.Length - 1).Trim(), ""); } else { newExpression.SetVariable(localVariableName.Trim(), 0.0); } } } formula = SolverTools.RemoveWhiteSpace(formula); // Check validity try { ValidityChecker.CheckValidity(formula); } catch (System.Exception ex) { throw ex; } Symbol s = Symbolicate(formula, 0, formula.Length, newExpression); newExpression.root = s; return(newExpression); }
public Expression SymbolicateExpression(string formula, string[] localVariables = null) { Expression newExpression = new Expression(); if (localVariables != null) { foreach (var localVariableName in localVariables) { if (localVariableName[0] == '$') { newExpression.SetVariable(localVariableName.Substring(1,localVariableName.Length-1).Trim(),""); } else { newExpression.SetVariable(localVariableName.Trim(),0.0); } } } formula = SolverTools.RemoveWhiteSpace(formula); // Check validity try { ValidityChecker.CheckValidity(formula); } catch (System.Exception ex) { throw ex; } Symbol s = Symbolicate(formula, 0, formula.Length,newExpression); newExpression.root = s; return newExpression; }