Class PolynomialTerm
java.lang.Object
edu.cmu.tetrad.study.gene.tetrad.gene.history.PolynomialTerm
- All Implemented Interfaces:
TetradSerializable
,Serializable
Implements a term in a polymonial whose variables are mapped to indices in in the set {0, 1, 2, ...}. The term has a coefficient and a freely generated list of variables. For example, if "x" -> 0, "y" -> 1, "z" -> 2, then the following terms are represented as follows, where "Vi" stands for the variable mapped to index i:
- 2.5x -> 2.5*(V0)(V0)
- 1.7xyz^2 -> 1.7*(V0)(V1)(V2)(V2)
- -5.0z^3y^2 -> -5.0*(V2)(V2)(V2)(V1)(V1)
- Author:
- josephramsey
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondouble
evaluate
(double[] values) Evaluates the term.double
Returns the coefficient.int
Returns the highest variable index in this term.int
Returns the number of variables in this term.int
getVariable
(int index) Returns the index'th variable.boolean
isVariableListEqual
(int[] variables) Returns true iff the given variable list is equal to the variable list of this term.static PolynomialTerm
Generates a simple exemplar of this class to test serialization.void
setCoefficient
(double coefficient) Sets the coefficient.toString()
Prints out a representation of the term.
-
Constructor Details
-
PolynomialTerm
public PolynomialTerm(double coefficient, int[] variables) Constructs a term.
-
-
Method Details
-
serializableInstance
Generates a simple exemplar of this class to test serialization. -
getCoefficient
public double getCoefficient()Returns the coefficient. -
setCoefficient
public void setCoefficient(double coefficient) Sets the coefficient. -
getNumVariables
public int getNumVariables()Returns the number of variables in this term. -
getVariable
public int getVariable(int index) Returns the index'th variable. -
isVariableListEqual
public boolean isVariableListEqual(int[] variables) Returns true iff the given variable list is equal to the variable list of this term. -
getMaxIndex
public int getMaxIndex()Returns the highest variable index in this term. -
evaluate
public double evaluate(double[] values) Evaluates the term. -
toString
Prints out a representation of the term.
-