Class Parser
java.lang.Object
com.github.gbenroscience.math.differentialcalculus.Parser
- Author:
- JIBOYE, OLUWAGBEMIRO OLAOLUWA Parses derivative commands of the format: diff(@(x)sin(x),5)... diff(@(x)sin(x),5,2)... diff(y,5)... diff(y,5,2)... The first command means the function, sin(x) is to be differentiated wrt x, and evaluated at x = 5. The second command means the function, sin(x) is to be differentiated wrt x, twice and then evaluated at x = 5. The third command means that a function called y has been pre-defined. The parser will load the function and differentiate it wrt x, and then evaluate it at x = 5. The fourth command means that a function called y has been pre-defined. The parser will load the function and differentiate it wrt x, twice, and then evaluate it at x = 5. Here sin(x) is to be differentiated and evaluated at x=5.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintdoubleintbooleanbooleanstatic voidstatic voidparseDerivativeCommand(List<String> list) voidsetDiffType(int diffType) voidsetOrderOfDifferentiation(int orderOfDifferentiation)
-
Field Details
-
result
-
GRAD_FUNC
public static final int GRAD_FUNC- See Also:
-
GRAD_VAL
public static final int GRAD_VAL- See Also:
-
-
Constructor Details
-
Parser
- Parameters:
expression- The expression to parse. e.g. diff(@(x)cos(x)+5*x,6,1) or diff(F,6,1) where F is a function that has been previously defined in the workspace and so is in theFunctionManagerIt may also take the form diff(@(x)cos(x)+5*x,6) or diff(F,6) where it assumes that the function is to be differentiated only once. In the future, we have diff(F) or (diff(@(x)cos(x)+5*x) which will return the gradient function itself.
-
-
Method Details
-
getEvalPoint
public double getEvalPoint() -
getFunction
-
getOrderOfDifferentiation
public int getOrderOfDifferentiation() -
setOrderOfDifferentiation
public void setOrderOfDifferentiation(int orderOfDifferentiation) -
getDiffType
public int getDiffType() -
setDiffType
public void setDiffType(int diffType) -
isGradFunc
public boolean isGradFunc() -
isGradEval
public boolean isGradEval() -
parseDerivativeCommand
- Parameters:
list- A list containing the scanned form of an expression containing information about the function whose derivative is to be evaluated and the point at which the derivative is to be evaluated. Common forms for the expression are: diff(@(x)sin(x),5)... diff(@(x)sin(x),5,2)... diff(y,5)... diff(y,5,2)... The first command means the function, sin(x) is to be differentiated wrt x, and evaluated at x = 5. The second command means the function, sin(x) is to be differentiated wrt x, twice and then evaluated at x = 5. The third command means that a function called y has been pre-defined. The parser will load the function and differentiate it wrt x, and then evaluate it at x = 5. The fourth command means that a function called y has been pre-defined. The parser will load the function and differentiate it wrt x, twice, and then evaluate it at x = 5. Direct examples would be: diff(@(x)sin(x+1),4) diff(F,5.32) where F is a function that has been defined before in the workspace.. and so on.
-
main
-