Question: public static void main(String[] args) { int firstarray[][] = {{1, 2, -2, 0}, {-3, 4, 7, 2}, {6, 0, 3, 1}}; int secondarray[][] = {{-1,
public static void main(String[] args) {
int firstarray[][] = {{1, 2, -2, 0}, {-3, 4, 7, 2}, {6, 0, 3, 1}};
int secondarray[][] = {{-1, 3}, {0, 9}, {1, -11}, {4, -5}};
int [][] result = new int[firstarray.length][secondarray[0].length];
for (int i = 0; i < firstarray.length; i++) {
for (int j = 0; j < secondarray[0].length; j++) {
for (int k = 0; k < firstarray[0].length; k++) {
result[i][j] += firstarray[i][k] * secondarray[k][j];
}
}
}
}
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
example of parallelstreams
firstarray.parallelStream().forEach(i->{
System.out.println("hi");
});
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
