Package org.ojalgo.equation
Class Equation
- 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 int
index
The row index of the original body matrix, [A].private BasicArray<?>
myBody
The (nonzero) elements of this equation/rowprivate double
myPivot
private double
myRHS
-
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 void
add(long ind, double addend)
void
add(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)
int
compareTo(Equation other)
long
count()
The total number of elements in this structure.static Equation
dense(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)
double
dot(Access1D<?> vector)
Will calculate and return the dot product of this 1D-structure and another input 1D-vector.double
doubleValue(int ind)
boolean
equals(java.lang.Object obj)
java.lang.Double
get(long ind)
BasicArray<?>
getBody()
double[]
getCoefficients()
double
getPivot()
double
getRHS()
int
hashCode()
<T extends Access1D<java.lang.Double> & Mutate1D.Modifiable<java.lang.Double>>
voidinitialise(T x)
void
modifyOne(long ind, UnaryFunction<java.lang.Double> modifier)
static Equation
of(double rhs, int pivot, double... body)
void
set(long ind, double value)
void
set(long ind, java.lang.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 java.lang.Comparable<N>>
Equationsparse(int pivot, int cols, DenseArray.Factory<N> factory)
static <N extends java.lang.Comparable<N>>
Equationsparse(int pivot, int cols, DenseArray.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, DenseArray.Factory<N> factory)
static <N extends java.lang.Comparable<N>>
java.util.List<Equation>sparseSystem(int rows, int cols, DenseArray.Factory<N> factory, int numberOfNonzeros)
java.lang.String
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 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 <N extends java.lang.Comparable<N>> Equation sparse(int pivot, int cols, DenseArray.Factory<N> factory)
-
sparse
public static <N extends java.lang.Comparable<N>> Equation sparse(int pivot, int cols, DenseArray.Factory<N> factory, int numberOfNonzeros)
-
sparse
public static Equation sparse(int pivot, int cols, int numberOfNonzeros)
-
sparseSystem
public static java.util.List<Equation> sparseSystem(int rows, int cols)
-
sparseSystem
public static <N extends java.lang.Comparable<N>> java.util.List<Equation> sparseSystem(int rows, int cols, DenseArray.Factory<N> factory)
-
sparseSystem
public static <N extends java.lang.Comparable<N>> java.util.List<Equation> sparseSystem(int rows, int cols, DenseArray.Factory<N> factory, int numberOfNonzeros)
-
sparseSystem
public static java.util.List<Equation> sparseSystem(int rows, int cols, int numberOfNonzeros)
-
wrap
public static Equation wrap(BasicArray<?> body, int pivot, double rhs)
-
add
public void add(long ind, java.lang.Comparable<?> addend)
- Specified by:
add
in interfaceMutate1D.Modifiable<java.lang.Double>
-
add
public void add(long ind, double addend)
- Specified by:
add
in 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.- 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:
compareTo
in interfacejava.lang.Comparable<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
public double dot(Access1D<?> vector)
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<java.lang.Double>
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in 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:
hashCode
in classjava.lang.Object
-
initialise
public <T extends Access1D<java.lang.Double> & Mutate1D.Modifiable<java.lang.Double>> void initialise(T x)
-
modifyOne
public void modifyOne(long ind, UnaryFunction<java.lang.Double> modifier)
- Specified by:
modifyOne
in 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:Structure1D
The total number of elements in this structure.- Specified by:
size
in interfaceStructure1D
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
calculate
private <T extends Access1D<java.lang.Double> & Mutate1D.Modifiable<java.lang.Double>> double calculate(T x, double rhs, double relaxation)
-
-