Package io.bhagat.math.linearalgebra
Class LinearEquation
- java.lang.Object
-
- io.bhagat.math.linearalgebra.LinearEquation
-
public class LinearEquation extends java.lang.ObjectA class for linear equations- Author:
- Bhagat
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classLinearEquation.TermA class for each term in the equation
-
Field Summary
Fields Modifier and Type Field Description LinearEquation.Term[]termsAn array of the terms in the linear equation
-
Constructor Summary
Constructors Constructor Description LinearEquation(java.lang.String equation, java.lang.String... variables)Constructs a Linear Equation object from a string equation and a list of variables
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description doublegetConstant()finds the constant in the equationjava.util.ArrayList<java.lang.String>getVariables()creates a list of variables from the termsdoublegetWeight(java.lang.String variable)gets a weight for a specific variableVectorgetWeights()gets all the weights that the variables are multiplied with in each termjava.lang.StringtoString()converts back to a string equation
-
-
-
Field Detail
-
terms
public LinearEquation.Term[] terms
An array of the terms in the linear equation
-
-
Method Detail
-
getVariables
public java.util.ArrayList<java.lang.String> getVariables()
creates a list of variables from the terms- Returns:
- the variables
-
getWeights
public Vector getWeights()
gets all the weights that the variables are multiplied with in each term- Returns:
- a vector containing the weights
-
getWeight
public double getWeight(java.lang.String variable)
gets a weight for a specific variable- Parameters:
variable- the variable- Returns:
- the weight
-
getConstant
public double getConstant()
finds the constant in the equation- Returns:
- the constant
-
toString
public java.lang.String toString()
converts back to a string equation- Overrides:
toStringin classjava.lang.Object
-
-