All Downloads are FREE. Search and download functionalities are using the official Maven repository.

maths.MatrixVectorOperations Maven / Gradle / Ivy

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;
    }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy