mikera.matrixx.impl.DenseColumnMatrix Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of vectorz Show documentation
Show all versions of vectorz Show documentation
Fast double-precision vector and matrix maths library for Java, supporting N-dimensional numeric arrays.
package mikera.matrixx.impl;
import java.util.Arrays;
import mikera.arrayz.impl.IDense;
import mikera.matrixx.AMatrix;
import mikera.matrixx.Matrix;
import mikera.vectorz.AVector;
import mikera.vectorz.Op;
import mikera.vectorz.impl.ArraySubVector;
import mikera.vectorz.util.DoubleArrays;
/**
* A densely packed matrix organised in column-major format.
*
* Transposes to/from a regular dense Matrix
*
* This class is useful if your main performance requirement is fast access to columns of a matrix.
* This is frequently true when the matrix is used as the *second* argument in matrix/matrix operations.
*
* @author Mike
*
*/
public final class DenseColumnMatrix extends AStridedMatrix implements IFastColumns, IDense {
private static final long serialVersionUID = 5459617932072332096L;
private DenseColumnMatrix(int rowCount, int columnCount, double[] data) {
super(data, rowCount, columnCount);
}
private DenseColumnMatrix(int rowCount, int columnCount) {
this(rowCount, columnCount, DoubleArrays.createStorage(rowCount, columnCount));
}
public static DenseColumnMatrix wrap(int rows, int cols, double[] data) {
return new DenseColumnMatrix(rows, cols, data);
}
public static DenseColumnMatrix create(AMatrix m) {
DenseColumnMatrix dm= new DenseColumnMatrix(m.rowCount(), m.columnCount());
dm.set(m);
return dm;
}
@Override
public int getArrayOffset() {
return 0;
}
@Override
public int rowStride() {
return 1;
}
@Override
public int columnStride() {
return rows;
}
@Override
public ArraySubVector getColumn(int j) {
return ArraySubVector.wrap(data, j*rows, rows);
}
@Override
public void copyRowTo(int i, double[] dest, int destOffset) {
for (int j=0; j
© 2015 - 2025 Weber Informatics LLC | Privacy Policy