00001 #include "cammva.h"
00002 #include <fstream.h>
00003 #include <stdio.h>
00004 #include <stdlib.h>
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 int main(){
00018
00019 CAMdoubleMatrix A(3,3);
00020 CAMdoubleMatrix M(3,3);
00021 CAMdoubleVector b(3);
00022 CAMdoubleVector rhs(3);
00023 CAMdoubleVector x(3);
00024 CAMdoubleVector residual(3);
00025
00026
00027
00028 ofstream OutFile;
00029 OutFile.open("Test.dat",ios::out);
00030
00031 long i,j;
00032
00033
00034 for(i=1; i<= 3; i++)
00035 for(j=1; j<= 3; j++)
00036 {
00037 M(i,j)=1.0/(double(i) + double(j));
00038 }
00039
00040 for(i=1; i<=3; i++)
00041 {
00042 rhs(i)=double(i);
00043 }
00044 OutFile << M;
00045 OutFile << rhs;
00046 OutFile.close();
00047
00048
00049
00050 ifstream InFile;
00051
00052
00053 InFile.open("Test.dat",ios::in);
00054 if (!InFile )
00055 {cerr << " Error in Opening input File "; exit(1); }
00056
00057 InFile >> A;
00058 InFile >> b;
00059
00060 x=A/b;
00061 residual=A*x - b;
00062
00063
00064
00065
00066 cout.setf(ios::scientific, ios::floatfield);
00067
00068 cout << " The matrix A " << endl;
00069 cout << A;
00070 cout << " The vector b " << endl;
00071 cout << b;
00072 cout << " The solution of A*x=b " << endl;
00073 cout << x;
00074 cout << " The residual " << endl;
00075 cout << residual;
00076
00077 cout << " Program End : Hit Any Key to Terminate " << endl;
00078 getchar();
00079 return 0;
00080 }
00081
00082