FWIW, DoubleMatrix's dot will be much faster than this. I'd recommend designing your internal data structures to use DoubleMatrix.