![JAR search and dependency download from the Maven repository](/logo.png)
mikera.vectorz.impl.SubMatrixViewVector 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.vectorz.impl;
import mikera.matrixx.AMatrix;
import mikera.vectorz.AVector;
/**
* A vector that wraps a sub-matrix of an arbitrary matrix
* @author Mike
*/
public class SubMatrixViewVector extends AMatrixViewVector {
private static final long serialVersionUID = -839770692590916488L;
private final int rowStart;
private final int colStart;
private final int rows;
private final int cols;
public SubMatrixViewVector(AMatrix source, int rowStart, int colStart, int rows, int cols) {
super(source,rows*cols);
source.checkRow(rowStart);
source.checkRow(rowStart+rows-1);
source.checkColumn(colStart);
source.checkColumn(colStart+cols-1);
this.rowStart=rowStart;
this.colStart=colStart;
this.rows=rows;
this.cols=cols;
}
@Override
public double get(int i) {
checkIndex(i);
return unsafeGet(i);
}
@Override
public void set(int i, double value) {
checkIndex(i);
unsafeSet(i,value);
}
@Override
public double unsafeGet(int i) {
return source.unsafeGet(calcRow(i), calcCol(i));
}
@Override
public void unsafeSet(int i, double value) {
source.unsafeSet(calcRow(i), calcCol(i),value);
}
@Override
public AVector exactClone() {
return new SubMatrixViewVector(source.exactClone(),rowStart,colStart,rows,cols);
}
@Override
public double dotProduct(double[] data, int offset) {
double result=0.0;
for (int i=0; i
© 2015 - 2025 Weber Informatics LLC | Privacy Policy