/********* smvp.cc ************ smvp computes a sequence of matrix vector products and uses them to compute the minimum polynomial of matrix A. Version 1. Illustrates forming a new communicator The name of a file containing A is given in a command line parameter. in file (u, A, v, root, comm ) computes Requires 2 or more processes. ******************************* One process stays out of the new communicator. It's role is to use the matrix vector products produced by the other processors to compute a vector m, which stores the coefficients of the "minimum polynomial" of the given matrix. This process needs a sequence of vectors of the form wi = A^i v). [ wi is the vector obtained from v by multiplying i times by A: A*A*...*A*v.] Each time this process receives a new vector wi, it updates it's computation of the minpoly using a function minpolystep(). ********** smvp.cc ***********/ main() { if ( r == 0 ) initialize_data( A, v, argv[1]); make communicator mvp-comm which excludes process p-1. if ( r != p-1 ) // I'm a mvp process { process 0 send v to process p-1, who calls it w distribute_data( A, v, mvp-comm ); for (int i = 1; i < 2n; i++ ) { compute v <-- Av in mvp-comm process 0 send v to process p-1, who calls it w } process 0 receive and print result m from process p-1. } else // I'm special process to use the vector sequence A^i v to make m. { for (int i = 0; i < 2n; i++ ) { process 0 send v to process p-1, who calls it w minpolystep(w, i, m); } process 0 receive and print result m from process p-1. } }