Go to the documentation of this file.00001
00002
00003
00004
00005 #define WANT_STREAM // include.h will get stream fns
00006
00007 #include "include.h"
00008 #include "newmat.h"
00009
00010 #ifdef use_namespace
00011 namespace NEWMAT {
00012 #endif
00013
00014 unsigned long OverflowException::Select;
00015 unsigned long SingularException::Select;
00016 unsigned long NPDException::Select;
00017 unsigned long ConvergenceException::Select;
00018 unsigned long ProgramException::Select;
00019 unsigned long IndexException::Select;
00020 unsigned long VectorException::Select;
00021 unsigned long NotSquareException::Select;
00022 unsigned long SubMatrixDimensionException::Select;
00023 unsigned long IncompatibleDimensionsException::Select;
00024 unsigned long NotDefinedException::Select;
00025 unsigned long CannotBuildException::Select;
00026 unsigned long InternalException::Select;
00027
00028
00029
00030 static void MatrixDetails(const GeneralMatrix& A)
00031
00032 {
00033 MatrixBandWidth bw = A.BandWidth(); int ubw = bw.upper; int lbw = bw.lower;
00034 BaseException::AddMessage("MatrixType = ");
00035 BaseException::AddMessage(A.Type().Value());
00036 BaseException::AddMessage(" # Rows = "); BaseException::AddInt(A.Nrows());
00037 BaseException::AddMessage("; # Cols = "); BaseException::AddInt(A.Ncols());
00038 if (lbw >=0)
00039 { BaseException::AddMessage("; lower BW = "); BaseException::AddInt(lbw); }
00040 if (ubw >=0)
00041 { BaseException::AddMessage("; upper BW = "); BaseException::AddInt(ubw); }
00042 BaseException::AddMessage("\n");
00043 }
00044
00045 NPDException::NPDException(const GeneralMatrix& A)
00046 : Runtime_error()
00047 {
00048 Select = BaseException::Select;
00049 AddMessage("detected by Newmat: matrix not positive definite\n\n");
00050 MatrixDetails(A);
00051 Tracer::AddTrace();
00052 }
00053
00054 SingularException::SingularException(const GeneralMatrix& A)
00055 : Runtime_error()
00056 {
00057 Select = BaseException::Select;
00058 AddMessage("detected by Newmat: matrix is singular\n\n");
00059 MatrixDetails(A);
00060 Tracer::AddTrace();
00061 }
00062
00063 ConvergenceException::ConvergenceException(const GeneralMatrix& A)
00064 : Runtime_error()
00065 {
00066 Select = BaseException::Select;
00067 AddMessage("detected by Newmat: process fails to converge\n\n");
00068 MatrixDetails(A);
00069 Tracer::AddTrace();
00070 }
00071
00072 ConvergenceException::ConvergenceException(const char* c) : Runtime_error()
00073 {
00074 Select = BaseException::Select;
00075 AddMessage("detected by Newmat: ");
00076 AddMessage(c); AddMessage("\n\n");
00077 if (c) Tracer::AddTrace();
00078 }
00079
00080 OverflowException::OverflowException(const char* c) : Runtime_error()
00081 {
00082 Select = BaseException::Select;
00083 AddMessage("detected by Newmat: ");
00084 AddMessage(c); AddMessage("\n\n");
00085 if (c) Tracer::AddTrace();
00086 }
00087
00088 ProgramException::ProgramException(const char* c) : Logic_error()
00089 {
00090 Select = BaseException::Select;
00091 AddMessage("detected by Newmat: ");
00092 AddMessage(c); AddMessage("\n\n");
00093 if (c) Tracer::AddTrace();
00094 }
00095
00096 ProgramException::ProgramException(const char* c, const GeneralMatrix& A)
00097 : Logic_error()
00098 {
00099 Select = BaseException::Select;
00100 AddMessage("detected by Newmat: ");
00101 AddMessage(c); AddMessage("\n\n");
00102 MatrixDetails(A);
00103 if (c) Tracer::AddTrace();
00104 }
00105
00106 ProgramException::ProgramException(const char* c, const GeneralMatrix& A,
00107 const GeneralMatrix& B) : Logic_error()
00108 {
00109 Select = BaseException::Select;
00110 AddMessage("detected by Newmat: ");
00111 AddMessage(c); AddMessage("\n\n");
00112 MatrixDetails(A); MatrixDetails(B);
00113 if (c) Tracer::AddTrace();
00114 }
00115
00116 ProgramException::ProgramException(const char* c, MatrixType a, MatrixType b)
00117 : Logic_error()
00118 {
00119 Select = BaseException::Select;
00120 AddMessage("detected by Newmat: ");
00121 AddMessage(c); AddMessage("\nMatrixTypes = ");
00122 AddMessage(a.Value()); AddMessage("; ");
00123 AddMessage(b.Value()); AddMessage("\n\n");
00124 if (c) Tracer::AddTrace();
00125 }
00126
00127 VectorException::VectorException() : Logic_error()
00128 {
00129 Select = BaseException::Select;
00130 AddMessage("detected by Newmat: cannot convert matrix to vector\n\n");
00131 Tracer::AddTrace();
00132 }
00133
00134 VectorException::VectorException(const GeneralMatrix& A)
00135 : Logic_error()
00136 {
00137 Select = BaseException::Select;
00138 AddMessage("detected by Newmat: cannot convert matrix to vector\n\n");
00139 MatrixDetails(A);
00140 Tracer::AddTrace();
00141 }
00142
00143 NotSquareException::NotSquareException(const GeneralMatrix& A)
00144 : Logic_error()
00145 {
00146 Select = BaseException::Select;
00147 AddMessage("detected by Newmat: matrix is not square\n\n");
00148 MatrixDetails(A);
00149 Tracer::AddTrace();
00150 }
00151
00152 SubMatrixDimensionException::SubMatrixDimensionException()
00153 : Logic_error()
00154 {
00155 Select = BaseException::Select;
00156 AddMessage("detected by Newmat: incompatible submatrix dimension\n\n");
00157 Tracer::AddTrace();
00158 }
00159
00160 IncompatibleDimensionsException::IncompatibleDimensionsException()
00161 : Logic_error()
00162 {
00163 Select = BaseException::Select;
00164 AddMessage("detected by Newmat: incompatible dimensions\n\n");
00165 Tracer::AddTrace();
00166 }
00167
00168 IncompatibleDimensionsException::IncompatibleDimensionsException
00169 (const GeneralMatrix& A, const GeneralMatrix& B)
00170 : Logic_error()
00171 {
00172 Select = BaseException::Select;
00173 AddMessage("detected by Newmat: incompatible dimensions\n\n");
00174 MatrixDetails(A); MatrixDetails(B);
00175 Tracer::AddTrace();
00176 }
00177
00178 NotDefinedException::NotDefinedException(const char* op, const char* matrix)
00179 : Logic_error()
00180 {
00181 Select = BaseException::Select;
00182 AddMessage("detected by Newmat: ");
00183 AddMessage(op);
00184 AddMessage(" not defined for ");
00185 AddMessage(matrix);
00186 AddMessage("\n\n");
00187 Tracer::AddTrace();
00188 }
00189
00190 CannotBuildException::CannotBuildException(const char* matrix)
00191 : Logic_error()
00192 {
00193 Select = BaseException::Select;
00194 AddMessage("detected by Newmat: cannot build matrix type ");
00195 AddMessage(matrix); AddMessage("\n\n");
00196 Tracer::AddTrace();
00197 }
00198
00199 IndexException::IndexException(int i, const GeneralMatrix& A)
00200 : Logic_error()
00201 {
00202 Select = BaseException::Select;
00203 AddMessage("detected by Newmat: index error: requested index = ");
00204 AddInt(i); AddMessage("\n\n");
00205 MatrixDetails(A);
00206 Tracer::AddTrace();
00207 }
00208
00209 IndexException::IndexException(int i, int j, const GeneralMatrix& A)
00210 : Logic_error()
00211 {
00212 Select = BaseException::Select;
00213 AddMessage("detected by Newmat: index error: requested indices = ");
00214 AddInt(i); AddMessage(", "); AddInt(j);
00215 AddMessage("\n\n");
00216 MatrixDetails(A);
00217 Tracer::AddTrace();
00218 }
00219
00220
00221 IndexException::IndexException(int i, const GeneralMatrix& A, bool)
00222 : Logic_error()
00223 {
00224 Select = BaseException::Select;
00225 AddMessage("detected by Newmat: element error: requested index (wrt 0) = ");
00226 AddInt(i);
00227 AddMessage("\n\n");
00228 MatrixDetails(A);
00229 Tracer::AddTrace();
00230 }
00231
00232 IndexException::IndexException(int i, int j, const GeneralMatrix& A, bool)
00233 : Logic_error()
00234 {
00235 Select = BaseException::Select;
00236 AddMessage(
00237 "detected by Newmat: element error: requested indices (wrt 0) = ");
00238 AddInt(i); AddMessage(", "); AddInt(j);
00239 AddMessage("\n\n");
00240 MatrixDetails(A);
00241 Tracer::AddTrace();
00242 }
00243
00244 InternalException::InternalException(const char* c) : Logic_error()
00245 {
00246 Select = BaseException::Select;
00247 AddMessage("internal error detected by Newmat: please inform author\n");
00248 AddMessage(c); AddMessage("\n\n");
00249 Tracer::AddTrace();
00250 }
00251
00252
00253
00254
00255
00256
00257 #ifdef DO_REPORT
00258
00259 int ExeCounter::nreports;
00260
00261 ExeCounter::ExeCounter(int xl, int xf) : line(xl), fileid(xf), nexe(0) {}
00262
00263 ExeCounter::~ExeCounter()
00264 {
00265 nreports++;
00266 cout << "REPORT " << setw(6) << nreports << " "
00267 << setw(6) << fileid << " " << setw(6) << line
00268 << " " << setw(6) << nexe << "\n";
00269 }
00270
00271 #endif
00272
00273
00274
00275 void MatrixErrorNoSpace(void* v) { if (!v) Throw(Bad_alloc()); }
00276
00277
00278
00279
00280
00281
00282
00283
00284 void CroutMatrix::GetRow(MatrixRowCol&)
00285 { Throw(NotDefinedException("GetRow","Crout")); }
00286 void CroutMatrix::GetCol(MatrixRowCol&)
00287 { Throw(NotDefinedException("GetCol","Crout")); }
00288 void CroutMatrix::operator=(const BaseMatrix&)
00289 { Throw(NotDefinedException("=","Crout")); }
00290 void BandLUMatrix::GetRow(MatrixRowCol&)
00291 { Throw(NotDefinedException("GetRow","BandLUMatrix")); }
00292 void BandLUMatrix::GetCol(MatrixRowCol&)
00293 { Throw(NotDefinedException("GetCol","BandLUMatrix")); }
00294 void BandLUMatrix::operator=(const BaseMatrix&)
00295 { Throw(NotDefinedException("=","BandLUMatrix")); }
00296 void BaseMatrix::IEQND() const
00297 { Throw(NotDefinedException("inequalities", "matrices")); }
00298 #ifdef TEMPS_DESTROYED_QUICKLY_R
00299 ReturnMatrixX::ReturnMatrixX(const ReturnMatrixX& tm)
00300 : gm(tm.gm) { Throw(ProgramException("ReturnMatrixX error")); }
00301 #endif
00302
00303
00304 #ifdef use_namespace
00305 }
00306 #endif
00307