00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef SELDON_FILE_SELDON_HXX
00022
00023 #include <iostream>
00024 #include <algorithm>
00025 #include <complex>
00026 #include <string>
00027 #include <sstream>
00028 #include <fstream>
00029 #include <limits>
00030 #include <cstdlib>
00031 #include <ctime>
00032 #include <exception>
00033 #include <stdexcept>
00034
00035 #ifdef SELDON_WITH_CBLAS
00036 extern "C"
00037 {
00038 #include "cblas.h"
00039 }
00040 #endif
00041
00042
00044
00046
00047 #ifdef SELDON_DEBUG_LEVEL_4
00048 #ifndef SELDON_DEBUG_LEVEL_3
00049 #define SELDON_DEBUG_LEVEL_3
00050 #endif
00051 #endif
00052
00053 #ifdef SELDON_DEBUG_LEVEL_3
00054 #ifndef SELDON_CHECK_BOUNDARIES
00055 #define SELDON_CHECK_BOUNDARIES
00056 #endif
00057 #ifndef SELDON_DEBUG_LEVEL_2
00058 #define SELDON_DEBUG_LEVEL_2
00059 #endif
00060 #endif
00061
00062 #ifdef SELDON_DEBUG_LEVEL_2
00063 #ifndef SELDON_CHECK_DIMENSIONS
00064 #define SELDON_CHECK_DIMENSIONS
00065 #endif
00066 #ifndef SELDON_DEBUG_LEVEL_1
00067 #define SELDON_DEBUG_LEVEL_1
00068 #endif
00069 #endif
00070
00071 #ifdef SELDON_DEBUG_LEVEL_1
00072 #ifndef SELDON_CHECK_MEMORY
00073 #define SELDON_CHECK_MEMORY
00074 #endif
00075 #ifndef SELDON_CHECK_IO
00076 #define SELDON_CHECK_IO
00077 #endif
00078 #ifndef SELDON_DEBUG_LEVEL_0
00079 #define SELDON_DEBUG_LEVEL_0
00080 #endif
00081 #endif
00082
00083 #ifdef SELDON_DEBUG_LEVEL_0
00084 #ifndef SELDON_DEBUG_LEVEL_1
00085 #ifndef SELDON_WITHOUT_THROW
00086 #define SELDON_WITHOUT_THROW
00087 #endif
00088 #endif
00089 #endif
00090
00091
00092 #ifndef TRY
00093 #define TRY try {
00094 #endif
00095 #ifndef END
00096 #define END \
00097 }\
00098 catch(Seldon::Error& Err)\
00099 {\
00100 Err.What();\
00101 return 1;\
00102 }\
00103 catch (std::exception& Err)\
00104 {\
00105 cout << "C++ exception: " << Err.what() << endl;\
00106 return 1;\
00107 }\
00108 catch (std::string& str)\
00109 {\
00110 cout << str << endl;\
00111 return 1;\
00112 }\
00113 catch (const char* str)\
00114 {\
00115 cout << str << endl;\
00116 return 1;\
00117 }\
00118 catch(...)\
00119 {\
00120 cout << "Unknown exception..." << endl;\
00121 return 1;\
00122 }
00123 #endif
00124
00126 #ifndef ERR
00127 #define ERR(x) cout << "Hermes - " #x << endl
00128 #endif
00129
00130 #ifndef DISP
00131 #define DISP(x) cout << #x ": " << x << endl
00132 #endif
00133
00134 #ifndef DISPLAY
00135 #define DISPLAY(x) cout << #x ": " << x << endl
00136 #endif
00137
00139 namespace Seldon
00140 {
00141 using namespace std;
00142 }
00143
00144
00145 #include "Common/Common.hxx"
00146
00147
00148 #ifndef SELDON_DEFAULT_ALLOCATOR
00149 #define SELDON_DEFAULT_ALLOCATOR MallocAlloc
00150 #endif
00151
00152 #include "Common/Allocator.hxx"
00153
00154
00155 #include "Common/Storage.hxx"
00156
00157
00158 #include "Common/Properties.hxx"
00159
00160 namespace Seldon
00161 {
00162
00163
00164
00165 template <class T, class Allocator>
00166 class Vector_Base;
00167
00168
00169 template <class T, class Storage = Vect_Full,
00170 class Allocator = SELDON_DEFAULT_ALLOCATOR<T> >
00171 class Vector
00172 {
00173
00174 };
00175
00176
00177 template <class T, class Allocator>
00178 class Vector<T, Vect_Full, Allocator>;
00179
00180
00181 template <class T, class Prop = General, class Storage = RowMajor,
00182 class Allocator = SELDON_DEFAULT_ALLOCATOR<T> >
00183 class Matrix
00184 {
00185
00186 };
00187
00188
00189 template <class T, class Prop, class Allocator>
00190 class Matrix<T, Prop, ColMajor, Allocator>;
00191
00192
00193 template <class T, class Prop, class Allocator>
00194 class Matrix<T, Prop, RowMajor, Allocator>;
00195
00196
00197 template <class T, class Prop, class Allocator>
00198 class Matrix<T, Prop, ColSymPacked, Allocator>;
00199
00200
00201 template <class T, class Prop, class Allocator>
00202 class Matrix<T, Prop, RowSymPacked, Allocator>;
00203
00204
00205 template <class T, class Prop, class Allocator>
00206 class Matrix<T, Prop, ColUpTriangPacked, Allocator>;
00207
00208
00209 template <class T, class Prop, class Allocator>
00210 class Matrix<T, Prop, ColLoTriangPacked, Allocator>;
00211
00212
00213 template <class T, class Prop, class Allocator>
00214 class Matrix<T, Prop, RowUpTriangPacked, Allocator>;
00215
00216
00217 template <class T, class Prop, class Allocator>
00218 class Matrix<T, Prop, RowLoTriangPacked, Allocator>;
00219
00220
00221 template <class T, class Prop, class Allocator>
00222 class Matrix<T, Prop, ColSparse, Allocator>;
00223
00224
00225 template <class T, class Prop, class Allocator>
00226 class Matrix<T, Prop, RowSparse, Allocator>;
00227
00228
00229 template <class T, class Prop, class Allocator>
00230 class Matrix<T, Prop, ColSymSparse, Allocator>;
00231
00232
00233 template <class T, class Prop, class Allocator>
00234 class Matrix<T, Prop, RowSymSparse, Allocator>;
00235
00236
00237 template <class T, class Prop, class Allocator>
00238 class Matrix<T, Prop, ColComplexSparse, Allocator>;
00239
00240
00241 template <class T, class Prop, class Allocator>
00242 class Matrix<T, Prop, RowComplexSparse, Allocator>;
00243
00244
00245 template <class T, class Prop, class Allocator>
00246 class Matrix<T, Prop, ColSymComplexSparse, Allocator>;
00247
00248
00249 template <class T, class Prop, class Allocator>
00250 class Matrix<T, Prop, RowSymComplexSparse, Allocator>;
00251
00252
00253 template <class T, class Allocator>
00254 class Array3D;
00255
00256
00257
00258 class SeldonTranspose
00259 {
00260 #ifdef SELDON_WITH_CBLAS
00261 protected:
00262 CBLAS_TRANSPOSE cblas_status_;
00263 #endif
00264 protected:
00265
00266 int status_;
00267 public:
00268 SeldonTranspose(int status)
00269 {
00270 status_ = status;
00271 #ifdef SELDON_WITH_CBLAS
00272 if (status_ == 0)
00273 cblas_status_ = CblasTrans;
00274 else if (status_ == 1)
00275 cblas_status_ = CblasNoTrans;
00276 else
00277 cblas_status_ = CblasConjTrans;
00278 #endif
00279 }
00280 #ifdef SELDON_WITH_CBLAS
00281 operator CBLAS_TRANSPOSE() const
00282 {
00283 return cblas_status_;
00284 }
00285 #endif
00286
00287 bool Trans() {return (status_ == 0);}
00288 bool NoTrans() {return (status_ == 1);}
00289 bool ConjTrans() {return (status_ == 2);}
00290 };
00291
00292 class class_SeldonTrans: public SeldonTranspose
00293 {
00294 public:
00295 class_SeldonTrans(): SeldonTranspose(0) {};
00296 };
00297
00298 class class_SeldonNoTrans: public SeldonTranspose
00299 {
00300 public:
00301 class_SeldonNoTrans(): SeldonTranspose(1) {};
00302 };
00303
00304 class class_SeldonConjTrans: public SeldonTranspose
00305 {
00306 public:
00307 class_SeldonConjTrans(): SeldonTranspose(2) {};
00308 };
00309
00310 class_SeldonTrans SeldonTrans;
00311 class_SeldonNoTrans SeldonNoTrans;
00312 class_SeldonConjTrans SeldonConjTrans;
00313
00314
00315
00316 class SeldonDiag
00317 {
00318 #ifdef SELDON_WITH_CBLAS
00319 protected:
00320 CBLAS_DIAG cblas_status_;
00321 #endif
00322 protected:
00323
00324 int status_;
00325 public:
00326 SeldonDiag(int status)
00327 {
00328 status_ = status;
00329 #ifdef SELDON_WITH_CBLAS
00330 if (status_ == 0)
00331 cblas_status_ = CblasNonUnit;
00332 else
00333 cblas_status_ = CblasUnit;
00334 #endif
00335 }
00336 #ifdef SELDON_WITH_CBLAS
00337 operator CBLAS_DIAG() const
00338 {
00339 return cblas_status_;
00340 }
00341 #endif
00342
00343 bool NonUnit() {return (status_ == 0);}
00344 bool Unit() {return (status_ == 1);}
00345 };
00346
00347 class class_SeldonNonUnit: public SeldonDiag
00348 {
00349 public:
00350 class_SeldonNonUnit(): SeldonDiag(0) {};
00351 };
00352
00353 class class_SeldonUnit: public SeldonDiag
00354 {
00355 public:
00356 class_SeldonUnit(): SeldonDiag(1) {};
00357 };
00358
00359 class_SeldonNonUnit SeldonNonUnit;
00360 class_SeldonUnit SeldonUnit;
00361
00362
00363
00364 class SeldonUplo
00365 {
00366 #ifdef SELDON_WITH_CBLAS
00367 protected:
00368 CBLAS_UPLO cblas_status_;
00369 #endif
00370 protected:
00371
00372 int status_;
00373 public:
00374 SeldonUplo(int status)
00375 {
00376 status_ = status;
00377 #ifdef SELDON_WITH_CBLAS
00378 if (status_ == 0)
00379 cblas_status_ = CblasUpper;
00380 else
00381 cblas_status_ = CblasLower;
00382 #endif
00383 }
00384 #ifdef SELDON_WITH_CBLAS
00385 operator CBLAS_UPLO() const
00386 {
00387 return cblas_status_;
00388 }
00389 #endif
00390
00391 operator char() const
00392 {
00393 return (status_ == 0) ? 'U' : 'L';
00394 }
00395
00396 bool Upper() {return (status_ == 0);}
00397 bool Lower() {return (status_ == 1);}
00398
00399 char Char() const
00400 {
00401 return (status_ == 0) ? 'U' : 'L';
00402 }
00403 char RevChar() const
00404 {
00405 return (status_ == 0) ? 'L' : 'U';
00406 }
00407
00408 };
00409
00410 SeldonUplo SeldonUpper(0);
00411 SeldonUplo SeldonLower(1);
00412
00413 class SeldonConjugate
00414 {
00415 protected:
00416
00417 bool status_;
00418 public:
00419 SeldonConjugate(bool status)
00420 {
00421 status_ = status;
00422 }
00423 inline bool Conj() const
00424 {
00425 return status_;
00426 }
00427 };
00428
00429 SeldonConjugate SeldonUnconj(false);
00430 SeldonConjugate SeldonConj(true);
00431
00432
00433
00434
00435 class SeldonSide
00436 {
00437 #ifdef SELDON_WITH_CBLAS
00438 protected:
00439 CBLAS_SIDE cblas_status_;
00440 #endif
00441 protected:
00442
00443 int status_;
00444 public:
00445 SeldonSide(int status)
00446 {
00447 status_ = status;
00448 #ifdef SELDON_WITH_CBLAS
00449 if (status_ == 0)
00450 cblas_status_ = CblasLeft;
00451 else
00452 cblas_status_ = CblasRight;
00453 #endif
00454 }
00455 #ifdef SELDON_WITH_CBLAS
00456 operator CBLAS_SIDE() const
00457 {
00458 return cblas_status_;
00459 }
00460 #endif
00461
00462 bool Left() {return (status_ == 0);}
00463 bool Right() {return (status_ == 1);}
00464 };
00465
00466 class class_SeldonLeft: public SeldonSide
00467 {
00468 public:
00469 class_SeldonLeft(): SeldonSide(0) {};
00470 };
00471
00472 class class_SeldonRight: public SeldonSide
00473 {
00474 public:
00475 class_SeldonRight(): SeldonSide(1) {};
00476 };
00477
00478 class_SeldonLeft SeldonLeft;
00479 class_SeldonRight SeldonRight;
00480
00481
00482 }
00483
00484
00485 #include "Array3D/Array3D.cxx"
00486 #include "Matrix/Matrix_Base.cxx"
00487 #include "Matrix/Matrix_Pointers.cxx"
00488 #include "Matrix/Matrix_Triangular.cxx"
00489 #include "Matrix/Matrix_Symmetric.cxx"
00490 #include "Matrix/Matrix_Hermitian.cxx"
00491 #include "Matrix/Matrix_Sparse.cxx"
00492 #include "Matrix/Matrix_ComplexSparse.cxx"
00493 #include "Matrix/Matrix_SymSparse.cxx"
00494 #include "Matrix/Matrix_SymComplexSparse.cxx"
00495 #include "Matrix/Matrix_SymPacked.cxx"
00496 #include "Matrix/Matrix_HermPacked.cxx"
00497 #include "Matrix/Matrix_TriangPacked.cxx"
00498 #include "Vector/Vector.cxx"
00499 #include "Computation/Basic_Functions/Functions_Matrix.cxx"
00500 #include "Computation/Basic_Functions/Functions_Vector.cxx"
00501 #include "Computation/Basic_Functions/Functions_MatVect.cxx"
00502
00503
00504 #ifdef SELDON_WITH_CBLAS
00505 #include "Computation/Interfaces/Blas_1.cxx"
00506 #include "Computation/Interfaces/Blas_2.cxx"
00507 #include "Computation/Interfaces/Blas_3.cxx"
00508 #endif
00509
00510
00511 #ifdef SELDON_WITH_LAPACK
00512 #undef LAPACK_INTEGER
00513 #define LAPACK_INTEGER int
00514 #undef LAPACK_REAL
00515 #define LAPACK_REAL float
00516 #undef LAPACK_DOUBLEREAL
00517 #define LAPACK_DOUBLEREAL double
00518 #undef LAPACK_COMPLEX
00519 #define LAPACK_COMPLEX void
00520 #undef LAPACK_DOUBLECOMPLEX
00521 #define LAPACK_DOUBLECOMPLEX void
00522 #undef LAPACK_LOGICAL
00523 #define LAPACK_LOGICAL int
00524 #undef LAPACK_L_FP
00525 #define LAPACK_L_FP int*
00526 #undef LAPACK_FTNLEN
00527 #define LAPACK_FTNLEN int*
00528 extern "C"
00529 {
00530 #include "Computation/Interfaces/clapack.h"
00531 }
00532 #include "Computation/Interfaces/Lapack.cxx"
00533 #endif
00534
00535 namespace Seldon
00536 {
00537
00538
00539 typedef Vector<int, Vect_Full, SELDON_DEFAULT_ALLOCATOR<int> > IVect;
00540 typedef Vector<float, Vect_Full, SELDON_DEFAULT_ALLOCATOR<float> > SVect;
00541 typedef Vector<double, Vect_Full, SELDON_DEFAULT_ALLOCATOR<double> > DVect;
00542 typedef Vector<complex<float>, Vect_Full,
00543 SELDON_DEFAULT_ALLOCATOR<complex<float> > > CVect;
00544 typedef Vector<complex<double>, Vect_Full,
00545 SELDON_DEFAULT_ALLOCATOR<complex<double> > > ZVect;
00546
00547 typedef Matrix<int, General, ColMajor,
00548 SELDON_DEFAULT_ALLOCATOR<int> > IGCMat;
00549 typedef Matrix<float, General, ColMajor,
00550 SELDON_DEFAULT_ALLOCATOR<float> > SGCMat;
00551 typedef Matrix<double, General, ColMajor,
00552 SELDON_DEFAULT_ALLOCATOR<double> > DGCMat;
00553 typedef Matrix<complex<float>, General, ColMajor,
00554 SELDON_DEFAULT_ALLOCATOR<complex<float> > > CGCMat;
00555 typedef Matrix<complex<double>, General, ColMajor,
00556 SELDON_DEFAULT_ALLOCATOR<complex<double> > > ZGCMat;
00557
00558 typedef Matrix<int, General, RowMajor,
00559 SELDON_DEFAULT_ALLOCATOR<int> > IGRMat;
00560 typedef Matrix<float, General, RowMajor,
00561 SELDON_DEFAULT_ALLOCATOR<float> > SGRMat;
00562 typedef Matrix<double, General, RowMajor,
00563 SELDON_DEFAULT_ALLOCATOR<double> > DGRMat;
00564 typedef Matrix<complex<float>, General, RowMajor,
00565 SELDON_DEFAULT_ALLOCATOR<complex<float> > > CGRMat;
00566 typedef Matrix<complex<double>, General, RowMajor,
00567 SELDON_DEFAULT_ALLOCATOR<complex<double> > > ZGRMat;
00568
00569 typedef Matrix<int, General, RowSparse,
00570 SELDON_DEFAULT_ALLOCATOR<int> > IGRSMat;
00571 typedef Matrix<float, General, RowSparse,
00572 SELDON_DEFAULT_ALLOCATOR<float> > SGRSMat;
00573 typedef Matrix<double, General, RowSparse,
00574 SELDON_DEFAULT_ALLOCATOR<double> > DGRSMat;
00575 typedef Matrix<complex<float>, General, RowSparse,
00576 SELDON_DEFAULT_ALLOCATOR<complex<float> > > CGRSMat;
00577 typedef Matrix<complex<double>, General, RowSparse,
00578 SELDON_DEFAULT_ALLOCATOR<complex<double> > > ZGRSMat;
00579
00580 typedef Matrix<int, General, ColSparse,
00581 SELDON_DEFAULT_ALLOCATOR<int> > IGCSMat;
00582 typedef Matrix<float, General, ColSparse,
00583 SELDON_DEFAULT_ALLOCATOR<float> > SGCSMat;
00584 typedef Matrix<double, General, ColSparse,
00585 SELDON_DEFAULT_ALLOCATOR<double> > DGCSMat;
00586 typedef Matrix<complex<float>, General, ColSparse,
00587 SELDON_DEFAULT_ALLOCATOR<complex<float> > > CGCSMat;
00588 typedef Matrix<complex<double>, General, ColSparse,
00589 SELDON_DEFAULT_ALLOCATOR<complex<double> > > ZGCSMat;
00590
00591
00592 }
00593
00594 #define SELDON_FILE_SELDON_HXX
00595 #endif