SLIDE 60 Classes Example: Matrix Class
const MatrixClass D(A); std :: cout << "Element1,1ofDis" << D(1 ,1) << std :: endl; std :: cout << std :: endl; A.Resize (5 ,5 ,0.0); for (int i=0;i<A.Rows () ;++i) A(i,i) = 2.0; for (int i=0;i<A.Rows () -1;++i) A(i+1,i) = A(i,i+1) =
// define vector b std :: vector <double > b(5); b[0] = b[4] = 5.0; b[1] = b[3] =
b[2] = 4.0; std :: vector <double >x = A*b; std :: cout << "A*b=("; for (size_t i=0;i<x.size () ;++i) std :: cout << x[i] << ""; std :: cout << ")" << std :: endl; std :: cout << std :: endl; // solve x = A.Solve(b); A.Print (); std :: cout << "ThesolutionwiththeordinaryGauss Elimination is:("; for (size_t i=0;i<x.size () ;++i) std :: cout << x[i] << ""; std :: cout << ")" << std :: endl; }
Ole Klein (IWR) Object-Oriented Programming
60 / 63