Skip to content

Instantly share code, notes, and snippets.

@arestifo
Created May 29, 2015 16:38
Show Gist options
  • Select an option

  • Save arestifo/0b1ad7aaad096f70d64f to your computer and use it in GitHub Desktop.

Select an option

Save arestifo/0b1ad7aaad096f70d64f to your computer and use it in GitHub Desktop.
Matrix multiplication class (actual multiplication)
package com.bcchack.ap;
public class MatrixMultiply {
public static int[][] multiplyMatrices(int[][] a, int[][] b)
{
int[][] ret = new int[a.length][b[0].length];
for (int row = 0; row < a.length; row++)
{
for (int col = 0; col < b[0].length; col++)
{
for (int col2 = 0; col2 < a[0].length; col2++)
{
ret[row][col] += a[row][col2] * b[col2][col];
}
}
}
return ret;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment