Package org.ojalgo.equation
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 org.ojalgo.structure.Access1D
Access1D.Aggregatable<N extends Comparable<N>>, Access1D.Collectable<N extends Comparable<N>,
R extends Mutate1D>, Access1D.ElementView<N extends Comparable<N>>, Access1D.SelectionView<N extends Comparable<N>>, Access1D.Sliceable<N extends Comparable<N>>, Access1D.Visitable<N extends 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
FieldsModifier and TypeFieldDescriptionfinal int
The row index of the original body matrix, [A].private final BasicArray
<?> The (nonzero) elements of this equation/rowprivate double
private double
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(long ind, double addend) void
add
(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) int
long
count()
The total number of elements in this structure.static Equation
dense
(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) double
Will calculate and return the dot product of this 1D-structure and another input 1D-vector.double
doubleValue
(int ind) boolean
get
(long ind) BasicArray
<?> getBody()
double[]
double
getPivot()
double
getRHS()
int
hashCode()
<T extends Access1D<Double> & Mutate1D.Modifiable<Double>>
voidinitialise
(T x) void
modifyOne
(long ind, UnaryFunction<Double> modifier) static Equation
of
(double rhs, int pivot, double... body) void
set
(long ind, double value) void
set
(long ind, Comparable<?> value) void
setRHS
(double rhs) int
size()
The total number of elements in this structure.static Equation
sparse
(int pivot, int cols) static Equation
sparse
(int pivot, int cols, int numberOfNonzeros) static <N extends Comparable<N>>
Equationsparse
(int pivot, int cols, DenseArray.Factory<N> factory) static <N extends Comparable<N>>
Equationsparse
(int pivot, int cols, DenseArray.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, DenseArray.Factory<N> factory) static <N extends Comparable<N>>
List<Equation> sparseSystem
(int rows, int cols, DenseArray.Factory<N> factory, int numberOfNonzeros) toString()
static Equation
wrap
(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, axpy, byteValue, byteValue, doubleValue, elements, floatValue, floatValue, intValue, intValue, longValue, longValue, nonzeros, select, shortValue, shortValue, supplyTo, toRawCopy1D
Methods inherited from interface org.ojalgo.structure.Mutate1D.Modifiable
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
public static <N extends Comparable<N>> Equation sparse(int pivot, int cols, DenseArray.Factory<N> factory) -
sparse
public static <N extends Comparable<N>> Equation sparse(int pivot, int cols, DenseArray.Factory<N> factory, int numberOfNonzeros) -
sparse
-
sparseSystem
-
sparseSystem
public static <N extends Comparable<N>> List<Equation> sparseSystem(int rows, int cols, DenseArray.Factory<N> factory) -
sparseSystem
public static <N extends Comparable<N>> List<Equation> sparseSystem(int rows, int cols, DenseArray.Factory<N> factory, int numberOfNonzeros) -
sparseSystem
-
wrap
-
add
- Specified by:
add
in interfaceMutate1D.Modifiable<Double>
-
add
public void add(long ind, double addend) - Specified by:
add
in interfaceMutate1D.Modifiable<Double>
-
adjust
public <T extends Access1D<Double> & Mutate1D.Modifiable<Double>> double adjust(T x, double relaxation) Will perform a (relaxed) GaussSeidel update.- 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:
compareTo
in interfaceComparable<Equation>
-
count
public long count()Description copied from interface:Structure1D
The 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:
count
in interfaceStructure1D
-
dot
Description copied from interface:Access1D
Will calculate and return the dot product of this 1D-structure and another input 1D-vector. -
doubleValue
public double doubleValue(int ind) - Specified by:
doubleValue
in 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
public int hashCode() -
initialise
-
modifyOne
- Specified by:
modifyOne
in 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:Structure1D
The total number of elements in this structure.- Specified by:
size
in interfaceStructure1D
-
toString
-
calculate
private <T extends Access1D<Double> & Mutate1D.Modifiable<Double>> double calculate(T x, double rhs, double relaxation)
-