void dgesv_check_vector()
{
CPPSL::cout << "############ check dgesv vector ############" << endl;
srand(time(NULL));
int M(3);
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));
}}
CPPSL::dcovector y(M);
for(int i=0; i<y.l; i++){
y(i) =double(rand() /(RAND_MAX/10));
}
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;
A.dgesv(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);
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));
}}
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));
}}
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;
A.dgesv(Y);
CPPSL::cout << "A=\n" << A << endl;
CPPSL::cout << "Y=\n" << Y << endl;
CPPSL::cout << "A_original*Y=\n" << A_original*Y << endl;
}
#include <iostream>
#include <cstdlib>
#include <ctime>
#include "cppscalapack.h"
#include "cppscalapack_init.h"
using namespace std;
#include "dgesv_check.cpp"
int main(int argc, char** argv)
{
CPPSL::initialize(argc,argv, 2,4, 64,64);
dgesv_check_vector();
dgesv_check_matrix();
CPPSL::finalize();
return 0;
}