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


rl_agent
Author(s): Todd Hester
autogenerated on Thu Jun 6 2019 22:00:14