Question: In this lab I am providing you with a code that performs the dot product on two matrices. I want you to edit this code
In this lab I am providing you with a code that performs the dot product on two
matrices.
I want you to edit this code so that we use multiprocessing fork where each
child calculates a rows of the resulting matrix.
Additionally please get the process ID of each child process that we create.
If you would like to edit the size of the matrices youre welcome to do so I
made them each x to start.
this is the code below please implement the answer related to the question I give you. and also show me the output
#include
#include
#include
void matrixmultiplyint rowsa int colsa int rowsb int colsb int a int
b
if rowsa colsb
printfDimensions mismatch.
;
return;
int result int mallocrowsa sizeofint ;
for int i ; i rowsa; i
resultiint malloccolsb sizeofint;
assertresulti NULL;
for int i ; i rowsa; i
for int j ; j colsb; j
resultij;
for int k ; k colsa; k
resultij aik bkj;
printfResult Matrix:
;
for int i ; i rowsa; i
for int j ; j colsb; j
printfd resultij;
printf
;
for int i ; i rowsa; i
freeresulti;
freeresult;
int main
int rowsa ;
int colsa ;
int rowsb ;
int colsb ;
int a int mallocrowsa sizeofint ;
forint i ; i rowsa; i
aiintmallocsizeofint colsa;
assertai NULL;
forint i ; i rowsa; i
forint j ; j colsb; j
aij i j;
printfContents of the array:
;
forint i ; i rowsa; i
forint j ; j colsb; j
printfd aij;
printf
;
int b int mallocrowsb sizeofint ;
forint i ; i rowsb; i
biintmallocsizeofint colsb;
assertai NULL;
forint i ; i rowsb; i
forint j ; j colsb; j
bij i j;
printfContents of the array:
;
forint i ; i rowsb; i
forint j ; j colsb; j
printfd bij;
printf
;
matrixmultiplyrowsa colsa rowsb colsb a b;
forint i ; i rowsb; i
freeai;
forint i ; i rowsb; i
freebi;
return ;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
