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
00062
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;
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
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
00111
00112
00113
00114
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
00122
00123
00124 namespace Internal
00125 {
00126
00127
00128
00129 static const unsigned int max_bytes_on_stack=1000;
00130
00131
00132
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{
00171
00172
00173
00174
00175 int size() const;
00176
00177 int num_rows() const;
00178
00179 int num_cols() const;
00180
00181
00182
00183
00184
00185
00186
00187 template<int Size, class Precision, class Base>
00188 void eval(Vector<Size, Precision, Base>& v) const;
00189
00190
00191 template <int Size, typename P1, typename B1>
00192 void plusequals(Vector<Size, P1, B1>& v) const;
00193
00194
00195 template <int Size, typename P1, typename B1>
00196 void minusequals(Vector<Size, P1, B1>& v) const;
00197
00198
00199
00200 template <int Size, typename P1, typename B1>
00201 Operator<T> add(const Vector<Size, P1, B1>& v) const;
00202
00203
00204 template <int Size, typename P1, typename B1>
00205 Operator<T> rsubtract(const Vector<Size, P1, B1>& v) const;
00206
00207
00208 template <int Size, typename P1, typename B1>
00209 Operator<T> lsubtract(const Vector<Size, P1, B1>& v) const;
00210
00211
00212
00213
00214
00215
00216
00217 template<int R, int C, class P, class B>
00218 void eval(Matrix<R,C,P,B>& m) const;
00219
00220
00221
00222 template <int Rows, int Cols, typename P1, typename B1>
00223 Operator<T> add(const Matrix<Rows,Cols, P1, B1>& m) const;
00224
00225
00226
00227 template <int Rows, int Cols, typename P1, typename B1>
00228 Operator<T> rsubtract(const Matrix<Rows,Cols, P1, B1>& m) const;
00229
00230
00231 template <int Rows, int Cols, typename P1, typename B1>
00232 Operator<T> lsubtract(const Matrix<Rows,Cols, P1, B1>& m) const;
00233
00234
00235 template <int Rows, int Cols, typename P1, typename B1>
00236 void plusequals(Matrix<Rows,Cols, P1, B1>& m) const;
00237
00238
00239 template <int Rows, int Cols, typename P1, typename B1>
00240 void minusequals(Matrix<Rows,Cols, P1, B1>& m) const;
00241
00242
00243
00244
00245
00246
00247
00248
00249 Operator<T> operator()(int size) const;
00250
00251
00252 Operator<T> operator()(int num_rows, int num_cols) const;
00253
00254
00255
00256
00257 typedef T Precision;
00258
00259
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 }
00264
00265
00266 };
00267 #else
00268 template<typename T> struct Operator;
00269 #endif
00270
00271
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
00299
00300 #ifndef TOON_DEFAULT_PRECISION
00301 typedef double DefaultPrecision;
00302 #else
00303 typedef TOON_DEFAULT_PRECISION DefaultPrecision;
00304 #endif
00305 }
00306
00307 #include <TooN/internal/dchecktest.hh>
00308 #include <TooN/internal/allocator.hh>
00309
00310 #include <TooN/internal/size_mismatch.hh>
00311 #include <TooN/internal/overfill_error.hh>
00312 #include <TooN/internal/slice_error.hh>
00313 #include <TooN/internal/debug.hh>
00314
00315 #include <TooN/internal/comma.hh>
00316
00317 #include <TooN/internal/vbase.hh>
00318 #include <TooN/internal/vector.hh>
00319
00320 #include <TooN/internal/mbase.hh>
00321 #include <TooN/internal/matrix.hh>
00322 #include <TooN/internal/reference.hh>
00323
00324 #include <TooN/internal/make_vector.hh>
00325 #include <TooN/internal/operators.hh>
00326
00327 #include <TooN/internal/objects.h>
00328
00329 #include <TooN/internal/diagmatrix.h>
00330
00331 #include <TooN/internal/data.hh>
00332 #include <TooN/internal/data_functions.hh>
00333
00334 #include <TooN/helpers.h>
00335
00336 #endif