public class Constant extends Object implements Expression, ExpressionCommand, MathObject
| Modifier and Type | Field and Description |
|---|---|
protected double |
value
The value of this Constant.
|
| Constructor and Description |
|---|
Constant(double value)
Create an unnamed Constant with the given value and null name.
|
Constant(String name,
double value)
Create a Constant with the given name and value.
|
| Modifier and Type | Method and Description |
|---|---|
void |
appendOutputString(ExpressionProgram prog,
int myIndex,
StringBuffer buffer)
Append the print string for this Constant to the buffer.
|
void |
apply(StackOfDouble stack,
Cases cases)
Apply the Constant to the stack.
|
void |
compileDerivative(ExpressionProgram prog,
int myIndex,
ExpressionProgram deriv,
Variable wrt)
Add a commands to deriv to evaluate the derivative of this Constant with respect to the
variable.
|
boolean |
dependsOn(Variable x)
Retrun false, since the value of this Constant is independent of the value of x.
|
Expression |
derivative(Variable wrt)
Return the derivative of this Constant with respect to the variable wrt.
|
int |
extent(ExpressionProgram prog,
int myIndex)
Return the number of locations that this Constant uses in the program.
|
String |
getName()
Return the name of this Constant.
|
double |
getVal()
Return the value of this Constant.
|
double |
getValueWithCases(Cases cases)
Return the value of the Constant.
|
void |
setName(String name)
Set the name of this Constant.
|
String |
toString()
Return the print string representing this Constant.
|
public Constant(double value)
public Constant(String name, double value)
public String getName()
getName in interface MathObjectpublic void setName(String name)
setName in interface MathObjectpublic double getVal()
public double getValueWithCases(Cases cases)
getValueWithCases in interface Expressionpublic Expression derivative(Variable wrt)
derivative in interface Expressionpublic String toString()
toString in interface ExpressiontoString in class Objectpublic void apply(StackOfDouble stack, Cases cases)
apply in interface ExpressionCommandstack - contains results of previous commands in the program.cases - if non-null, any case information generated during evaluation should be recorded here.public void compileDerivative(ExpressionProgram prog, int myIndex, ExpressionProgram deriv, Variable wrt)
compileDerivative in interface ExpressionCommandprog - program in which ExpressionCommand occurs.myIndex - point at which ExpressionCommand occurs in the ExpressionProgram.deriv - the derivative of the ExpressionPorgram prog, which is in the process of being computed.
Commands should added to deriv that will compute the derivative of this ExpressionCommand.wrt - commands are added to deriv with respect to this Variable.public int extent(ExpressionProgram prog, int myIndex)
extent in interface ExpressionCommandprog - ExpressionProgram in which this ExpressionCommand occurs.myIndex - index at which ExpressionCommand occurs in prog.public boolean dependsOn(Variable x)
dependsOn in interface ExpressiondependsOn in interface ExpressionCommandpublic void appendOutputString(ExpressionProgram prog, int myIndex, StringBuffer buffer)
appendOutputString in interface ExpressionCommand