// extracting these small methods makes things faster; hotspot likes them
 private static double[] MatrixMultiply(double[][] matrix, double[] vector)
 {
     double[] result = new double[matrix.Length];
     for (int i = 0; i < matrix.Length; i++)
     {
         result[i] = ArrayMath.DotProduct(matrix[i], vector);
     }
     return(result);
 }