newmatex.cpp
Go to the documentation of this file.
1 
4 // Copyright (C) 1992,3,4,7: R B Davies
5 
6 #define WANT_STREAM // include.h will get stream fns
7 
8 #include "include.h" // include standard files
9 #include "newmat.h"
10 
11 #ifdef use_namespace
12 namespace NEWMAT {
13 #endif
14 
15 unsigned long OverflowException::Select;
16 unsigned long SingularException::Select;
17 unsigned long NPDException::Select;
18 unsigned long ConvergenceException::Select;
19 unsigned long ProgramException::Select;
20 unsigned long IndexException::Select;
21 unsigned long VectorException::Select;
22 unsigned long NotSquareException::Select;
25 unsigned long NotDefinedException::Select;
26 unsigned long CannotBuildException::Select;
27 unsigned long InternalException::Select;
28 
29 
30 
31 static void MatrixDetails(const GeneralMatrix& A)
32 // write matrix details to Exception buffer
33 {
34  MatrixBandWidth bw = A.bandwidth();
35  int ubw = bw.upper_val; int lbw = bw.lower_val;
36  BaseException::AddMessage("MatrixType = ");
40  if (lbw >=0)
41  {
42  BaseException::AddMessage("; lower BW = ");
44  }
45  if (ubw >=0)
46  {
47  BaseException::AddMessage("; upper BW = ");
49  }
51 }
52 
54  : Runtime_error()
55 {
57  AddMessage("detected by Newmat: matrix not positive definite\n\n");
58  MatrixDetails(A);
60 }
61 
63  : Runtime_error()
64 {
66  AddMessage("detected by Newmat: matrix is singular\n\n");
67  MatrixDetails(A);
69 }
70 
72  : Runtime_error()
73 {
75  AddMessage("detected by Newmat: process fails to converge\n\n");
76  MatrixDetails(A);
78 }
79 
81 {
83  AddMessage("detected by Newmat: ");
84  AddMessage(c); AddMessage("\n\n");
85  if (c) Tracer::AddTrace();
86 }
87 
89 {
91  AddMessage("detected by Newmat: ");
92  AddMessage(c); AddMessage("\n\n");
93  if (c) Tracer::AddTrace();
94 }
95 
97 {
99  AddMessage("detected by Newmat: ");
100  AddMessage(c); AddMessage("\n\n");
101  if (c) Tracer::AddTrace();
102 }
103 
105  : Logic_error()
106 {
108  AddMessage("detected by Newmat: ");
109  AddMessage(c); AddMessage("\n\n");
110  MatrixDetails(A);
111  if (c) Tracer::AddTrace();
112 }
113 
115  const GeneralMatrix& B) : Logic_error()
116 {
118  AddMessage("detected by Newmat: ");
119  AddMessage(c); AddMessage("\n\n");
121  if (c) Tracer::AddTrace();
122 }
123 
125  : Logic_error()
126 {
128  AddMessage("detected by Newmat: ");
129  AddMessage(c); AddMessage("\nMatrixTypes = ");
130  AddMessage(a.Value()); AddMessage("; ");
131  AddMessage(b.Value()); AddMessage("\n\n");
132  if (c) Tracer::AddTrace();
133 }
134 
136 {
138  AddMessage("detected by Newmat: cannot convert matrix to vector\n\n");
140 }
141 
143  : Logic_error()
144 {
146  AddMessage("detected by Newmat: cannot convert matrix to vector\n\n");
147  MatrixDetails(A);
149 }
150 
152  : Logic_error()
153 {
155  AddMessage("detected by Newmat: matrix is not square\n\n");
156  MatrixDetails(A);
158 }
159 
161  : Logic_error()
162 {
164  AddMessage("detected by Newmat: matrix is not square\n\n");
166 }
167 
169  : Logic_error()
170 {
172  AddMessage("detected by Newmat: incompatible submatrix dimension\n\n");
174 }
175 
177  : Logic_error()
178 {
180  AddMessage("detected by Newmat: incompatible dimensions\n\n");
182 }
183 
185  (const GeneralMatrix& A, const GeneralMatrix& B)
186  : Logic_error()
187 {
189  AddMessage("detected by Newmat: incompatible dimensions\n\n");
192 }
193 
195  (const GeneralMatrix& A)
196  : Logic_error()
197 {
199  AddMessage("detected by Newmat: incompatible dimensions\n\n");
200  MatrixDetails(A);
202 }
203 
204 NotDefinedException::NotDefinedException(const char* op, const char* matrix)
205  : Logic_error()
206 {
208  AddMessage("detected by Newmat: ");
209  AddMessage(op);
210  AddMessage(" not defined for ");
211  AddMessage(matrix);
212  AddMessage("\n\n");
214 }
215 
217  : Logic_error()
218 {
220  AddMessage("detected by Newmat: cannot build matrix type ");
221  AddMessage(matrix); AddMessage("\n\n");
223 }
224 
226  : Logic_error()
227 {
229  AddMessage("detected by Newmat: index error: requested index = ");
230  AddInt(i); AddMessage("\n\n");
231  MatrixDetails(A);
233 }
234 
236  : Logic_error()
237 {
239  AddMessage("detected by Newmat: index error: requested indices = ");
240  AddInt(i); AddMessage(", "); AddInt(j);
241  AddMessage("\n\n");
242  MatrixDetails(A);
244 }
245 
246 
248  : Logic_error()
249 {
251  AddMessage("detected by Newmat: element error: requested index (wrt 0) = ");
252  AddInt(i);
253  AddMessage("\n\n");
254  MatrixDetails(A);
256 }
257 
258 IndexException::IndexException(int i, int j, const GeneralMatrix& A, bool)
259  : Logic_error()
260 {
262  AddMessage(
263  "detected by Newmat: element error: requested indices (wrt 0) = ");
264  AddInt(i); AddMessage(", "); AddInt(j);
265  AddMessage("\n\n");
266  MatrixDetails(A);
268 }
269 
271 {
273  AddMessage("internal error detected by Newmat: please inform author\n");
274  AddMessage(c); AddMessage("\n\n");
276 }
277 
278 
279 
280 
281 /************************* ExeCounter functions *****************************/
282 
283 #ifdef DO_REPORT
284 
285 int ExeCounter::nreports; // will be set to zero
286 
287 ExeCounter::ExeCounter(int xl, int xf) : line(xl), fileid(xf), nexe(0) {}
288 
289 ExeCounter::~ExeCounter()
290 {
291  nreports++;
292  cout << "REPORT " << setw(6) << nreports << " "
293  << setw(6) << fileid << " " << setw(6) << line
294  << " " << setw(6) << nexe << "\n";
295 }
296 
297 #endif
298 
299 /**************************** error handler *******************************/
300 
301 void MatrixErrorNoSpace(const void* v) { if (!v) Throw(Bad_alloc()); }
302 // throw exception if v is null
303 
304 
305 
306 
307 /************************* miscellanous errors ***************************/
308 
309 
311  { Throw(NotDefinedException("GetRow","Crout")); }
313  { Throw(NotDefinedException("GetCol","Crout")); }
315  { Throw(NotDefinedException("GetRow","BandLUMatrix")); }
317  { Throw(NotDefinedException("GetCol","BandLUMatrix")); }
318 void BaseMatrix::IEQND() const
319  { Throw(NotDefinedException("inequalities", "matrices")); }
320 
321 
322 #ifdef use_namespace
323 }
324 #endif
325 
static unsigned long Select
Definition: newmat.h:1917
MatrixType Type() const
Definition: newmat.h:493
IndexException(int i, const GeneralMatrix &A)
Definition: newmatex.cpp:225
static void AddMessage(const char *a_what)
Definition: myexcept.cpp:73
void GetRow(MatrixRowCol &)
Definition: newmatex.cpp:314
static void MatrixDetails(const GeneralMatrix &A)
Definition: newmatex.cpp:31
void GetCol(MatrixRowCol &)
Definition: newmatex.cpp:312
static unsigned long Select
Definition: newmat.h:1963
static unsigned long Select
Definition: newmat.h:2019
void IEQND() const
Definition: newmatex.cpp:318
virtual MatrixBandWidth bandwidth() const
Definition: newmat4.cpp:671
int Nrows() const
Definition: newmat.h:494
static void AddTrace()
Definition: myexcept.cpp:116
NPDException(const GeneralMatrix &)
Definition: newmatex.cpp:53
OverflowException(const char *c)
Definition: newmatex.cpp:88
SingularException(const GeneralMatrix &A)
Definition: newmatex.cpp:62
NotDefinedException(const char *op, const char *matrix)
Definition: newmatex.cpp:204
#define Throw(E)
Definition: myexcept.h:191
CannotBuildException(const char *matrix)
Definition: newmatex.cpp:216
static unsigned long Select
Definition: newmat.h:1952
static unsigned long Select
Definition: newmat.h:1984
FloatVector FloatVector * a
int Ncols() const
Definition: newmat.h:495
static unsigned long Select
Definition: newmat.h:1975
void MatrixErrorNoSpace(const void *v)
test for allocation fails
Definition: newmatex.cpp:301
const char * Value() const
Definition: newmat.h:183
static unsigned long Select
Definition: newmat.h:1925
ConvergenceException(const GeneralMatrix &A)
Definition: newmatex.cpp:71
void GetRow(MatrixRowCol &)
Definition: newmatex.cpp:310
static unsigned long Select
Definition: newmat.h:2011
static void AddInt(int value)
Definition: myexcept.cpp:88
void GetCol(MatrixRowCol &)
Definition: newmatex.cpp:316
Not defined exception.
Definition: newmat.h:2008
static unsigned long Select
Definition: myexcept.h:91
Logic_error(const char *a_what=0)
Definition: myexcept.cpp:397
static unsigned long Select
Definition: newmat.h:1934
static unsigned long Select
Definition: newmat.h:2028
static unsigned long Select
Definition: newmat.h:1993
static unsigned long Select
Definition: newmat.h:1942
The classes for matrices that can contain data are derived from this.
Definition: newmat.h:447
static unsigned long Select
Definition: newmat.h:2001
InternalException(const char *c)
Definition: newmatex.cpp:270


kni
Author(s): Martin Günther
autogenerated on Fri Jun 7 2019 22:06:45