00001 #ifndef _MTRX_EXCEPT_HH_
00002 #define _MTRX_EXCEPT_HH_
00003
00004 #include <iostream>
00005 #include "std_except.hh"
00006
00007 class MatrixException : public StandardException{
00008 public:
00009 MatrixException() : StandardException() {};
00010 MatrixException(const string& fname, int ln,
00011 const string& msg = string())
00012 : StandardException(fname, ln, head()+msg) {}
00013 const char *head() const { return ""; }
00014 };
00015
00016 class MatrixDimensionException : public MatrixException {
00017 public:
00018 MatrixDimensionException() : MatrixException() {};
00019 MatrixDimensionException(const string& fname, int ln,
00020 const string& msg = string())
00021 : MatrixException(fname, ln, head()+msg) {}
00022 const char *head() const {return "Cannot allocate matrix: Invalid dimension(s).";};
00023 };
00024
00025 class MatrixMemoryExhaustException : public MatrixException {
00026 public:
00027 MatrixMemoryExhaustException() : MatrixException() {};
00028 MatrixMemoryExhaustException(const string& fname, int ln,
00029 const string& msg = string())
00030 : MatrixException(fname, ln, head()+msg) {}
00031 const char *head() const {return "Cannot allocate matrix: Memory full.";};
00032 };
00033
00034 class MatrixEmptyMatrixException : public MatrixException {
00035 public:
00036 MatrixEmptyMatrixException() : MatrixException() {};
00037 MatrixEmptyMatrixException(const string& fname, int ln,
00038 const string& msg = string())
00039 : MatrixException(fname, ln, head()+msg) {}
00040 const char *head() const {return "Illegal operation: Matrix is empty.";};
00041 };
00042
00043 class MatrixArrayBoundsException : public MatrixException {
00044 public:
00045 MatrixArrayBoundsException() : MatrixException() {};
00046 MatrixArrayBoundsException(const string& fname, int ln,
00047 const string& msg = string())
00048 : MatrixException(fname, ln, head()+msg) {}
00049 const char *head() const {return "Index exceeds matrix dimensions.";};
00050 };
00051
00052 class MatrixZeroIndexException : public MatrixException {
00053 public:
00054 MatrixZeroIndexException() : MatrixException() {};
00055 MatrixZeroIndexException(const string& fname, int ln,
00056 const string& msg = string())
00057 : MatrixException(fname, ln, head()+msg) {}
00058 const char *head() const {return "Index into matrix is negative or zero.";};
00059 };
00060
00061 class MatrixRowDimException : public MatrixException {
00062 public:
00063 MatrixRowDimException() : MatrixException() {};
00064 MatrixRowDimException(const string& fname, int ln,
00065 const string& msg = string())
00066 : MatrixException(fname, ln, head()+msg) {}
00067 const char *head() const {return "Matrix row dimension mismatch.";};
00068 };
00069
00070 class MatrixColDimException : public MatrixException {
00071 public:
00072 MatrixColDimException() : MatrixException() {};
00073 MatrixColDimException(const string& fname, int ln,
00074 const string& msg = string())
00075 : MatrixException(fname, ln, head()+msg) {}
00076 const char *head() const {return "Matrix column dimension mismatch.";};
00077 };
00078
00079 class MatrixBadArgException : public MatrixException {
00080 public:
00081 MatrixBadArgException() : MatrixException() {};
00082 MatrixBadArgException(const string& fname, int ln,
00083 const string& msg = string())
00084 : MatrixException(fname, ln, head()+msg) {}
00085 const char *head() const {return "Invalid argument.";};
00086 };
00087
00088 class MatrixIsComplexException : public MatrixException {
00089 public:
00090 MatrixIsComplexException() : MatrixException() {};
00091 MatrixIsComplexException(const string& fname, int ln,
00092 const string& msg = string())
00093 : MatrixException(fname, ln, head()+msg) {}
00094 const char *head() const {return "Matrix operation not defined for complex matrices.";};
00095 };
00096
00097 class MatrixDivisionByZeroException : public MatrixException {
00098 public:
00099 MatrixDivisionByZeroException() : MatrixException() {};
00100 MatrixDivisionByZeroException(const string& fname, int ln,
00101 const string& msg = string())
00102 : MatrixException(fname, ln, head()+msg) {}
00103 const char *head() const {return "Division by zero.";};
00104 };
00105
00106 class MatrixDomainException : public MatrixException {
00107 public:
00108 MatrixDomainException() : MatrixException() {};
00109 MatrixDomainException(const string& fname, int ln,
00110 const string& msg = string())
00111 : MatrixException(fname, ln, head()+msg) {}
00112 const char *head() const {return "Matrix operation called with input not in required domain.";};
00113 };
00114
00115 class MatrixRangeException : public MatrixException {
00116 public:
00117 MatrixRangeException() : MatrixException() {};
00118 MatrixRangeException(const string& fname, int ln,
00119 const string& msg = string())
00120 : MatrixException(fname, ln, head()+msg) {}
00121 const char *head() const {return "Matrix operation yielded out-of-range result.";};
00122 };
00123
00124
00125 #endif