tmti.cpp
Go to the documentation of this file.
00001 
00002 
00003 
00007 
00008 
00009 //#define WANT_STREAM
00010 
00011 #include "include.h"
00012 
00013 #include "newmatap.h"
00014 //#include "newmatio.h"
00015 
00016 #include "tmt.h"
00017 
00018 #ifdef use_namespace
00019 using namespace NEWMAT;
00020 #endif
00021 
00022 
00023 void WillNotConverge()
00024 {
00025    Matrix A(10,10);
00026    Throw(ConvergenceException(A));
00027 }
00028 
00029 void ReSizeMatrix(Matrix& A)
00030 // for seeing if we can redimension a vector as a matrix
00031 { A.ReSize(4,5); }
00032 
00033 void trymati()
00034 {
00035 #ifndef DisableExceptions
00036    Tracer et("Eighteenth test of Matrix package");
00037    Matrix RUStillThere(10,20); RUStillThere = 1553;
00038    Tracer::PrintTrace();
00039 
00040    ColumnVector checks(23); checks = 1.0; checks(1) = 0.0;
00041 
00042    Try { WillNotConverge(); }
00043    Catch(ConvergenceException) { checks(2) = 0; }
00044    CatchAll { checks(1) = 1; }
00045 
00046 
00047    Try { Matrix M(10,10); SymmetricMatrix S = M; }
00048    Catch(ConvergenceException) { checks(1) = 1; }
00049    Catch(InternalException) { checks(1) = 1; }
00050    Catch(ProgramException) { checks(3) = 0; }
00051    CatchAll { checks(1) = 1; }
00052 
00053 
00054    Try { Matrix M(10,10); M(10,11) = 2.0; }
00055    Catch(ConvergenceException) { checks(1) = 1; }
00056    Catch(InternalException) { checks(1) = 1; }
00057    Catch(IndexException) { checks(4) = 0; }
00058    CatchAll { checks(1) = 1; }
00059 
00060    Try { Matrix M(10,10); M = 0.0; M = M.i(); }
00061    Catch(ConvergenceException) { checks(1) = 1; }
00062    Catch(InternalException) { checks(1) = 1; }
00063    Catch(ProgramException) { checks(1) = 1; }
00064    Catch(SingularException) { checks(5) = 0; }
00065    Catch(Bad_alloc) { checks(1) = 1; }
00066    CatchAndThrow;
00067 
00068    Try { ColumnVector A(30), B(50);  A = 5; B = 3; FFT(A,B,A,B); }
00069    Catch(ConvergenceException) { checks(1) = 1; }
00070    Catch(InternalException) { checks(1) = 1; }
00071    Catch(ProgramException) { checks(6) = 0; }
00072    CatchAll { checks(1) = 1; }
00073 
00074    Try
00075    {
00076       ColumnVector A(30); A = 5; Matrix At = A.t();
00077       DiagonalMatrix D;
00078       SVD(At,D);
00079    }
00080    Catch(ConvergenceException) { checks(1) = 1; }
00081    Catch(InternalException) { checks(1) = 1; }
00082    Catch(Logic_error) { checks(6) = 0; }
00083    Catch(Bad_alloc) { checks(1) = 1; }
00084    CatchAndThrow;
00085 
00086    Try { BandMatrix X(10,3,4); X(1,10) = 4.0; }
00087    Catch(ConvergenceException) { checks(1) = 1; }
00088    Catch(InternalException) { checks(1) = 1; }
00089    Catch(IndexException) { checks(7) = 0; }
00090    CatchAll { checks(1) = 1; }
00091 
00092    Try
00093    {
00094       SymmetricMatrix S(10); S = 5;
00095       LowerTriangularMatrix L = Cholesky(S);
00096    }
00097    Catch(ConvergenceException) { checks(1) = 1; }
00098    Catch(InternalException) { checks(1) = 1; }
00099    Catch(ProgramException) { checks(1) = 1; }
00100    Catch(NPDException) { checks(8) = 0; }
00101    Catch(Bad_alloc) { checks(1) = 1; }
00102    CatchAndThrow;
00103 
00104    Try { BandMatrix M(10,3,5); M = 0.0; Matrix XM = M.i(); }
00105    Catch(ConvergenceException) { checks(1) = 1; }
00106    Catch(InternalException) { checks(1) = 1; }
00107    Catch(ProgramException) { checks(1) = 1; }
00108    Catch(SingularException) { checks(9) = 0; }
00109    Catch(Bad_alloc) { checks(1) = 1; }
00110    CatchAndThrow;
00111 
00112    Try { ColumnVector X(10); ColumnVector Y; X = 5; X = X - Y; }
00113    Catch(ConvergenceException) { checks(1) = 1; }
00114    Catch(InternalException) { checks(1) = 1; }
00115    Catch(IncompatibleDimensionsException) { checks(10) = 0; }
00116    Catch(Bad_alloc) { checks(1) = 1; }
00117    CatchAndThrow;
00118 
00119    Try
00120    {
00121       UpperTriangularMatrix U(3); RowVector RV(3); RV = 10;
00122       U.Row(2) = RV;
00123    }
00124    Catch(ConvergenceException) { checks(1) = 1; }
00125    Catch(InternalException) { checks(1) = 1; }
00126    Catch(ProgramException) { checks(11) = 0; }
00127    Catch(Bad_alloc) { checks(1) = 1; }
00128    CatchAndThrow;
00129 
00130    Try { DiagonalMatrix D(3); D << 12 << 13 << 14 << 15; }
00131    Catch(ConvergenceException) { checks(1) = 1; }
00132    Catch(InternalException) { checks(1) = 1; }
00133    Catch(ProgramException) { checks(12) = 0; }
00134    CatchAndThrow;
00135 
00136    Try { ColumnVector D(3); D << 12 << 13; D << 1 << 2 << 3; }
00137    Catch(ConvergenceException) { checks(1) = 1; }
00138    Catch(InternalException) { checks(1) = 1; }
00139    Catch(ProgramException) { checks(13) = 0; }
00140    CatchAndThrow;
00141 
00142 
00143    Try {  { ColumnVector D(3); D << 12 << 13; }  }
00144    Catch(ConvergenceException) { checks(1) = 1; }
00145    Catch(InternalException) { checks(1) = 1; }
00146    Catch(ProgramException) { checks(14) = 0; }
00147    CatchAndThrow;
00148 
00149    Try { ColumnVector CV; ReSizeMatrix(CV); }
00150    Catch(ConvergenceException) { checks(1) = 1; }
00151    Catch(InternalException) { checks(1) = 1; }
00152    Catch(VectorException) { checks(15) = 0; }
00153    CatchAndThrow;
00154 
00155    Try { RowVector RV(20); ReSizeMatrix(RV); }
00156    Catch(ConvergenceException) { checks(1) = 1; }
00157    Catch(InternalException) { checks(1) = 1; }
00158    Catch(VectorException) { checks(16) = 0; }
00159    CatchAndThrow;
00160 
00161    Try
00162    {
00163       UpperTriangularMatrix U(10); U = 5;
00164       DiagonalMatrix D(10); D = 2;
00165       D += U;                 // illegal conversion
00166    }
00167    Catch(ConvergenceException) { checks(1) = 1; }
00168    Catch(InternalException) { checks(1) = 1; }
00169    Catch(ProgramException) { checks(17) = 0; }
00170    CatchAndThrow;
00171 
00172    Try { Matrix A(2,3), B(2,3); if (A < B) A = B; }
00173    Catch(ConvergenceException) { checks(1) = 1; }
00174    Catch(InternalException) { checks(1) = 1; }
00175    Catch(NotDefinedException) { checks(18) = 0; }
00176    CatchAndThrow;
00177 
00178    Try { SymmetricBandMatrix A(3,1); A = 1; A = A.Reverse(); }
00179    Catch(ConvergenceException) { checks(1) = 1; }
00180    Catch(InternalException) { checks(1) = 1; }
00181    Catch(NotDefinedException) { checks(19) = 0; }
00182    CatchAndThrow;
00183 
00184    Try
00185    {
00186       Matrix A(5,5); A = 1.0;
00187       UpperTriangularMatrix B(10);
00188       B.SubMatrix(3,7,3,7) = A;
00189    }
00190    Catch(ProgramException) { checks(20) = 0; }
00191    CatchAndThrow;
00192 
00193    Try {  { RowVector D(1); D << 12 << 13; }  }
00194    Catch(InternalException) { checks(1) = 1; }
00195    Catch(ProgramException) { checks(21) = 0; }
00196    CatchAndThrow;
00197 
00198    Try {  { RowVector D(0); D << 12; }  }
00199    Catch(InternalException) { checks(1) = 1; }
00200    Catch(ProgramException) { checks(22) = 0; }
00201    CatchAndThrow;
00202 
00203    Try { Matrix M(10,10); Matrix XM(3,3); M = 0.0; XM = M.i(); }
00204    Catch(SingularException) { checks(23) = 0; }
00205    CatchAll { checks(1) = 1; }
00206 
00207    Print(checks);
00208    Matrix RUStillThere1(10,20); RUStillThere1 = 1553;
00209    RUStillThere = RUStillThere - RUStillThere1;
00210    Print(RUStillThere);
00211 #endif
00212 
00213 }
00214 
00215 
00217 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines


kni
Author(s): Neuronics AG (see AUTHORS.txt); ROS wrapper by Martin Günther
autogenerated on Tue May 28 2013 14:52:55