public class Strassen { public static double[][] multiply(double[][] A, double[][] B) { try { checkInputStrassen(A,B); } catch (RuntimeException e) { throw e; } return strassenRecursive(A,B); } private static double[][] reconstructAnswer(double[][] r, double[][] s, double[][] t, double[][] u) { int n = r.length*2; double[][] C = new double[n][n]; copyBack(C,r,0,0); copyBack(C,s,0,n/2); copyBack(C,t,n/2,0); copyBack(C,u,n/2,n/2); return C; } private static void copyBack(double[][] C, double[][] r, int x, int y) { for (int i=0; i1) { if (n%2 != 0) { throw new IllegalArgumentException("Non power of 2 matrix"); } n/=2; } int q = A[0].length; if (q==0) { throw new IllegalArgumentException("Null matrix"); } if (q!=p) { throw new IllegalArgumentException("Nonsquare Matrix"); } for (int i=1; i