00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef TOON_INCLUDE_TOON_H
00033 #define TOON_INCLUDE_TOON_H
00034 #include <iostream>
00035 #include <cstdlib>
00036 #include <limits>
00037 #include <new>
00038 #include <utility>
00039 #include <vector>
00040 #include <complex>
00041 #include <TooN/internal/config.hh>
00042 #include <TooN/internal/typeof.hh>
00043 #include <TooN/internal/deprecated.hh>
00044
00045 #if defined TOON_NDEBUG || defined NDEBUG
00046 #define TOON_NDEBUG_MISMATCH
00047 #define TOON_NDEBUG_SLICE
00048 #define TOON_NDEBUG_SIZE
00049 #define TOON_NDEBUG_FILL
00050 #endif
00051
00052 #ifdef TOON_INITIALIZE_RANDOM
00053 #include <ctime>
00054 #endif
00055
00056 #ifdef TOON_USE_LAPACK
00057 #ifndef TOON_DETERMINANT_LAPACK
00058 #define TOON_DETERMINANT_LAPACK 35
00059 #endif
00060 #endif
00061
00063 namespace TooN {
00064
00065 #ifdef TOON_TEST_INTERNALS
00066 namespace Internal
00067 {
00068 struct BadIndex{};
00069 struct SliceError{};
00070 struct StaticSliceError{};
00071 struct SizeMismatch{};
00072 struct StaticSizeMismatch{};
00073 struct VectorOverfill{};
00074 struct StaticVectorOverfill{};
00075 struct MatrixOverfill{};
00076 struct StaticMatrixOverfill{};
00077 struct Underfill{};
00078 }
00079 #endif
00080
00081 using std::numeric_limits;
00101 template<class C> struct IsField
00102 {
00103 static const int value = numeric_limits<C>::is_specialized;
00104 };
00105
00106 template<class C> struct IsField<std::complex<C> >
00107 {
00108 static const int value = numeric_limits<C>::is_specialized;
00109 };
00110
00115 template<class C> struct IsField<const C>
00116 {
00117 static const int value = IsField<C>::value;
00118 };
00119
00120 template<class C, class D> struct These_Types_Do_Not_Form_A_Field;
00121
00124 namespace Internal
00125 {
00129 static const unsigned int max_bytes_on_stack=1000;
00133 struct Slicing{};
00134 template<int RowStride, int ColStride> struct Slice;
00135 template<int Size, typename Precision, int Stride, typename Mem> struct GenericVBase;
00136 }
00137
00138 template<int Size, class Precision, class Base> struct Vector;
00139 template<int Rows, int Cols, class Precision, class Base> struct Matrix;
00140 template<int Size, class Precision, class Base> struct DiagonalMatrix;
00141
00142
00143 #ifdef DOXYGEN_INCLUDE_ONLY_FOR_DOCS
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170 template<typename T> struct Operator{
00173
00175 int size() const;
00177 int num_rows() const;
00179 int num_cols() const;
00181
00184
00187 template<int Size, class Precision, class Base>
00188 void eval(Vector<Size, Precision, Base>& v) const;
00189
00191 template <int Size, typename P1, typename B1>
00192 void plusequals(Vector<Size, P1, B1>& v) const;
00193
00195 template <int Size, typename P1, typename B1>
00196 void minusequals(Vector<Size, P1, B1>& v) const;
00197
00200 template <int Size, typename P1, typename B1>
00201 Operator<T> add(const Vector<Size, P1, B1>& v) const;
00202
00204 template <int Size, typename P1, typename B1>
00205 Operator<T> rsubtract(const Vector<Size, P1, B1>& v) const;
00206
00208 template <int Size, typename P1, typename B1>
00209 Operator<T> lsubtract(const Vector<Size, P1, B1>& v) const;
00210
00212
00217 template<int R, int C, class P, class B>
00218 void eval(Matrix<R,C,P,B>& m) const;
00219
00222 template <int Rows, int Cols, typename P1, typename B1>
00223 Operator<T> add(const Matrix<Rows,Cols, P1, B1>& m) const;
00224
00225
00227 template <int Rows, int Cols, typename P1, typename B1>
00228 Operator<T> rsubtract(const Matrix<Rows,Cols, P1, B1>& m) const;
00229
00231 template <int Rows, int Cols, typename P1, typename B1>
00232 Operator<T> lsubtract(const Matrix<Rows,Cols, P1, B1>& m) const;
00233
00235 template <int Rows, int Cols, typename P1, typename B1>
00236 void plusequals(Matrix<Rows,Cols, P1, B1>& m) const;
00237
00239 template <int Rows, int Cols, typename P1, typename B1>
00240 void minusequals(Matrix<Rows,Cols, P1, B1>& m) const;
00242
00243
00246
00249 Operator<T> operator()(int size) const;
00250
00252 Operator<T> operator()(int num_rows, int num_cols) const;
00254
00257 typedef T Precision;
00258
00260 template<class Pout, class Pmult> Operator<Internal::Identity<Pout> > scale_me(const Pmult& m) const
00261 {
00262 return Operator<Internal::Identity<Pout> >(val*m);
00263 }
00265
00266 };
00267 #else
00268 template<typename T> struct Operator;
00269 #endif
00270
00272 static const int Dynamic = -1;
00273 static const int Resizable = -0x7fffffff;
00274
00275 namespace Internal
00276 {
00277 template<int i, int j> struct SimpleSizer{static const int size=i;};
00278 template<int i> struct SimpleSizer<Dynamic, i>{static const int size=i;};
00279 template<int i> struct SimpleSizer<i, Dynamic>{static const int size=i;};
00280 template<> struct SimpleSizer<Dynamic, Dynamic> {static const int size=-1;};
00281
00282 template<int i> struct IsStatic
00283 {
00284 static const bool is = (i!=Dynamic && i != Resizable);
00285 };
00286
00287
00288 template<int i, int j=i> struct Sizer{
00289 static const int size=SimpleSizer<Sizer<i>::size, Sizer<j>::size>::size;
00290 };
00291
00292
00293
00294 template<int i> struct Sizer<i,i>{
00295 static const int size = IsStatic<i>::is?i:Dynamic;
00296 };
00297 }
00298
00300 typedef double DefaultPrecision;
00301 }
00302
00303 #include <TooN/internal/dchecktest.hh>
00304 #include <TooN/internal/allocator.hh>
00305
00306 #include <TooN/internal/size_mismatch.hh>
00307 #include <TooN/internal/overfill_error.hh>
00308 #include <TooN/internal/slice_error.hh>
00309 #include <TooN/internal/debug.hh>
00310
00311 #include <TooN/internal/comma.hh>
00312
00313 #include <TooN/internal/vbase.hh>
00314 #include <TooN/internal/vector.hh>
00315
00316 #include <TooN/internal/mbase.hh>
00317 #include <TooN/internal/matrix.hh>
00318 #include <TooN/internal/reference.hh>
00319
00320 #include <TooN/internal/make_vector.hh>
00321 #include <TooN/internal/operators.hh>
00322
00323 #include <TooN/internal/objects.h>
00324
00325 #include <TooN/internal/diagmatrix.h>
00326
00327 #include <TooN/internal/data.hh>
00328 #include <TooN/internal/data_functions.hh>
00329
00330 #include <TooN/helpers.h>
00331
00332 #endif