Skip to content

Instantly share code, notes, and snippets.

@tkfx
Last active July 21, 2016 15:37
Show Gist options
  • Save tkfx/7ab93bf211d13e3d699d22d216685267 to your computer and use it in GitHub Desktop.
Save tkfx/7ab93bf211d13e3d699d22d216685267 to your computer and use it in GitHub Desktop.
private static double[] loopUnrolling2(double[][] matrix1, double[] vector1) {
double[] result = new double[vector1.length];
for (int i = 0; i < matrix1.length; i++) {
result[i] += matrix1[i][0] * vector1[0];
result[i] += matrix1[i][1] * vector1[1];
result[i] += matrix1[i][2] * vector1[2];
// and maybe it will expand even further - e.g. 4 iterations, thus
// adding code to fix the indexing
// which we would waste more time doing correctly and efficiently
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment