Question: C++ Correct the program listed below to use OpenMP Prarallel Loop (for) to multiply a matrix by a vector. Add a clause default(none) to declare

C++
Correct the program listed below to use OpenMP Prarallel Loop (for) to multiply a matrix by a vector.
Add a clause default(none) to declare a range of variables used inside a parallel block.
Describe what command you will use to compile this program in the terminal (which uses OpenMP) and the command to run this program from the terminal.
#include
#include
#define M 16
#define N 16
void mxv(int m, int n, double * a, double * b, double * c)
{
int i, j;
for(i=0;i
{
a[i]=0.0;
// a loop that computes the product of the i-th row of matrix b
// and the vector c, the result is the i-th element of the vector a
for(j=0;j
a[i]+=b[i*n+j]*c[j]; //a[i]=b[i][j]*c[j]
}
}
int main(){
double A[M], B[M*N], C[N];
int k, l;
// matrix initialization
for(k=0; k
for(l=0;l
C[l]=l*1.0;
B[k*N+l]=l*0.1+k;
}
// calculata vector A
mxv(M, N, A, B, C);
for(k=0; k
printf("%5.2f ",A[k]);
printf(" ");
return 0;
}

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!