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

An Example Code of dgematrix_lapack

//=============================================================================
/*! dgesv_check */
void dgesv_check_vector()
{
  CPPSL::cout << "############ check dgesv vector ############" << endl;
  
  srand(time(NULL));
  int M(3);
  
  //// make dgematrix A  ////
  CPPSL::dgematrix A(M,M);
  for(int i=0; i<A.m; i++){ for(int j=0; j<A.n; j++){
    A(i,j) =double(rand()/(RAND_MAX/10));
  }}
  
  //// make dcovector y ////
  CPPSL::dcovector y(M);
  for(int i=0; i<y.l; i++){
    y(i) =double(rand() /(RAND_MAX/10));
  }
  
  //// make A_original and y_original ////
  CPPSL::dgematrix A_original(A);
  CPPSL::dcovector y_original(y);
  CPPSL::cout << "A_original=\n" << A_original << endl;
  CPPSL::cout << "y_original=\n" << y_original << endl;
  
  //// solve Ax=y ////
  A.dgesv(y);
  
  //// print A, y and A_original*y ////
  CPPSL::cout << "A=\n" << A << endl;
  CPPSL::cout << "y=\n" << y << endl;
  CPPSL::cout << "A_original*y=\n" << A_original*y << endl;
}

//==============================================================================
void dgesv_check_matrix()
{
  CPPSL::cout << "############ check dgesv matrix ############" << endl;
  
  srand(time(NULL));
  int M(3);
  
  //// make dgematrix A  ////
  CPPSL::dgematrix A(M,M);
  for(int i=0; i<A.m; i++){ for(int j=0; j<A.n; j++){
    A(i,j) =double(rand()/(RAND_MAX/10));
  }}
  
  //// make dgematrix Y  ////
  CPPSL::dgematrix Y(M,M);
  for(int i=0; i<Y.m; i++){ for(int j=0; j<Y.n; j++){
    Y(i,j) =double(rand()/(RAND_MAX/10));
  }}
  
  //// make A_original and Y_original ////
  CPPSL::dgematrix A_original(A);
  CPPSL::dgematrix Y_original(Y);
  CPPSL::cout << "A_original=\n" << A_original << endl;
  CPPSL::cout << "Y_original=\n" << Y_original << endl;
  
  //// solve AY=B ////
  A.dgesv(Y);
  
  //// print A, Y and A_original*Y ////
  CPPSL::cout << "A=\n" << A << endl;
  CPPSL::cout << "Y=\n" << Y << endl;
  CPPSL::cout << "A_original*Y=\n" << A_original*Y << endl;
}
//====================================================================[include]
#include <iostream>
#include <cstdlib>
#include <ctime>
#include "cppscalapack.h"
#include "cppscalapack_init.h"
using namespace std;

#include "dgesv_check.cpp"
//#include "dgels_check.cpp"
//#include "dgelss_check.cpp"
//#include "dgeev_check.cpp"
//#include "dgesvd_check.cpp"

//=======================================================================[main]
/*! main */
int main(int argc, char** argv)
{
  //// initialize ////
  CPPSL::initialize(argc,argv, 2,4, 64,64);
  //CPPSL::initialize(argc,argv, 2,4, 1,1);
  
  dgesv_check_vector();
  dgesv_check_matrix();
  //dgels_check_vector();
  //dgels_check_matrix();
  //dgelss_check();
  //dgeev_check_right();
  //dgeev_check_left();
  //dgesvd_check();
  
  //// finalize ////
  CPPSL::finalize();
  return 0;
}

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