mikera.matrixx.impl.MatrixRowView 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 mikera.matrixx.AMatrix;
import mikera.vectorz.AVector;
import mikera.vectorz.Op;
import mikera.vectorz.Op2;
import mikera.vectorz.impl.AMatrixViewVector;
/**
* A class representing a view of a matrix row as a vector.
*
* Used where no better implementations for getRowView(...) on a matrix exist.
*
* @author Mike
*/
@SuppressWarnings("serial")
public final class MatrixRowView extends AMatrixViewVector {
private final int row;
public MatrixRowView(AMatrix aMatrix, int row) {
super(aMatrix,aMatrix.columnCount());
aMatrix.checkRow(row);
this.row = row;
}
@Override
public double get(int i) {
return source.get(row, i);
}
@Override
public double unsafeGet(int i) {
return source.unsafeGet(row, i);
}
@Override
public void set(int i, double value) {
source.set(row, i, value);
}
@Override
public void unsafeSet(int i, double value) {
source.unsafeSet(row, i, value);
}
@Override
public boolean isFullyMutable() {
return source.isFullyMutable();
}
@Override
public MatrixRowView exactClone() {
return new MatrixRowView(source.exactClone(), row);
}
@Override public void getElements(double[] data, int offset) {
source.copyRowTo(row,data,offset);
}
@Override
protected int calcRow(int i) {
return row;
}
@Override
protected int calcCol(int i) {
return i;
}
@Override
public AVector clone() {
return source.getRowClone(row);
}
@Override
public boolean equals(AVector v) {
if (v==this) return true;
if (v.length()!=length) return false;
for (int i=0; i
© 2015 - 2025 Weber Informatics LLC | Privacy Policy