- java.lang.Object
-
- org.ojalgo.equation.Equation
-
- All Implemented Interfaces:
java.lang.Comparable<Equation>,Access1D<java.lang.Double>,Mutate1D.Modifiable<java.lang.Double>,Structure1D
public final class Equation extends java.lang.Object implements java.lang.Comparable<Equation>, Access1D<java.lang.Double>, Mutate1D.Modifiable<java.lang.Double>
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.ojalgo.structure.Access1D
Access1D.Aggregatable<N extends java.lang.Comparable<N>>, Access1D.Collectable<N extends java.lang.Comparable<N>,R extends Mutate1D>, Access1D.ElementView<N extends java.lang.Comparable<N>>, Access1D.SelectionView<N extends java.lang.Comparable<N>>, Access1D.Sliceable<N extends java.lang.Comparable<N>>, Access1D.Visitable<N extends java.lang.Comparable<N>>
-
Nested classes/interfaces inherited from interface org.ojalgo.structure.Structure1D
Structure1D.BasicMapper<T>, Structure1D.IndexMapper<T>, Structure1D.IntIndex, Structure1D.Logical<S extends Structure1D,B extends Structure1D.Logical<S,B>>, Structure1D.LongIndex, Structure1D.LoopCallback
-
-
Field Summary
Fields Modifier and Type Field Description intindexThe row index of the original body matrix, [A].private BasicArray<?>myBodyThe (nonzero) elements of this equation/rowprivate doublemyPivotprivate doublemyRHS
-
Constructor Summary
Constructors Constructor Description Equation(BasicArray<?> body, int pivot, double rhs)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(int ind, double addend)voidadd(long ind, java.lang.Comparable<?> addend)<T extends Access1D<java.lang.Double> & Mutate1D.Modifiable<java.lang.Double>>
doubleadjust(T x, double relaxation)Will perform a (relaxed) GaussSeidel update.private <T extends Access1D<java.lang.Double> & Mutate1D.Modifiable<java.lang.Double>>
doublecalculate(T x, double rhs, double relaxation)intcompareTo(Equation other)longcount()The total number of elements in this structure.static Equationdense(int pivot, int cols)static <N extends java.lang.Comparable<N>>
Equationdense(int pivot, int cols, DenseArray.Factory<N,?> factory)static java.util.List<Equation>denseSystem(int rows, int cols)static <N extends java.lang.Comparable<N>>
java.util.List<Equation>denseSystem(int rows, int cols, DenseArray.Factory<N,?> factory)doubledot(Access1D<?> vector)Will calculate and return the dot product of this 1D-structure and another input 1D-vector.doubledotLower(Access1D<?> x)Efficiently compute sum_{j < pivot} a_{ij} * x_j (excludes the pivot).doubledotUpper(Access1D<?> x)Efficiently compute sum_{j > pivot} a_{ij} * x_j (excludes the pivot).doubledoubleValue(int ind)booleanequals(java.lang.Object obj)java.lang.Doubleget(long ind)BasicArray<?>getBody()double[]getCoefficients()doublegetPivot()doublegetRHS()inthashCode()<T extends Access1D<java.lang.Double> & Mutate1D.Modifiable<java.lang.Double>>
voidinitialise(T x)Initialises the solution vector's element atindexto the value that would solve this equation if the RHS was zero and all other elements in the solution vector unchanged.voidmodifyOne(long ind, UnaryFunction<java.lang.Double> modifier)static Equationof(double rhs, int pivot, double... body)voidset(long ind, double value)voidset(long ind, java.lang.Comparable<?> value)voidsetRHS(double rhs)intsize()The total number of elements in this structure.static Equationsparse(int pivot, int cols)static Equationsparse(int pivot, int cols, int numberOfNonzeros)static <N extends java.lang.Comparable<N>>
Equationsparse(int pivot, int cols, PlainArray.Factory<N,?> factory)static <N extends java.lang.Comparable<N>>
Equationsparse(int pivot, int cols, PlainArray.Factory<N,?> factory, int numberOfNonzeros)static java.util.List<Equation>sparseSystem(int rows, int cols)static java.util.List<Equation>sparseSystem(int rows, int cols, int numberOfNonzeros)static <N extends java.lang.Comparable<N>>
java.util.List<Equation>sparseSystem(int rows, int cols, PlainArray.Factory<N,?> factory)static <N extends java.lang.Comparable<N>>
java.util.List<Equation>sparseSystem(int rows, int cols, PlainArray.Factory<N,?> factory, int numberOfNonzeros)java.lang.StringtoString()static Equationwrap(BasicArray<?> body, int pivot, double rhs)-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.ojalgo.structure.Access1D
asCollectable1D, asKeyed1D, asList, axpy, byteValue, byteValue, doubleValue, elements, floatValue, floatValue, intValue, intValue, longValue, longValue, nonzeros, select, shortValue, shortValue, supplyTo, toList, toRawCopy1D
-
Methods inherited from interface org.ojalgo.structure.Mutate1D.Modifiable
add, add, add, add, add, add, add, add, add, add, add, modifyAll, modifyMatching, modifyMatching, modifyRange
-
-
-
-
Field Detail
-
index
public final int index
The row index of the original body matrix, [A].
-
myBody
private final BasicArray<?> myBody
The (nonzero) elements of this equation/row
-
myPivot
private double myPivot
-
myRHS
private double myRHS
-
-
Constructor Detail
-
Equation
Equation(BasicArray<?> body, int pivot, double rhs)
-
-
Method Detail
-
dense
public static Equation dense(int pivot, int cols)
-
dense
public static <N extends java.lang.Comparable<N>> Equation dense(int pivot, int cols, DenseArray.Factory<N,?> factory)
-
denseSystem
public static java.util.List<Equation> denseSystem(int rows, int cols)
-
denseSystem
public static <N extends java.lang.Comparable<N>> java.util.List<Equation> denseSystem(int rows, int cols, DenseArray.Factory<N,?> factory)
-
of
public static Equation of(double rhs, int pivot, double... body)
-
sparse
public static Equation sparse(int pivot, int cols)
-
sparse
public static Equation sparse(int pivot, int cols, int numberOfNonzeros)
-
sparse
public static <N extends java.lang.Comparable<N>> Equation sparse(int pivot, int cols, PlainArray.Factory<N,?> factory)
-
sparse
public static <N extends java.lang.Comparable<N>> Equation sparse(int pivot, int cols, PlainArray.Factory<N,?> factory, int numberOfNonzeros)
-
sparseSystem
public static java.util.List<Equation> sparseSystem(int rows, int cols)
-
sparseSystem
public static java.util.List<Equation> sparseSystem(int rows, int cols, int numberOfNonzeros)
-
sparseSystem
public static <N extends java.lang.Comparable<N>> java.util.List<Equation> sparseSystem(int rows, int cols, PlainArray.Factory<N,?> factory)
-
sparseSystem
public static <N extends java.lang.Comparable<N>> java.util.List<Equation> sparseSystem(int rows, int cols, PlainArray.Factory<N,?> factory, int numberOfNonzeros)
-
wrap
public static Equation wrap(BasicArray<?> body, int pivot, double rhs)
-
add
public void add(int ind, double addend)- Specified by:
addin interfaceMutate1D.Modifiable<java.lang.Double>
-
add
public void add(long ind, java.lang.Comparable<?> addend)- Specified by:
addin interfaceMutate1D.Modifiable<java.lang.Double>
-
adjust
public <T extends Access1D<java.lang.Double> & Mutate1D.Modifiable<java.lang.Double>> double adjust(T x, double relaxation)
Will perform a (relaxed) GaussSeidel update.This call will not work if the pivot (the element at
index) is zero!- Parameters:
x- The current solution (one element will be updated)relaxation- Typically 1.0 but could be anything (Most likely should be between 0.0 and 2.0).- Returns:
- The error in this equation
-
compareTo
public int compareTo(Equation other)
- Specified by:
compareToin interfacejava.lang.Comparable<Equation>
-
count
public long count()
Description copied from interface:Structure1DThe total number of elements in this structure.You only need to implement this method if the structure can contain more than Integer.MAX_VALUE elements.
- Specified by:
countin interfaceStructure1D
-
dot
public double dot(Access1D<?> vector)
Description copied from interface:Access1DWill calculate and return the dot product of this 1D-structure and another input 1D-vector.
-
dotLower
public double dotLower(Access1D<?> x)
Efficiently compute sum_{j < pivot} a_{ij} * x_j (excludes the pivot). Uses direct sparse iteration when available to avoid O(n) random access scans.
-
dotUpper
public double dotUpper(Access1D<?> x)
Efficiently compute sum_{j > pivot} a_{ij} * x_j (excludes the pivot). Uses direct sparse iteration when available to avoid O(n) random access scans.
-
doubleValue
public double doubleValue(int ind)
- Specified by:
doubleValuein interfaceAccess1D<java.lang.Double>
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
get
public java.lang.Double get(long ind)
-
getBody
public BasicArray<?> getBody()
-
getCoefficients
public double[] getCoefficients()
-
getPivot
public double getPivot()
- Returns:
- The element at
index
-
getRHS
public double getRHS()
- Returns:
- The equation RHS
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
initialise
public <T extends Access1D<java.lang.Double> & Mutate1D.Modifiable<java.lang.Double>> void initialise(T x)
Initialises the solution vector's element atindexto the value that would solve this equation if the RHS was zero and all other elements in the solution vector unchanged.- Type Parameters:
T- The solution vector type- Parameters:
x- The solution vector to be initialised
-
modifyOne
public void modifyOne(long ind, UnaryFunction<java.lang.Double> modifier)- Specified by:
modifyOnein interfaceMutate1D.Modifiable<java.lang.Double>
-
set
public void set(long ind, java.lang.Comparable<?> value)
-
set
public void set(long ind, double value)
-
setRHS
public void setRHS(double rhs)
-
size
public int size()
Description copied from interface:Structure1DThe total number of elements in this structure.- Specified by:
sizein interfaceStructure1D
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
calculate
private <T extends Access1D<java.lang.Double> & Mutate1D.Modifiable<java.lang.Double>> double calculate(T x, double rhs, double relaxation)
-
-