Question: You are supposed to use the given template for implementing each of the problems. Additionally, your program will be given two arguments, path to an

You are supposed to use the given template for implementing each of the problems. Additionally, your program will be given two arguments, path to an input file and an output file from which your program will obtain the input and output the result into respectively, like the following (for C++): mpirun -np 11 ./a.out .

Let A be a full rank square matrix of N rows and N columns. Write a program to find the solution to the set of linear equations Ax = b using the Gaussian Elimination algorithm followed by back substitution. You can assume that A is partitioned into rows and the partitions are stored across the processes.

Input: First line will contain N, the size of the square matrix. The next N rows will contain N + 1 floating-point values each, where the value in the ith row at the jth place is the A[i][j] value when j N and b[i] if j is N + 1.

Output: A vector x which is the solution to Ax = b containing real numbers having absolute error less than 1e-6. Constraints: 1 <= N <= 102

Example: Sample Input: 3 1.0 5.0 11.0 -1.0 2.0 9.0 29.0 -2.0 -3.0 10.0 1.0 3.0 Sample Output: -1.0 0 0

Code should be written in the middle of the template given below, where it is written as "Enter your code here"

# include # include using namespace std ; int main ( int argc , char ** argv ) { int rank , numprocs ; // initiate MPI MPI_Init ( &argc , & argv ); // get size of the current communicator MPI_Comm_size ( MPI_COMM_WORLD , & numprocs ); // get current process rank MPI_Comm_rank ( MPI_COMM_WORLD , & rank ); /* synchronize all processes */ MPI_Barrier ( MPI_COMM_WORLD ); double start_time = MPI_Wtime (); // enter your code here MPI_Barrier ( MPI_COMM_WORLD ); double end_time = MPI_Wtime () - start_time ; double maxTime ; // get max program run time for all processes MPI_Reduce ( & end_time , & maxTime , 1, MPI_DOUBLE , MPI_MAX , 0, MPI_COMM_WORLD ); if ( rank == 0 ) { cout <<" Total time (s): " <

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!