Main Page | Class List | File List | Class Members | File Members | Related Pages

An Example Code of dgematrix_io

//====================================================================[include]
#include <iostream>
#include <cstdlib>
#include <ctime>
#include "cppscalapack.h"
#include "cppscalapack_init.h"
using namespace std;

//=======================================================================[main]
/*! main */
int main(int argc, char** argv)
{
  srand(time(NULL));
  const int M(4), N(3);
  
  //// initialize ////
  CPPSL::initialize(argc,argv, 2,4, 64,64);
  //CPPSL::initialize(argc,argv, 2,4, 1,1);
  
  //// make dgematrix A ////
  CPPSL::dgematrix A(M,N);
  for(int i=0; i<A.m; i++){ for(int j=0; j<A.n; j++){
    A(i,j) =double(rand()/(RAND_MAX/10));
  }}
  
  //// print A in two ways ////
  CPPSL::cout << "A =\n" << A << endl;
  for(int i=0; i<A.m; i++){ for(int j=0; j<A.n; j++){
    CPPSL::cout << "A(" << i << "," << j << ") =" << A(i,j) << endl;
  }}
  
  //// make dgematrix B ////
  CPPSL::dgematrix B(A);
  
  //// print y in two ways ////
  CPPSL::cout << "B =\n" << B << endl;
  for(int i=0; i<B.m; i++){ for(int j=0; j<B.n; j++){
    CPPSL::cout << "B(" << i << "," << j << ") =" << B(i,j) << endl;
  }}
  
  //// print A+B ////
  CPPSL::cout << "A+B=\n" << A+B << endl;
  
  //// finalize ////
  CPPSL::finalize();
  return 0;
}

Generated on Sat Jan 31 19:25:46 2004 for CPPScaLapack by doxygen 1.3.5