Question: public class matrix { public static void main(String[] args) { mul(); } static int b[][]={{21,21},{22,22}}; static int a[][] ={{1,1},{2,2}}; public static void mul(){ int c[][]

public class matrix

{

public static void main(String[] args) {

mul();

}

static int b[][]={{21,21},{22,22}};

static int a[][] ={{1,1},{2,2}};

public static void mul(){

int c[][] = new int[2][2];

long startTime = System.nanoTime();

b.parallelStream().forEach(-->{

System.out.println(" ");

});

for(int i=0;i

for(int j=0;j

c[i][j] =0;

}

}

for(int i=0;i

for(int j=0;j

for(int k=0;k

c[i][j]= c[i][j] +(a[i][k] * b[k][j]);

}

}

}

for(int i=0;i

for(int j=0;j

System.out.print(c[i][j]);

}

System.out.println(" ");

}

long endTime = System.nanoTime() - startTime;

System.out.println(endTime*Math.pow(10,-9));

}

}

IN JAVA

Please uses parallelStreams() in java to parallelize the for loops for matrix multiplication. It says you cannot use paralleStreams on ints. If that is true please adjust starter code

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!