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

main_MVector.cpp

Go to the documentation of this file.
00001 //=======================================================================
00002 // Basic C++: a simple mathematical vector class
00003 //      Test
00004 //-----------------------------------------------------------------------
00005 // Jean-Paul Rigault --- Copyright 2004
00006 // $Id: main_MVector.cpp,v 1.1 2004/11/28 11:38:07 jpr Exp $
00007 //=======================================================================
00008 
00009 #include "common_defs.h"
00010 #include "MVector.h"
00011 
00012 int main()
00013 {
00014     cout << boolalpha;// Sets cout to print bool as true or false (not 1 and 0)
00015 
00016     MSG(Constructors);
00017 
00018     MVector mv0; 
00019     MVector mv1(5, 1.5);
00020     OUT(mv0);
00021     OUT(mv1);
00022     OUT(mv0 == mv1);
00023 
00024     MSG(Assignments);
00025 
00026     EXEC(mv0 = mv1);
00027     OUT(mv0);
00028     OUT(mv0 == mv1);
00029     OUT(mv1 += mv1);
00030     OUT(mv1 -= mv1);
00031 
00032     MSG (Scalar product and norm);
00033 
00034     OUT(mv0.norm());
00035     OUT(mv0 * mv0);
00036 
00037     MSG(Arithmetic operations);
00038 
00039     OUT(mv0 + mv0);
00040     OUT(mv0 - mv0);
00041     try
00042     {
00043         MVector mv2(10);
00044         OUT(mv0 + mv2);
00045     }
00046     catch (MVector::Bad_Dimensions)
00047     {
00048         cerr << "*** Bad dimensions" << endl;
00049     }    
00050 
00051     MSG(Subscript);
00052 
00053     EXEC(mv0[2] = 5.5);
00054     OUT(mv0[2]);
00055     try
00056     {
00057         OUT(mv0[107]);
00058     }
00059     catch (MVector::Out_Of_Bounds)
00060     {
00061         cerr << "*** Out of bounds" << endl;
00062     }
00063 
00064     const MVector cmv = mv1;
00065     OUT(cmv[2]);
00066     // cmv[2] = 3.5; DOES NOT COMPILE
00067 
00068 
00069     return 0;
00070 }

Generated on Mon Dec 12 18:25:41 2005 for Vectors_and_Matrices by  doxygen 1.4.3