|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsbrt.kernel.math.AbstractPolynomial<V>
sbrt.kernel.math.AbstractLinearComb<V>
sbrt.kernel.math.HashLinearComb<V>
V
- the variable type.public final class HashLinearComb<V>
This class is a concrete implemenation of LinearComb. The hash codes of the provided variables are used extenstively in this implementation to provide constant-time lookup for internally stored information.
Nested Class Summary | |
---|---|
static class |
HashLinearComb.Term<V>
This class is a concrete implementation of LinearComb.Term. |
Constructor Summary | |
---|---|
HashLinearComb(java.util.Collection<? extends LinearComb.Term<? extends V>> terms,
double constant,
double zeroCutoff)
Constructs a new linear combination from the provided terms and constant. |
|
HashLinearComb(LinearComb.Term<? extends V>[] terms,
double constant,
double zeroCutoff)
Constructs a new linear combination from the provided terms and constant. |
Method Summary | ||
---|---|---|
HashLinearComb<V> |
add(double constant)
Adds, in the mathematical sense, the provided constant to this linear combination. |
|
HashLinearComb<V> |
add(LinearComb<? extends V> expression)
Adds, in the mathematical sense, the provided linear combination to this linear combination. |
|
double |
getCoefficient(java.lang.Object variable)
Returns the coefficient of the term containing the provided variable. |
|
HashLinearComb.Term<V>[] |
getTermArray()
Returns the terms of this linear combination as an array. |
|
java.util.Set<V> |
getVariables()
Returns the set of variables contained in this mathematical expression. |
|
boolean |
hasAllVariables(java.util.Collection<?> variables)
Indicates if this mathematical expression contains all of the variables in the provided collection. |
|
boolean |
hasVariable(java.lang.Object variable)
Indicates if the provided object is a variable contained in this mathematical expression. |
|
boolean |
hasVariables()
Indicates if this mathematical expression contains any variables. |
|
java.util.Iterator<LinearComb.Term<V>> |
iterator()
Returns an iterator over the terms of this linear combination. |
|
static void |
main(java.lang.String[] args)
Used for testing purposes. |
|
HashLinearComb<V> |
multiply(double constant)
Multiplies this linear combination by the provided constant. |
|
HashLinearComb<V> |
plugIn(java.util.Map<?,? extends LinearComb<? extends V>> variableValues)
Plugs in the provided linear combinations to produce a new linear combination. |
|
HashLinearComb<V> |
plugIn(java.util.Map<?,java.lang.Double> numbers,
java.util.Map<?,? extends LinearComb<? extends V>> linearCombs)
Plugs in the provided numerical values and linear combinations to produce a new linear combination. |
|
HashLinearComb<V> |
plugIn(java.lang.Object variable,
double value)
Plugs the provided numerical value into the provided variable to produce a new linear combination. |
|
HashLinearComb<V> |
plugIn(java.lang.Object variable,
LinearComb<? extends V> expr)
Plugs the provided linear combination into the provided variable to produce a new linear combination. |
|
HashLinearComb<V> |
plugInNumbers(java.util.Map<?,java.lang.Double> variableValues)
Plugs in the provided numerical values to produce a new linear combination. |
|
static
|
singleTerm(double coefficient,
V variable)
Returns a single-term linear combination with the provided variable and coefficient. |
|
static
|
singleTerm(LinearComb.Term<V> term)
Returns a single-term linear combination with the provided term. |
|
static
|
singleTerm(V variable)
Returns a single-term linear combination with the provided variable. |
|
static
|
singleTerm(V variable,
double coefficient)
Returns a single-term linear combination with the provided variable and coefficient. |
|
static
|
singleTerm(V variable,
double coefficient,
double zeroCutoff)
Returns a single-term linear combination with the provided variable, coefficient, and zero cutoff. |
|
HashLinearComb<V> |
solveFor(java.lang.Object variable,
double rightHandSide)
Equates this linear combination to the provided constant and solves for the provided variable. |
|
int |
terms()
Returns the number of terms contained in this linear combination. |
|
int |
variables()
Returns the number of variables in this mathematical expression. |
Methods inherited from class sbrt.kernel.math.AbstractLinearComb |
---|
equals, getTermList, getZeroCutoff |
Methods inherited from class sbrt.kernel.math.AbstractPolynomial |
---|
checkConstant, getConstant, hashCode, toString |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface sbrt.kernel.math.LinearComb |
---|
hashCode, toString |
Methods inherited from interface sbrt.kernel.math.Polynomial |
---|
getConstant |
Constructor Detail |
---|
public HashLinearComb(LinearComb.Term<? extends V>[] terms, double constant, double zeroCutoff)
terms
- an array containing the terms used to create this linear
combination.constant
- the constant of this linear combination.zeroCutoff
- the zero cutoff.public HashLinearComb(java.util.Collection<? extends LinearComb.Term<? extends V>> terms, double constant, double zeroCutoff)
terms
- a collection of terms used to create this linear
combination.constant
- the constant of this linear combination.zeroCutoff
- the zero cutoff.
java.lang.IllegalArgumentException
- if a variable occurs in more than
one provided term.
java.lang.IllegalArgumentException
- if a provided value is either
infinite or NaN; or if the zero cutoff is negative.Method Detail |
---|
public HashLinearComb.Term<V>[] getTermArray()
public int terms()
public HashLinearComb<V> plugIn(java.util.Map<?,? extends LinearComb<? extends V>> variableValues)
If some of the keys in the provided map are not variables in this expression, their provided value is simply ignored.
variableValues
- objects mapped to linear combinations.
public HashLinearComb<V> plugIn(java.util.Map<?,java.lang.Double> numbers, java.util.Map<?,? extends LinearComb<? extends V>> linearCombs)
If some of the keys in either of the provided maps are not variables in this expression, their provided values are simply ignored.
numbers
- objects mapped to numerical values.linearCombs
- objects mapped to linear combinations.
plugIn(Map)
,
plugInNumbers(Map)
public HashLinearComb<V> plugInNumbers(java.util.Map<?,java.lang.Double> variableValues)
If some of the keys in the provided map are not variables in this expression, their provided value is simply ignored. If a value is provided for each variable in this linear combination, the resulting expression will not contain any variables of its own, only a constant.
variableValues
- objects mapped to numerical values.
public HashLinearComb<V> plugIn(java.lang.Object variable, double value)
variable
- the variable whose value is to be assigned.value
- the value to be assigned to the provided variable in this
linear combination.
public HashLinearComb<V> plugIn(java.lang.Object variable, LinearComb<? extends V> expr)
variable
- the variable whose value is to be assigned.expr
- the value to be assigned to the provided variable in this
linear combination.
public double getCoefficient(java.lang.Object variable)
variable
- the variable whose corresponding coefficient is to be
returned.
public HashLinearComb<V> solveFor(java.lang.Object variable, double rightHandSide)
variable
- the variable in this linear combination for which to
solve.rightHandSide
- the constant with which this linear combination is
equated.
public HashLinearComb<V> add(double constant)
constant
- the constant with which to add.
public HashLinearComb<V> add(LinearComb<? extends V> expression)
expression
- the linear combination with which to add.
public HashLinearComb<V> multiply(double constant)
constant
- the constant with which to multiply this linear
combination.
public java.util.Set<V> getVariables()
public boolean hasVariables()
true
if this expression contains at least
one variable; false
otherwise.public boolean hasAllVariables(java.util.Collection<?> variables)
variables
- the collection of variables whose
presence in this expression is to be tested.
true
if each element of the provided
collection is a variable in this expression;
false
otherwise.public boolean hasVariable(java.lang.Object variable)
variable
- the variable whose presence in this
mathematical expression is to be tested.
true
if this expression contains the
provided variable; false
otherwise.public int variables()
public java.util.Iterator<LinearComb.Term<V>> iterator()
iterator
in interface java.lang.Iterable<LinearComb.Term<V>>
iterator
in interface LinearComb<V>
iterator
in class AbstractLinearComb<V>
public static <V> HashLinearComb<V> singleTerm(V variable, double coefficient)
V
- the variable type.variable
- the variable.coefficient
- the coefficient.
public static <V> HashLinearComb<V> singleTerm(V variable, double coefficient, double zeroCutoff)
V
- the variable type.variable
- the variable.coefficient
- the coefficient.zeroCutoff
- the zero cutoff.
public static <V> HashLinearComb<V> singleTerm(double coefficient, V variable)
V
- the variable type.coefficient
- the coefficient.variable
- the variable.
public static <V> HashLinearComb<V> singleTerm(V variable)
V
- the variable type.variable
- the variable.
public static <V> HashLinearComb<V> singleTerm(LinearComb.Term<V> term)
V
- the variable type.term
- the term.
public static void main(java.lang.String[] args)
args
- none required.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |