maths.MatrixVectorOperations Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jstat Show documentation
Show all versions of jstat Show documentation
Java Library for Statistical Analysis.
The newest version!
package maths;
import datasets.DenseMatrixSet;
import datasets.VectorDouble;
import datastructs.IVector;
/**
* Implements common matrix-vector operations
*/
public class MatrixVectorOperations {
/**
* Computes y = M*x
*/
public static final IVector dot(DenseMatrixSet mat, VectorDouble x){
if(mat.n() != x.size()){
throw new IllegalStateException("Matrix columns "+mat.n()+" and vector " +
" size " +x.size() +" are not equal.");
}
IVector rslt = new VectorDouble(mat.m());
for(int r=0; r row = mat.getRow(r);
rslt.set(r, VectorOperations.dotProduct(row, x));
}
return rslt;
}
}