List of usage examples for org.apache.commons.math3.linear ArrayRealVector cosine
public double cosine(RealVector v) throws DimensionMismatchException, MathArithmeticException
From source file:de.andreasschoknecht.LS3.Query.java
/** * Calculate the LSSM values with respect to a document collection. * * @param Sk The matrix Sk of singular values * @param Vtk The matrix Vtk of the singular value decomposition *///from w w w . j a v a 2 s. co m void calculateLSSMValues(RealMatrix Sk, RealMatrix Vtk) { // scale Vtk with singular value matrix Sk RealMatrix scaledVtk = Sk.multiply(Vtk); // the query model as vector ArrayRealVector queryVector = new ArrayRealVector(pseudoDocument); int docsNumber = scaledVtk.getColumnDimension(); lssmValues = new double[docsNumber]; for (int i = 0; i < docsNumber; i++) { RealVector columnVector = scaledVtk.getColumnVector(i); lssmValues[i] = (queryVector.cosine(columnVector) + 1) / 2; } }