tmti.cpp
Go to the documentation of this file.
1 
7 
8 
9 //#define WANT_STREAM
10 
11 #include "include.h"
12 
13 #include "newmatap.h"
14 //#include "newmatio.h"
15 
16 #include "tmt.h"
17 
18 #ifdef use_namespace
19 using namespace NEWMAT;
20 #endif
21 
22 
24 {
25  Matrix A(10,10);
27 }
28 
30 // for seeing if we can redimension a vector as a matrix
31 { A.ReSize(4,5); }
32 
33 void trymati()
34 {
35 #ifndef DisableExceptions
36  Tracer et("Eighteenth test of Matrix package");
37  Matrix RUStillThere(10,20); RUStillThere = 1553;
39 
40  ColumnVector checks(23); checks = 1.0; checks(1) = 0.0;
41 
42  Try { WillNotConverge(); }
43  Catch(ConvergenceException) { checks(2) = 0; }
44  CatchAll { checks(1) = 1; }
45 
46 
47  Try { Matrix M(10,10); SymmetricMatrix S = M; }
48  Catch(ConvergenceException) { checks(1) = 1; }
49  Catch(InternalException) { checks(1) = 1; }
50  Catch(ProgramException) { checks(3) = 0; }
51  CatchAll { checks(1) = 1; }
52 
53 
54  Try { Matrix M(10,10); M(10,11) = 2.0; }
55  Catch(ConvergenceException) { checks(1) = 1; }
56  Catch(InternalException) { checks(1) = 1; }
57  Catch(IndexException) { checks(4) = 0; }
58  CatchAll { checks(1) = 1; }
59 
60  Try { Matrix M(10,10); M = 0.0; M = M.i(); }
61  Catch(ConvergenceException) { checks(1) = 1; }
62  Catch(InternalException) { checks(1) = 1; }
63  Catch(ProgramException) { checks(1) = 1; }
64  Catch(SingularException) { checks(5) = 0; }
65  Catch(Bad_alloc) { checks(1) = 1; }
67 
68  Try { ColumnVector A(30), B(50); A = 5; B = 3; FFT(A,B,A,B); }
69  Catch(ConvergenceException) { checks(1) = 1; }
70  Catch(InternalException) { checks(1) = 1; }
71  Catch(ProgramException) { checks(6) = 0; }
72  CatchAll { checks(1) = 1; }
73 
74  Try
75  {
76  ColumnVector A(30); A = 5; Matrix At = A.t();
78  SVD(At,D);
79  }
80  Catch(ConvergenceException) { checks(1) = 1; }
81  Catch(InternalException) { checks(1) = 1; }
82  Catch(Logic_error) { checks(6) = 0; }
83  Catch(Bad_alloc) { checks(1) = 1; }
85 
86  Try { BandMatrix X(10,3,4); X(1,10) = 4.0; }
87  Catch(ConvergenceException) { checks(1) = 1; }
88  Catch(InternalException) { checks(1) = 1; }
89  Catch(IndexException) { checks(7) = 0; }
90  CatchAll { checks(1) = 1; }
91 
92  Try
93  {
94  SymmetricMatrix S(10); S = 5;
96  }
97  Catch(ConvergenceException) { checks(1) = 1; }
98  Catch(InternalException) { checks(1) = 1; }
99  Catch(ProgramException) { checks(1) = 1; }
100  Catch(NPDException) { checks(8) = 0; }
101  Catch(Bad_alloc) { checks(1) = 1; }
103 
104  Try { BandMatrix M(10,3,5); M = 0.0; Matrix XM = M.i(); }
105  Catch(ConvergenceException) { checks(1) = 1; }
106  Catch(InternalException) { checks(1) = 1; }
107  Catch(ProgramException) { checks(1) = 1; }
108  Catch(SingularException) { checks(9) = 0; }
109  Catch(Bad_alloc) { checks(1) = 1; }
111 
112  Try { ColumnVector X(10); ColumnVector Y; X = 5; X = X - Y; }
113  Catch(ConvergenceException) { checks(1) = 1; }
114  Catch(InternalException) { checks(1) = 1; }
115  Catch(IncompatibleDimensionsException) { checks(10) = 0; }
116  Catch(Bad_alloc) { checks(1) = 1; }
118 
119  Try
120  {
121  UpperTriangularMatrix U(3); RowVector RV(3); RV = 10;
122  U.Row(2) = RV;
123  }
124  Catch(ConvergenceException) { checks(1) = 1; }
125  Catch(InternalException) { checks(1) = 1; }
126  Catch(ProgramException) { checks(11) = 0; }
127  Catch(Bad_alloc) { checks(1) = 1; }
129 
130  Try { DiagonalMatrix D(3); D << 12 << 13 << 14 << 15; }
131  Catch(ConvergenceException) { checks(1) = 1; }
132  Catch(InternalException) { checks(1) = 1; }
133  Catch(ProgramException) { checks(12) = 0; }
135 
136  Try { ColumnVector D(3); D << 12 << 13; D << 1 << 2 << 3; }
137  Catch(ConvergenceException) { checks(1) = 1; }
138  Catch(InternalException) { checks(1) = 1; }
139  Catch(ProgramException) { checks(13) = 0; }
141 
142 
143  Try { { ColumnVector D(3); D << 12 << 13; } }
144  Catch(ConvergenceException) { checks(1) = 1; }
145  Catch(InternalException) { checks(1) = 1; }
146  Catch(ProgramException) { checks(14) = 0; }
148 
149  Try { ColumnVector CV; ReSizeMatrix(CV); }
150  Catch(ConvergenceException) { checks(1) = 1; }
151  Catch(InternalException) { checks(1) = 1; }
152  Catch(VectorException) { checks(15) = 0; }
154 
155  Try { RowVector RV(20); ReSizeMatrix(RV); }
156  Catch(ConvergenceException) { checks(1) = 1; }
157  Catch(InternalException) { checks(1) = 1; }
158  Catch(VectorException) { checks(16) = 0; }
160 
161  Try
162  {
163  UpperTriangularMatrix U(10); U = 5;
164  DiagonalMatrix D(10); D = 2;
165  D += U; // illegal conversion
166  }
167  Catch(ConvergenceException) { checks(1) = 1; }
168  Catch(InternalException) { checks(1) = 1; }
169  Catch(ProgramException) { checks(17) = 0; }
171 
172  Try { Matrix A(2,3), B(2,3); if (A < B) A = B; }
173  Catch(ConvergenceException) { checks(1) = 1; }
174  Catch(InternalException) { checks(1) = 1; }
175  Catch(NotDefinedException) { checks(18) = 0; }
177 
178  Try { SymmetricBandMatrix A(3,1); A = 1; A = A.Reverse(); }
179  Catch(ConvergenceException) { checks(1) = 1; }
180  Catch(InternalException) { checks(1) = 1; }
181  Catch(NotDefinedException) { checks(19) = 0; }
183 
184  Try
185  {
186  Matrix A(5,5); A = 1.0;
187  UpperTriangularMatrix B(10);
188  B.SubMatrix(3,7,3,7) = A;
189  }
190  Catch(ProgramException) { checks(20) = 0; }
192 
193  Try { { RowVector D(1); D << 12 << 13; } }
194  Catch(InternalException) { checks(1) = 1; }
195  Catch(ProgramException) { checks(21) = 0; }
197 
198  Try { { RowVector D(0); D << 12; } }
199  Catch(InternalException) { checks(1) = 1; }
200  Catch(ProgramException) { checks(22) = 0; }
202 
203  Try { Matrix M(10,10); Matrix XM(3,3); M = 0.0; XM = M.i(); }
204  Catch(SingularException) { checks(23) = 0; }
205  CatchAll { checks(1) = 1; }
206 
207  Print(checks);
208  Matrix RUStillThere1(10,20); RUStillThere1 = 1553;
209  RUStillThere = RUStillThere - RUStillThere1;
210  Print(RUStillThere);
211 #endif
212 
213 }
214 
215 
217 
void trymati()
Definition: tmti.cpp:33
#define Try
Definition: myexcept.h:190
#define Catch
Definition: myexcept.h:193
Miscellaneous exception (details in character string).
Definition: newmat.h:1947
#define CatchAndThrow
Definition: myexcept.h:195
Internal newmat exception - shouldn&#39;t happen.
Definition: newmat.h:2025
virtual void ReSize(int m, int n)
Definition: newmat.h:662
void WillNotConverge()
Definition: tmti.cpp:23
ReversedMatrix Reverse() const
Definition: newmat.h:2140
#define CatchAll
Definition: myexcept.h:194
Upper triangular matrix.
Definition: newmat.h:799
void FFT(const ColumnVector &U, const ColumnVector &V, ColumnVector &X, ColumnVector &Y)
Definition: fft.cpp:201
Band matrix.
Definition: newmat.h:1096
TransposedMatrix t() const
Definition: newmat6.cpp:320
void ReSizeMatrix(Matrix &A)
Definition: tmti.cpp:29
Singular matrix exception.
Definition: newmat.h:1931
void SVD(const Matrix &, DiagonalMatrix &, Matrix &, Matrix &, bool=true, bool=true)
Definition: svd.cpp:30
#define Throw(E)
Definition: myexcept.h:191
static void PrintTrace()
Definition: myexcept.cpp:109
The usual rectangular matrix.
Definition: newmat.h:625
InvertedMatrix i() const
Definition: newmat6.cpp:329
ReturnMatrix Cholesky(const SymmetricMatrix &S)
Definition: cholesky.cpp:36
Incompatible dimensions exception.
Definition: newmat.h:1998
Index exception.
Definition: newmat.h:1960
Diagonal matrix.
Definition: newmat.h:896
Lower triangular matrix.
Definition: newmat.h:848
GetSubMatrix Row(int f) const
Definition: newmat.h:2150
GetSubMatrix SubMatrix(int fr, int lr, int fc, int lc) const
Definition: newmat.h:2146
Symmetric band matrix.
Definition: newmat.h:1245
Not positive definite exception.
Definition: newmat.h:1914
Not defined exception.
Definition: newmat.h:2008
Covergence failure exception.
Definition: newmat.h:1922
Row vector.
Definition: newmat.h:953
void Print(const Matrix &X)
Definition: tmt.cpp:42
Column vector.
Definition: newmat.h:1008
Cannot convert to vector exception.
Definition: newmat.h:1972
Symmetric matrix.
Definition: newmat.h:753


kni
Author(s): Martin Günther
autogenerated on Fri Jan 3 2020 04:01:17