Main Page | Namespace List | Class List | File List | Class Members | File Members

testblas.cpp

Go to the documentation of this file.
00001 #include<iostream>
00002 #include"DMatrix.h"
00003 #include"DVector.h"
00004 #include"SMatrix.h"
00005 #include"SVector.h"
00006 #include"MyBlas.h"
00007 #include"MyLapack.h"
00008 #include<cmath>
00009 #include<stdlib.h>
00010 
00011 using namespace std;
00012 
00013 int main()
00014 {
00015 int ndim=3,lwork;
00016 int info;
00017 
00018 DVector V1,V2,V3,X,T;
00019 DMatrix M1,M2,M3;
00020 
00021 V1.allocate(ndim-1);
00022 V2.allocate(ndim);
00023 V3.allocate(ndim);
00024 X.allocate(3);
00025 double sum,*work;
00026 M1.allocate(ndim-1,ndim);
00027 M2.allocate(ndim,ndim);
00028 M3.allocate(ndim,ndim);
00029 
00030 int ipiv[3],ldx;
00031 
00032 srand(1);
00033 
00034 
00035 for(int i=0;i<ndim;i++) 
00036 { 
00037         V3(i)=(float)rand()/(double)RAND_MAX; 
00038         V2(i)=(float)rand()/(double)RAND_MAX;   
00039 for(int j=0;j<ndim;j++) 
00040         {
00041         M3(j,i)=(float)rand()/(double)RAND_MAX;
00042         M2(j,i)=(float)rand()/(double)RAND_MAX;
00043         }
00044 }
00045 
00046 
00047 cout << M2 << endl;
00048 M2.transpose();
00049 cout << M2 << endl;
00050 
00051 cout << M3 << endl;
00052 M2=M3;
00053 cout << M2 << endl;
00054 
00055 M2=1.0;
00056 
00057 M2=M2+M3;
00058 cout << M2 << endl;
00059 
00060 M1=1.0;
00061 
00062 cout << V2 << endl;
00063 
00064 dgemv_t(1.0,M1,V2,0.0,V1);
00065 
00066 cout << V1 << " ciao a tutti " << endl;
00067         
00068 
00069 /*
00070 MY_DCOPY(ndim,V1,1,V3,1);
00071 for(int i=0;i<ndim;i++) cout << V3[i] << "  ";
00072 cout << endl;
00073 cout << " DAXPY " << endl;
00074 MY_DAXPY(ndim,2.0,V1,1,V3,1);
00075 for(int i=0;i<ndim;i++) cout << V3[i] << "  ";
00076 cout << endl;
00077 cout << " DGEMV " << endl;
00078 MY_DGEMV(CblasNoTrans,ndim,ndim,1.0,M1,ndim,V1,1,0.0,V3,1);
00079 for(int i=0;i<ndim;i++) cout << V3[i] << "  ";
00080 cout << endl;
00081 cout << " DGEMM " << endl;
00082  MY_DGEMM(CblasNoTrans,CblasNoTrans,ndim,ndim,ndim,1.0
00083                  ,M1,ndim,M2,ndim,0.0,M3,ndim);
00084 for(int i=0;i<ndim;i++)
00085 {
00086         for(int j=0;j<ndim;j++)
00087                 cout << M3[i*ndim+j] << "  ";
00088         cout << endl;
00089 }*/
00090 
00091 ldx=1;
00092 lwork=ndim*ndim*ndim;
00093 work= new double[lwork];
00094 
00095 M3=0.0;
00096 
00097 M3(0,0)=10;
00098 M3(1,1)=10;
00099 M3(2,2)=10;
00100 
00101 info=DSYEV('n','u',M3,V2,work,lwork);
00102 
00103 
00104 
00105 cout << V2 << endl;
00106 /*
00107 V1[0]=-1;
00108 V1[1]=1;
00109 V1[2]=0;
00110 
00111 sum=MY_DASUM(3,V1,1);
00112 cout << " sum = " << sum << endl;
00113 
00114 cout << endl;*/
00115 return(0);
00116 }

Generated on Wed Aug 16 19:03:50 2006 for MyLapack by  doxygen 1.4.4