org.ojalgo.matrix.store
Class PrimitiveDenseStore

java.lang.Object
  extended by org.ojalgo.array.PrimitiveArray
      extended by org.ojalgo.matrix.store.PrimitiveDenseStore
All Implemented Interfaces:
Serializable, CholeskyDecomposition.CholeskyStore<Double>, LUDecomposition.LUStore<Double>, QRDecomposition.QRStore<Double>, MatrixStore<Double>, PhysicalStore<Double>

public final class PrimitiveDenseStore
extends PrimitiveArray
implements PhysicalStore<Double>, CholeskyDecomposition.CholeskyStore<Double>, LUDecomposition.LUStore<Double>, QRDecomposition.QRStore<Double>, Serializable

A Double (actually double) implementation of PhysicalStore.

Author:
apete
See Also:
Serialized Form

Field Summary
static PhysicalFactory<Double> FACTORY
           
 int length
           
 
Method Summary
 void add(Double aNmbr)
           
 void add(PhysicalStore<Double> aStore)
           
 void applyHouseholder(int aFirstTargetCol, MatrixStore<Double> aHouseholderStore, int aHouseholderCol, Object aColumnArray)
           
 Double calculateColumnNorm(int aRow, int aCol, int aDegree)
           
 Double calculateRowNorm(int aRow, int aCol, int aDegree)
           
 Double calculateTrace()
           
 Double calculateVectorNorm(int aDegree)
           
 Double calculateVectorProduct(PhysicalStore<Double> aStore)
           
 boolean computeCholesky()
           
 LUDecomposition.Pivot computeLU()
           
 void computeQR()
           
 PrimitiveDenseStore copy()
          Each call must produce a new instance.
 Double countNonZeroElements()
           
 void divide(Double aNmbr)
           
 void divideElements(PhysicalStore<Double> aStore)
           
 double doubleValue(int aRow, int aCol)
           
 boolean equals(PhysicalStore<Double> aStore, NumberContext aCntxt)
           
 void exchangeRows(int aRowA, int aRowB)
           
 int getColDim()
           
 Double getLargestElement()
           
 int getMinDim()
           
 Double getNumber(int aRow, int aCol)
           
 PhysicalFactory<Double> getPhysicalFactory()
           
 int getRowDim()
           
 boolean isAbsolute(int aRow, int aCol)
           
 boolean isLowerLeftShaded()
           The lower (left) triangle is shaded leaving an upper Hessenberg matrix.
 boolean isShaded()
           Either the lower (left) or the upper (right) triangles are shaded.
 boolean isUpperRightShaded()
           The upper (right) triangle is shaded leaving a lower Hessenberg matrix.
 boolean isZero(int aRow, int aCol)
           
 void multiply(Double aNmbr)
           
 Double multiplyBothSides(MatrixStore<Double> aStore)
          Calculates [aStore]T[this][aStore] as in a quadratic function [x]T[Q][x].
 void multiplyElements(PhysicalStore<Double> aStore)
           
 MatrixStore<Double> multiplyLeft(MatrixStore<Double> aStore)
           
 void multiplyLeft(Rotation<Double> aRotation)
           
 MatrixStore<Double> multiplyRight(MatrixStore<Double> aStore)
           
 void multiplyRight(Rotation<Double> aRotation)
           
 void negateAll()
           
 void rotateLeft(int aLowerIndex, int aHigherIndex, Double anAngle)
           As in MatrixStore.multiplyLeft(MatrixStore) where the left/parameter matrix is a plane rotation.
 void rotateRight(int aLowerIndex, int aHigherIndex, Double anAngle)
           As in MatrixStore.multiplyRight(MatrixStore) where the right/parameter matrix is a plane rotation.
 void set(int aRow, int aCol, double aNmbr)
           
 void set(int aRow, int aCol, Double aNmbr)
           
 void shadeLowerLeft()
           Shades the lower (left) triangle, leaving an upper Hessenberg matrix.
 void shadeUpperRight()
           Shades the upper (right) triangle, leaving a lower Hessenberg matrix.
 int size()
           
 void substituteBackwards(MatrixStore<Double> aBody, boolean assumeOne)
           
 void substituteForwards(MatrixStore<Double> aBody, boolean assumeOne)
           
 void subtract(Double aNmbr)
           
 void subtract(PhysicalStore<Double> aStore)
           
 List<Double> toList()
           
 PhysicalStore<Double> toPhysicalStore()
          May (probably will) return the same instance with every call.
 double[][] toRawCopy()
           
 Scalar<Double> toScalar(int aRow, int aCol)
           
 String toString()
           
 Array1Dim<N> toUtility1Dim()
           A utility facade that conveniently/consistently presents the BasicArray as a one-dimensional array.
 Array2Dim<N> toUtility2Dim()
           A utility facade that conveniently/consistently presents the BasicArray as a two-dimensional array.
 ArrayAnyDim<N> toUtilityAnyDim()
           A utility facade that conveniently/consistently presents the BasicArray as a multi-dimensional array.
 void unshade()
          Unshades both the lower (left) and upper (right) triangles.
 
Methods inherited from class org.ojalgo.array.PrimitiveArray
doubleValue, enforceAll, equals, equals, exchangeSets, fillAll, fillOne, fillSet, fillSet, getNumber, hashCode, isAbsolute, isReal, isZero, modifyAll, modifyAll, modifyAll, modifyOne, modifyOne, modifyOne, modifySet, modifySet, modifySet, modifySet, modifySet, modifySet, searchAscending, sortAscending, toScalar, visitAll, visitOne, visitSet, visitSet
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.ojalgo.matrix.store.PhysicalStore
enforceAll, fillAll, visitAll
 

Field Detail

FACTORY

public static final PhysicalFactory<Double> FACTORY

length

public final int length
Method Detail

add

public void add(Double aNmbr)
Specified by:
add in interface PhysicalStore<Double>

add

public void add(PhysicalStore<Double> aStore)
Specified by:
add in interface PhysicalStore<Double>

applyHouseholder

public void applyHouseholder(int aFirstTargetCol,
                             MatrixStore<Double> aHouseholderStore,
                             int aHouseholderCol,
                             Object aColumnArray)
Parameters:
aFirstTargetCol - The first column of "this" to be transformed.
aHouseholderStore - The MatrixStore where the householder column is stored.
aHouseholderCol - the index of the householder column in aHouseholderStore.
aColumnArray - An array (values not set) for internal/temporary storage of the householder column. Should be of type N[] or double[].

calculateColumnNorm

public Double calculateColumnNorm(int aRow,
                                  int aCol,
                                  int aDegree)
Specified by:
calculateColumnNorm in interface PhysicalStore<Double>

calculateRowNorm

public Double calculateRowNorm(int aRow,
                               int aCol,
                               int aDegree)
Specified by:
calculateRowNorm in interface PhysicalStore<Double>

calculateTrace

public Double calculateTrace()
Specified by:
calculateTrace in interface PhysicalStore<Double>

calculateVectorNorm

public Double calculateVectorNorm(int aDegree)
Specified by:
calculateVectorNorm in interface PhysicalStore<Double>

calculateVectorProduct

public Double calculateVectorProduct(PhysicalStore<Double> aStore)
Specified by:
calculateVectorProduct in interface PhysicalStore<Double>

computeCholesky

public boolean computeCholesky()
Specified by:
computeCholesky in interface CholeskyDecomposition.CholeskyStore<Double>

computeLU

public LUDecomposition.Pivot computeLU()
Specified by:
computeLU in interface LUDecomposition.LUStore<Double>
See Also:
LUDecomposition.LUStore.computeLU()

computeQR

public void computeQR()
Specified by:
computeQR in interface QRDecomposition.QRStore<Double>

copy

public PrimitiveDenseStore copy()
Description copied from interface: PhysicalStore
Each call must produce a new instance.

Specified by:
copy in interface PhysicalStore<Double>
Returns:
A new PhysicalStore copy.

countNonZeroElements

public Double countNonZeroElements()
Specified by:
countNonZeroElements in interface PhysicalStore<Double>

divide

public void divide(Double aNmbr)
Specified by:
divide in interface PhysicalStore<Double>

divideElements

public void divideElements(PhysicalStore<Double> aStore)
Specified by:
divideElements in interface PhysicalStore<Double>

doubleValue

public double doubleValue(int aRow,
                          int aCol)
Specified by:
doubleValue in interface MatrixStore<Double>

equals

public boolean equals(PhysicalStore<Double> aStore,
                      NumberContext aCntxt)
Specified by:
equals in interface PhysicalStore<Double>

exchangeRows

public void exchangeRows(int aRowA,
                         int aRowB)
Specified by:
exchangeRows in interface PhysicalStore<Double>

getColDim

public int getColDim()
Specified by:
getColDim in interface MatrixStore<Double>

getLargestElement

public Double getLargestElement()
Specified by:
getLargestElement in interface PhysicalStore<Double>

getMinDim

public int getMinDim()
Specified by:
getMinDim in interface MatrixStore<Double>

getNumber

public Double getNumber(int aRow,
                        int aCol)
Specified by:
getNumber in interface MatrixStore<Double>

getPhysicalFactory

public PhysicalFactory<Double> getPhysicalFactory()
Specified by:
getPhysicalFactory in interface MatrixStore<Double>

getRowDim

public int getRowDim()
Specified by:
getRowDim in interface MatrixStore<Double>

isAbsolute

public boolean isAbsolute(int aRow,
                          int aCol)
Specified by:
isAbsolute in interface PhysicalStore<Double>

isLowerLeftShaded

public boolean isLowerLeftShaded()
Description copied from interface: MatrixStore

The lower (left) triangle is shaded leaving an upper Hessenberg matrix.

Specified by:
isLowerLeftShaded in interface MatrixStore<Double>
See Also:
MatrixStore.isUpperRightShaded(), MatrixStore.isShaded(), PhysicalStore.shadeLowerLeft(), PhysicalStore.unshade()

isShaded

public boolean isShaded()
Description copied from interface: MatrixStore

Either the lower (left) or the upper (right) triangles are shaded.

Shading part of a MatrixStore causes that part to be ignored (as if it had zero valued elements) when doing matrix multiplication. It is possible to shade part of a PhysicalStore even though the shaded elements are not actually zero valued. Calling doubleValue(i, j), getNumber(i, j) or toScalar(i, j) will return the actual stored value.

Specified by:
isShaded in interface MatrixStore<Double>
See Also:
MatrixStore.isLowerLeftShaded(), MatrixStore.isUpperRightShaded(), PhysicalStore.unshade()

isUpperRightShaded

public boolean isUpperRightShaded()
Description copied from interface: MatrixStore

The upper (right) triangle is shaded leaving a lower Hessenberg matrix.

Specified by:
isUpperRightShaded in interface MatrixStore<Double>
See Also:
MatrixStore.isLowerLeftShaded(), MatrixStore.isShaded(), PhysicalStore.shadeUpperRight(), PhysicalStore.unshade()

isZero

public boolean isZero(int aRow,
                      int aCol)
Specified by:
isZero in interface PhysicalStore<Double>

multiply

public void multiply(Double aNmbr)
Specified by:
multiply in interface PhysicalStore<Double>

multiplyBothSides

public Double multiplyBothSides(MatrixStore<Double> aStore)
Description copied from interface: MatrixStore
Calculates [aStore]T[this][aStore] as in a quadratic function [x]T[Q][x]. The input parameter is assumed to be a vector, but it does not matter if it's a row vector or a column vector. "this" is assumed to be a square matrix. Instead of returning a 1-by-1 matrix this method returns a scalar.

Specified by:
multiplyBothSides in interface MatrixStore<Double>

multiplyElements

public void multiplyElements(PhysicalStore<Double> aStore)
Specified by:
multiplyElements in interface PhysicalStore<Double>

multiplyLeft

public MatrixStore<Double> multiplyLeft(MatrixStore<Double> aStore)
Specified by:
multiplyLeft in interface MatrixStore<Double>

multiplyLeft

public void multiplyLeft(Rotation<Double> aRotation)
Specified by:
multiplyLeft in interface PhysicalStore<Double>

multiplyRight

public MatrixStore<Double> multiplyRight(MatrixStore<Double> aStore)
Specified by:
multiplyRight in interface MatrixStore<Double>

multiplyRight

public void multiplyRight(Rotation<Double> aRotation)
Specified by:
multiplyRight in interface PhysicalStore<Double>

negateAll

public void negateAll()
Specified by:
negateAll in interface PhysicalStore<Double>

rotateLeft

public void rotateLeft(int aLowerIndex,
                       int aHigherIndex,
                       Double anAngle)
Description copied from interface: PhysicalStore

As in MatrixStore.multiplyLeft(MatrixStore) where the left/parameter matrix is a plane rotation.

Multiplying by a plane rotation from the left means that [this] gets two of its rows updated to new combinations of those two (current) rows.

There are two ways to transpose/invert a rotation. Either you negate the angle or you interchange the two indeces that define the rotation plane.

Specified by:
rotateLeft in interface PhysicalStore<Double>
See Also:
PhysicalStore.rotateRight(int, int, Number)

rotateRight

public void rotateRight(int aLowerIndex,
                        int aHigherIndex,
                        Double anAngle)
Description copied from interface: PhysicalStore

As in MatrixStore.multiplyRight(MatrixStore) where the right/parameter matrix is a plane rotation.

Multiplying by a plane rotation from the right means that [this] gets two of its columns updated to new combinations of those two (current) columns.

There result is undefined if the two input indeces are the same (in which case the rotation plane is undefined).

Specified by:
rotateRight in interface PhysicalStore<Double>
See Also:
PhysicalStore.rotateLeft(int, int, Number)

set

public void set(int aRow,
                int aCol,
                double aNmbr)
Specified by:
set in interface PhysicalStore<Double>

set

public void set(int aRow,
                int aCol,
                Double aNmbr)
Specified by:
set in interface PhysicalStore<Double>

shadeLowerLeft

public void shadeLowerLeft()
Description copied from interface: PhysicalStore

Shades the lower (left) triangle, leaving an upper Hessenberg matrix.

Specified by:
shadeLowerLeft in interface PhysicalStore<Double>
See Also:
PhysicalStore.unshade()

shadeUpperRight

public void shadeUpperRight()
Description copied from interface: PhysicalStore

Shades the upper (right) triangle, leaving a lower Hessenberg matrix.

Specified by:
shadeUpperRight in interface PhysicalStore<Double>
See Also:
PhysicalStore.unshade()

substituteBackwards

public void substituteBackwards(MatrixStore<Double> aBody,
                                boolean assumeOne)

substituteForwards

public void substituteForwards(MatrixStore<Double> aBody,
                               boolean assumeOne)

subtract

public void subtract(Double aNmbr)
Specified by:
subtract in interface PhysicalStore<Double>

subtract

public void subtract(PhysicalStore<Double> aStore)
Specified by:
subtract in interface PhysicalStore<Double>

toList

public List<Double> toList()
Specified by:
toList in interface PhysicalStore<Double>

toPhysicalStore

public PhysicalStore<Double> toPhysicalStore()
Description copied from interface: MatrixStore
May (probably will) return the same instance with every call. PhysicalStore instances are mutable. If you plan to modify it you should make a copy first. Depending on what you do with the PhysicalStore you may have to unshade it.

Specified by:
toPhysicalStore in interface MatrixStore<Double>
Returns:
A PhysicalStore representation of this MatrixStore.
See Also:
PhysicalStore.copy(), PhysicalStore.unshade()

toRawCopy

public double[][] toRawCopy()
Specified by:
toRawCopy in interface PhysicalStore<Double>

toScalar

public Scalar<Double> toScalar(int aRow,
                               int aCol)
Specified by:
toScalar in interface MatrixStore<Double>

unshade

public void unshade()
Description copied from interface: PhysicalStore
Unshades both the lower (left) and upper (right) triangles.

Specified by:
unshade in interface PhysicalStore<Double>
See Also:
PhysicalStore.shadeLowerLeft(), PhysicalStore.shadeUpperRight()

size

public final int size()

toString

public final String toString()
Overrides:
toString in class Object

toUtility1Dim

public final Array1Dim<N> toUtility1Dim()

A utility facade that conveniently/consistently presents the BasicArray as a one-dimensional array. Note that you will modify the actual array by accessing it through this facade.

Disregards the array structure, and simply treats it as one-domensional.


toUtility2Dim

public final Array2Dim<N> toUtility2Dim()

A utility facade that conveniently/consistently presents the BasicArray as a two-dimensional array. Note that you will modify the actual array by accessing it through this facade.

If "this" has more than two dimensions then only the first plane of the first cube of the first... is used/accessed. If this only has one dimension then everything is assumed to be in the first column of the first plane of the first cube...


toUtilityAnyDim

public final ArrayAnyDim<N> toUtilityAnyDim()

A utility facade that conveniently/consistently presents the BasicArray as a multi-dimensional array. Note that you will modify the actual array by accessing it through this facade.