/************************************************************ File: cholesky_master.cc Description: A program that inputs a matrix from a file and computes the Cholesky decomposition using several processes. Author: Dana Vrajitoru Organization: IUSB Date: August 16, 2002 **************************************************************/ #include #include #include #include #include "cholesky_master.h" #include "common.h" // Asks for the file name, reads the matrix from the file, and sends // each line to the corresponding slave process. void Read_matrix(int proc_nr) { int i, j, size=proc_nr-1; char filename[20]; float *a; a = new float[proc_nr-1]; cout << "Enter the file name containing the matrix" << endl; cin >> filename; ifstream fin(filename); if (fin.good()) { for (i=1; i> a[j]; Send_float_array(i, a, size); } fin.close(); } else cout << "Could not open the file" << endl; } // Asks for a file name for the result, collects the resulting matrix // by line from the slave processes, then writes it to the file. Since // the resulting matrix is 0 above the diagonal, the master only // receives the part of the matrix on and below the diagonal. void Write_solution(int proc_nr) { int i, j; char filename[20]; float *a; a = new float[proc_nr-1]; cout << "Enter the file name for the result" << endl; cin >> filename; ofstream fout(filename); if (fout.good()) { for (i=1; i