Class PolynomialTerm

java.lang.Object
edu.cmu.tetrad.study.gene.tetrad.gene.history.PolynomialTerm
All Implemented Interfaces:
TetradSerializable, Serializable

public class PolynomialTerm extends Object implements TetradSerializable

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:

  1. 2.5x -> 2.5*(V0)(V0)
  2. 1.7xyz^2 -> 1.7*(V0)(V1)(V2)(V2)
  3. -5.0z^3y^2 -> -5.0*(V2)(V2)(V2)(V1)(V1)
Author:
josephramsey
See Also:
  • Constructor Details

    • PolynomialTerm

      public PolynomialTerm(double coefficient, int[] variables)
      Constructs a term.
  • Method Details

    • serializableInstance

      public static PolynomialTerm 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

      public String toString()
      Prints out a representation of the term.
      Overrides:
      toString in class Object