Class RowMajorRealMatrix
- All Implemented Interfaces:
LinearOperator,RealMatrix,VectorOperator
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionapply(RealVector vector) Apply this operator to the vector passed in.final booleandouble[][]doublegetEntry(int row, int column) intintdouble[]getRow(int row) double[][]inthashCode()multiply(RealMatrix otherMatrix) Multiplies this matrix byotherMatrixand returns the row-major product.subMatrix(int startRow, int lengthRow, int startColumn, int lengthColumn) transposedApply(RealVector vector) Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.apple.foundationdb.linear.LinearOperator
getNumDimensions, invertedApply, isSquareMethods inherited from interface com.apple.foundationdb.linear.RealMatrix
isTransposable, valueBasedHashCode, valueEqualsMethods inherited from interface com.apple.foundationdb.linear.VectorOperator
transform, untransform
-
Constructor Details
-
RowMajorRealMatrix
public RowMajorRealMatrix(@Nonnull double[][] data)
-
-
Method Details
-
getNumRowDimensions
public int getNumRowDimensions()- Specified by:
getNumRowDimensionsin interfaceLinearOperator
-
getNumColumnDimensions
public int getNumColumnDimensions()- Specified by:
getNumColumnDimensionsin interfaceLinearOperator
-
getEntry
public double getEntry(int row, int column) - Specified by:
getEntryin interfaceRealMatrix
-
getRow
@Nonnull public double[] getRow(int row) -
transpose
- Specified by:
transposein interfaceRealMatrix
-
apply
Description copied from interface:VectorOperatorApply this operator to the vector passed in.- Specified by:
applyin interfaceRealMatrix- Specified by:
applyin interfaceVectorOperator- Parameters:
vector- the vector- Returns:
- a new vector
-
transposedApply
- Specified by:
transposedApplyin interfaceLinearOperator- Specified by:
transposedApplyin interfaceRealMatrix
-
multiply
Multiplies this matrix byotherMatrixand returns the row-major product.The implementation provides two SIMD fast paths plus a scalar triple-loop fallback. This is asymmetric to
ColumnMajorRealMatrix.multiply(com.apple.foundationdb.linear.RealMatrix), which gets by with a single universal AXPY path. The asymmetry is forced by storage layout — not an oversight — so the rest of this comment explains why the two methods can't share a shape.Matrix multiplication has two SIMD-able decompositions:
- Output-stationary dot:
C[i][j] = dot(A.row(i), B.col(j)). RequiresA.row(i)andB.col(j)to both be contiguous in memory. - Input-stationary AXPY:
C.row(i) += A[i][k] · B.row(k). RequiresC.row(i)andB.row(k)to both be contiguous.
What's contiguous depends on layout: a row-major matrix exposes contiguous rows and strided columns; a column-major matrix exposes contiguous columns and strided rows. So for row-major
A(this method), the decompositions split cleanly alongB's layout — shape (1) needs column-majorB, shape (2) needs row-majorB— and we need both specialized branches to keep every layout combination on a SIMD path. The scalar fallback below is dead code today (no otherRealMatrixsubtypes exist), but it preserves correctness for any future layout that doesn't surface a contiguous strip on either axis.Column-major
Adodges the split:ColumnMajorRealMatrix.multiply(com.apple.foundationdb.linear.RealMatrix)writesC.col(j) += B[k][j] · A.col(k), where the contiguous arrays it cares about (A.col(k)andC.col(j)) come fromAandCthemselves — never fromB. The only thingBcontributes per inner step is a single scalarB[k][j], which a virtualgetEntrycall delivers cheaply regardless ofB's layout. One universal AXPY path covers everyBthere.- Specified by:
multiplyin interfaceRealMatrix- Parameters:
otherMatrix- the right-hand operand; must satisfyotherMatrix.getNumRowDimensions() == this.getNumColumnDimensions()- Returns:
- a new
RowMajorRealMatrixcontaining the product
- Output-stationary dot:
-
subMatrix
@Nonnull public RowMajorRealMatrix subMatrix(int startRow, int lengthRow, int startColumn, int lengthColumn) - Specified by:
subMatrixin interfaceRealMatrix
-
toRowMajor
- Specified by:
toRowMajorin interfaceRealMatrix
-
getRowMajorData
@Nonnull public double[][] getRowMajorData()- Specified by:
getRowMajorDatain interfaceRealMatrix
-
toColumnMajor
- Specified by:
toColumnMajorin interfaceRealMatrix
-
getColumnMajorData
@Nonnull public double[][] getColumnMajorData()- Specified by:
getColumnMajorDatain interfaceRealMatrix
-
quickTranspose
- Specified by:
quickTransposein interfaceRealMatrix
-
flipMajor
- Specified by:
flipMajorin interfaceRealMatrix
-
equals
-
hashCode
public int hashCode()
-