// Start iteration:
for (m = 0; m < l; m++){
count++;
update_Z(Z, y, TH, A, G, r) ;
update_TH(TH, THV, Z, A, G, r);
update_KSI_AR(KSI_array, Z, TH);
MPI_Gather (KSI_array, (2*k)+2, MPI_DOUBLE, KSI_rec, (2*k)+2, MPI_DOUBLE, ROOT, MPI_COMM_WORLD);
if(rank == ROOT){
double XX00=0.0; // XX00 = XX
double XX01=0.0; // XX01 = XX
double XZ00=0.0; // XZ0 = XZ0
double XZ10=0.0; // XZ1 = XZ1
// Retrieve x′x and x′Z from KSI_rec::
for(i=0; i<size; i++) {
XX00 += KSI_rec 2*k+(2*k+2)*i ;
XX01 += KSI_rec (2*k+1)+(2*k+2)*i ;
}
gsl_matrix_set(XX, 0, 0, XX00);
gsl_matrix_set(XX, 0, 1, XX01);
gsl_matrix_set(XX, 1, 0, XX01);
gsl_matrix_set(XX, 1, 1, n);
for(j=0; j < k; j++) {
XZ00=0.0;
XZ10=0.0;
for(i=0; i<size; i++) {
XZ00 += KSI_rec ;
XZ10 += KSI_rec ;
}
gsl_matrix_set(XZ, 0, 0, XZ00);
gsl_matrix_set(XZ, 1, 0, XZ10);
}
update_A_G(A, G, AV, GV, XX, XZ, unif, count, r);
// Transfer A and G data into a buffer so that they can be broadcasted:
for(i=0; i < k; i++){
A_G_array i = gsl_vector_get(A, i);
A_G_array i+k = gsl_vector_get(G, i);}
}
MPI_Bcast(A_G_array, 2*k, MPI_DOUBLE, ROOT, MPI_COMM_WORLD);
// Transfer A and G received to a vector structure:
for(i=0; i < k; i++){
gsl_vector_set(A,i,A_G_array i );
gsl_vector_set(G,i,A_G_array i+k );
}
}// End iteration
Pseudocode 1