Errors.hxx
1 // Copyright (C) 2001-2009 Vivien Mallet
2 //
3 // This file is part of the linear-algebra library Seldon,
4 // http://seldon.sourceforge.net/.
5 //
6 // Seldon is free software; you can redistribute it and/or modify it under the
7 // terms of the GNU Lesser General Public License as published by the Free
8 // Software Foundation; either version 2.1 of the License, or (at your option)
9 // any later version.
10 //
11 // Seldon is distributed in the hope that it will be useful, but WITHOUT ANY
12 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
14 // more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public License
17 // along with Seldon. If not, see http://www.gnu.org/licenses/.
18 
19 
20 #ifndef SELDON_FILE_ERRORS_HXX
21 
22 #include <string>
23 #include <iostream>
24 #include "Common.hxx"
25 
26 
27 namespace Seldon
28 {
29 
30 
31  using namespace std;
32 
33 
35  // ERROR //
37 
38  class Error
39  {
40  protected:
42  string description_;
44  string function_;
46  string comment_;
47 
48  public:
49  Error(string function = "", string comment = "");
50  Error(string description, string function, string comment);
51  virtual ~Error();
52 
53  virtual string What();
54  void CoutWhat();
55  };
56 
57 
59  // UNDEFINED //
61 
62  class Undefined: public Error
63  {
64  public:
65  Undefined(string function = "", string comment = "");
66  virtual ~Undefined();
67 
68  virtual string What();
69  };
70 
71 
73  // WRONGARGUMENT //
75 
76  class WrongArgument: public Error
77  {
78  public:
79  WrongArgument(string function = "", string comment = "");
80  virtual ~WrongArgument();
81 
82  virtual string What();
83  };
84 
85 
87  // NOMEMORY //
89 
90  class NoMemory: public Error
91  {
92  public:
93  NoMemory(string function = "", string comment = "");
94  virtual ~NoMemory();
95  };
96 
97 
99  // WRONGDIM //
101 
102  class WrongDim: public Error
103  {
104  public:
105  WrongDim(string function = "", string comment = "");
106  virtual ~WrongDim();
107  };
108 
109 
111  // WRONGINDEX //
113 
114  class WrongIndex: public Error
115  {
116  public:
117  WrongIndex(string function = "", string comment = "");
118  virtual ~WrongIndex();
119  };
120 
121 
123  // WRONGROW //
125 
126  class WrongRow: public Error
127  {
128  public:
129  WrongRow(string function = "", string comment = "");
130  virtual ~WrongRow();
131  };
132 
133 
135  // WRONGCOL //
137 
138  class WrongCol: public Error
139  {
140  public:
141  WrongCol(string function = "", string comment = "");
142  virtual ~WrongCol();
143  };
144 
145 
147  // IOERROR //
149 
150  class IOError: public Error
151  {
152  public:
153  IOError(string function = "", string comment = "");
154  virtual ~IOError();
155  };
156 
157 
159  // other errors //
161 
162 
164  {
165  public:
166  SolverMaximumIterationError(string function = "", string comment = "");
167  virtual ~SolverMaximumIterationError();
168  };
169 
170 
172  {
173  public:
174  SolverDivergenceError(string function = "", string comment = "");
175  virtual ~SolverDivergenceError();
176  };
177 
178 
180  // CheckBounds //
182 
183 
184  void CheckBounds(long i, long length1_, string nom);
185  void CheckBounds(int i, int j, int length1_, int length2_, string nom);
186  void CheckBoundsSym(int i, int j, int length1_, int length2_, string nom);
187  void CheckBoundsTriang(int i, int j, int length1_, int length2_,
188  bool uplo, string nom);
189 
190  void CheckBounds(int i, int j, int k,
191  int length1_, int length2_, int length3_, string nom);
192 
193  void CheckBounds(int i, int j, int k, int l, int length1_, int length2_,
194  int length3_, int length4_, string nom);
195 
196  void CheckBounds(int i, int j, int k, int l, int m,
197  int length0, int length1, int length2, int length3,
198  int length4, string nom);
199 
200  void CheckBounds(int i, int j, int k, int l, int m, int n,
201  int length0, int length1, int length2, int length3,
202  int length4, int length5, string nom);
203 
204  void CheckBounds(int i, int j, int k, int l, int m, int n, int o,
205  int length0, int length1, int length2, int length3,
206  int length4, int length5, int length6, string nom);
207 
208  void CheckBounds(int i, int j, int k, int l, int m, int n, int o, int p,
209  int length0, int length1, int length2, int length3,
210  int length4, int length5, int length6, int length7,
211  string nom);
212 
213 
214  void CheckBounds(int i, int j, int k, int l, int m, int n, int o, int p,
215  int q, int length0, int length1, int length2, int length3,
216  int length4, int length5, int length6, int length7,
217  int length8, string nom);
218 
219  void CheckPointer(void*, string name);
220 
222  // LAPACKERROR //
224 
225  class LapackError: public Error
226  {
227  protected:
228  int info_;
229 
230  public:
231  LapackError(int info, string function, string comment);
232  virtual ~LapackError();
233 
234  virtual string What();
235  };
236 
237 
239  // LAPACKINFO //
241 
242 
244  {
245  private:
246  int info_;
247 
248  public:
249  LapackInfo(int info);
250 
251 #ifndef SWIG
252  operator int ();
253 #endif
254 
255  int GetInfo();
256  int& GetInfoRef();
257  };
258 
259 
260  extern LapackInfo lapack_info;
261 
262 
263 } // namespace Seldon.
264 
265 #define SELDON_FILE_ERRORS_HXX
266 #endif
Seldon::LapackInfo
Definition: Errors.hxx:243
Seldon::Error::comment_
string comment_
A comment about the error.
Definition: Errors.hxx:46
Seldon::WrongCol
Definition: Errors.hxx:138
Seldon::SolverDivergenceError
Definition: Errors.hxx:171
Seldon::WrongIndex
Definition: Errors.hxx:114
Seldon::Error
Definition: Errors.hxx:38
Seldon::WrongRow
Definition: Errors.hxx:126
Seldon::Undefined
Definition: Errors.hxx:62
Seldon::Error::description_
string description_
Message describing the exception type.
Definition: Errors.hxx:42
Seldon::WrongArgument
Definition: Errors.hxx:76
Seldon::Error::function_
string function_
Name of the function in which the error occurred.
Definition: Errors.hxx:44
Seldon::WrongDim
Definition: Errors.hxx:102
Seldon::SolverMaximumIterationError
Definition: Errors.hxx:163
Seldon
Seldon namespace.
Definition: Array.cxx:24
Seldon::IOError
Definition: Errors.hxx:150
Seldon::LapackError
Definition: Errors.hxx:225
Seldon::NoMemory
Definition: Errors.hxx:90