Esempio n. 1
0
void ReduceObject()
{
   ROOT::Mpi::TEnvironment env(gApplication->Argc(), gApplication->Argv());
   ROOT::Mpi::TIntraCommunicator world;

   MpiInitTest(world, 2, ROOT::Mpi::GreaterIqual);

   Int_t root = 1;
   TString str = "+";
   str += world.Rank();

   world.ReduceSendObject(str, ROOT::Mpi::SUM, root);
   TVectorD arr(3);
   arr[0] = world.Rank();
   arr[1] = world.Rank();
   arr[2] = world.Rank();

   world.ReduceSendObject(arr, ROOT::Mpi::SUM, root);


   if (world.Rank() == root) {
      TString    rstr ;
      world.ReduceRecvObject(rstr, ROOT::Mpi::SUM, root);
      std::cout << rstr << std::endl;
      TVectorD rarr(3);
      world.ReduceRecvObject(rarr, ROOT::Mpi::SUM, root);
      rarr.Print();
//       std::cout<<rarr;
//       MpiCompareTest(i, (world.Size() * (world.Size() + 1) / 2) - world.Size(), world.Rank(), "Reduce Send/Recv Scalar Char_t");
   }

}
/**
 * Inicializa los centroides de los clusters. No se utiliza si ya
 * se tienen centroides.
 */
void Kmeans::initialize(){

    int j, l, k;

    RandomArray rarr(N);

    for(j = 0; j < K; ++j){

        k = rarr.get();

        for(l = 0; l < M; ++l)
            centroid[0][j][l] = data[k][l];
    }

    initialized = true;
}