Class Equation
java.lang.Object
org.ojalgo.equation.Equation
- All Implemented Interfaces:
Comparable<Equation>, Access1D<Double>, Mutate1D.Modifiable<Double>, Structure1D
public final class Equation
extends Object
implements Comparable<Equation>, Access1D<Double>, Mutate1D.Modifiable<Double>
-
Nested Class Summary
Nested classes/interfaces inherited from interface Access1D
Access1D.Aggregatable<N>, Access1D.Collectable<N,R>, Access1D.ElementView<N>, Access1D.SelectionView<N>, Access1D.Sliceable<N>, Access1D.Visitable<N> Nested classes/interfaces inherited from interface Structure1D
Structure1D.BasicMapper<T>, Structure1D.IndexMapper<T>, Structure1D.IntIndex, Structure1D.Logical<S,B>, Structure1D.LongIndex, Structure1D.LoopCallback -
Field Summary
FieldsModifier and TypeFieldDescriptionfinal intThe row index of the original body matrix, [A].private final BasicArray<?> The (nonzero) elements of this equation/rowprivate doubleprivate double -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(int ind, double addend) voidadd(long ind, Comparable<?> addend) <T extends Access1D<Double> & Mutate1D.Modifiable<Double>>
doubleadjust(T x, double relaxation) Will perform a (relaxed) GaussSeidel update.private <T extends Access1D<Double> & Mutate1D.Modifiable<Double>>
doublecalculate(T x, double rhs, double relaxation) intlongcount()The total number of elements in this structure.static Equationdense(int pivot, int cols) static <N extends Comparable<N>>
Equationdense(int pivot, int cols, DenseArray.Factory<N, ?> factory) denseSystem(int rows, int cols) static <N extends Comparable<N>>
List<Equation> denseSystem(int rows, int cols, DenseArray.Factory<N, ?> factory) doubleWill calculate and return the dot product of this 1D-structure and another input 1D-vector.doubleEfficiently compute sum_{j invalid input: '<' pivot} a_{ij} * x_j (excludes the pivot).doubleEfficiently compute sum_{j > pivot} a_{ij} * x_j (excludes the pivot).doubledoubleValue(int ind) booleanget(long ind) BasicArray<?> getBody()double[]doublegetPivot()doublegetRHS()inthashCode()<T extends Access1D<Double> & Mutate1D.Modifiable<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<Double> modifier) static Equationof(double rhs, int pivot, double... body) voidset(long ind, double value) voidset(long ind, 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 Comparable<N>>
Equationsparse(int pivot, int cols, PlainArray.Factory<N, ?> factory) static <N extends Comparable<N>>
Equationsparse(int pivot, int cols, PlainArray.Factory<N, ?> factory, int numberOfNonzeros) sparseSystem(int rows, int cols) sparseSystem(int rows, int cols, int numberOfNonzeros) static <N extends Comparable<N>>
List<Equation> sparseSystem(int rows, int cols, PlainArray.Factory<N, ?> factory) static <N extends Comparable<N>>
List<Equation> sparseSystem(int rows, int cols, PlainArray.Factory<N, ?> factory, int numberOfNonzeros) toString()static Equationwrap(BasicArray<?> body, int pivot, double rhs) Methods inherited from interface Access1D
asCollectable1D, asKeyed1D, asList, axpy, byteValue, byteValue, doubleValue, elements, floatValue, floatValue, intValue, intValue, longValue, longValue, nonzeros, select, shortValue, shortValue, supplyTo, toList, toRawCopy1DMethods inherited from interface Mutate1D.Modifiable
add, add, add, add, add, add, add, add, add, add, add, modifyAll, modifyMatching, modifyMatching, modifyRange
-
Field Details
-
index
public final int indexThe row index of the original body matrix, [A]. -
myBody
The (nonzero) elements of this equation/row -
myPivot
private double myPivot -
myRHS
private double myRHS
-
-
Constructor Details
-
Equation
Equation(BasicArray<?> body, int pivot, double rhs)
-
-
Method Details
-
dense
-
dense
public static <N extends Comparable<N>> Equation dense(int pivot, int cols, DenseArray.Factory<N, ?> factory) -
denseSystem
-
denseSystem
public static <N extends Comparable<N>> List<Equation> denseSystem(int rows, int cols, DenseArray.Factory<N, ?> factory) -
of
-
sparse
-
sparse
-
sparse
public static <N extends Comparable<N>> Equation sparse(int pivot, int cols, PlainArray.Factory<N, ?> factory) -
sparse
public static <N extends Comparable<N>> Equation sparse(int pivot, int cols, PlainArray.Factory<N, ?> factory, int numberOfNonzeros) -
sparseSystem
-
sparseSystem
-
sparseSystem
public static <N extends Comparable<N>> List<Equation> sparseSystem(int rows, int cols, PlainArray.Factory<N, ?> factory) -
sparseSystem
public static <N extends Comparable<N>> List<Equation> sparseSystem(int rows, int cols, PlainArray.Factory<N, ?> factory, int numberOfNonzeros) -
wrap
-
add
public void add(int ind, double addend) - Specified by:
addin interfaceMutate1D.Modifiable<Double>
-
add
- Specified by:
addin interfaceMutate1D.Modifiable<Double>
-
adjust
public <T extends Access1D<Double> & Mutate1D.Modifiable<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
- Specified by:
compareToin interfaceComparable<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
-
dotLower
Efficiently compute sum_{j invalid input: '<' pivot} a_{ij} * x_j (excludes the pivot). Uses direct sparse iteration when available to avoid O(n) random access scans. -
dotUpper
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<Double>
-
equals
-
get
-
getBody
-
getCoefficients
public double[] getCoefficients() -
getPivot
public double getPivot()- Returns:
- The element at
index
-
getRHS
public double getRHS()- Returns:
- The equation RHS
-
hashCode
-
initialise
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
- Specified by:
modifyOnein interfaceMutate1D.Modifiable<Double>
-
set
-
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
-
calculate
private <T extends Access1D<Double> & Mutate1D.Modifiable<Double>> double calculate(T x, double rhs, double relaxation)
-