examples/calibrate3d/TooN/TooN.h

00001 
00002 /*                       
00003          Copyright (C) 2005 Tom Drummond
00004 
00005      This library is free software; you can redistribute it and/or
00006      modify it under the terms of the GNU Lesser General Public
00007      License as published by the Free Software Foundation; either
00008      version 2.1 of the License, or (at your option) any later version.
00009 
00010      This library is distributed in the hope that it will be useful,
00011      but WITHOUT ANY WARRANTY; without even the implied warranty of
00012      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013      Lesser General Public License for more details.
00014 
00015      You should have received a copy of the GNU Lesser General Public
00016      License along with this library; if not, write to the Free Software
00017      Foundation, Inc.
00018      51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00019 */
00020 #ifndef __TOON_H
00021 #define __TOON_H
00022 
00023 
00024 #include <string.h>  // for memcpy
00025 #include <cmath>    // for sqrt
00026 #include <iomanip>
00027 #include <cassert>
00028 #include <iostream> // for input and output of vectors and matrices
00029 
00030 #include <TooN/util.h>
00031 #ifndef TOON_NO_NAMESPACE
00032 namespace TooN {
00033 #endif
00034 
00035 static const int General=-1;
00036 
00037 
00038 // actual values are needed in transpose operation
00039 // which does nothing except return a ref to
00040 // a matrix with the opposite layout
00041 //enum{RowMajor=0,ColMajor=1};
00042 
00043 
00044 // just placeholders
00045 struct RowMajor{
00046   static bool is_rowmajor(){return true;}
00047 };
00048 struct ColMajor{
00049   static bool is_rowmajor(){return false;}
00050 };
00051 
00052 struct NUMERICS {
00053   // enum{Stack,Heap}; // allocation zone for fixed size stuff
00054   enum{Owner,Reference}; // ownership of variable size stuff
00055 
00056   // static const int DefaultLayout = RowMajor;
00057 
00058   typedef RowMajor DefaultLayout;
00059 
00060   // multiplication policy
00061   enum{BlasMult,CPPMult};
00062 
00063   // maximum no of mults in a matrix/vector * matrix/vector
00064   // product where we use inline c++
00065   // above this number we switch to using BLAS
00066   static const int MaxCPPMultCount = 100;
00067 
00068   // maximum no of doubles in an object before
00069   // we put it on the heap instead of the stack
00070   static const int MaxStackSize=100;  // ie 10x10 matrix
00071 };
00072 
00073 
00074 // forward declarations of all needed classes
00075 
00076 
00078 
00079 // Fixed Size Memory Access
00080 template<int Size>
00081 class Stack;
00082 
00083 template<int Size>
00084 class Heap;
00085 
00087 
00088 template <int Size, class AllocZone>
00089 class FixedVAccessor;
00090 
00091 template <int Size, int Skip>
00092 class SkipAccessor;
00093 
00094 class DynamicVAccessor;
00095 class RefSkipAccessor;
00096 
00097 template <class Accessor>
00098 class VectorBase;
00099 
00100 template <int Size, class Accessor>
00101 class FixedVector;
00102 
00103 template <class Accessor>
00104 class DynamicVector;
00105 
00106 //class RefVector;
00107 //class ConstRefVector;
00108 //class RefSkipVector;
00109 //class ConstRefSkipVector;
00110 
00111 template <int Size=General>
00112 class Vector;
00113 
00114 
00116 
00117 template <int Rows, int Cols, class Layout, class AllocZone>
00118 class FixedMAccessor;
00119 
00120 template<int Rows, int Cols, int Skip, class Layout>
00121 class SkipMAccessor;
00122 
00123 template<class Layout>
00124 class DynamicMAccessor;
00125 
00126 template <class Layout>
00127 class RefSkipMAccessor;
00128 
00129 template <class Accessor>
00130 class MatrixBase;
00131 
00132 template<int Rows, int Cols, class Accessor>
00133 struct FixedMatrix;
00134 
00135 template<class Accessor>
00136 struct DynamicMatrix;
00137 
00138 template<class Layout>
00139 class RefMatrix;
00140 template<class Layout>
00141 class ConstRefMatrix;
00142 
00143 template<class Layout>
00144 class RefSkipMatrix;
00145 template<class Layout>
00146 class ConstRefSkipMatrix;
00147 
00148 template <int Rows=General,
00149           int Cols=Rows,
00150           class Layout = typename NUMERICS::DefaultLayout >
00151 class Matrix; 
00152 
00153 
00154 // never actually use one of these
00155 // they're just used as dummy arguments
00156 // to destinguish between templated constructors
00157 // most compilers should be able to optimise them out
00158 template <class T>
00159 class Operator {};  
00160 
00161 template <int Size, int I>
00162 class ZoneHandler;
00163 
00164 template<int Size>
00165 class ZoneHandler<Size,0> {
00166 public:
00167   typedef Stack<Size> get_zone;
00168 };
00169 
00170 template<int Size>
00171 class ZoneHandler<Size,1> {
00172 public:
00173   typedef Heap<Size> get_zone;
00174 };
00175 
00176 template <int Size>
00177 class SizeTraits : public ZoneHandler<Size,(Size > NUMERICS::MaxStackSize ? 1 : 0)> {
00178 };
00179 
00180 
00181 #ifdef TOON_DEBUG
00182   #define TOON_ASSERT(X,Y) if(!(X)) throw Y()
00183   #define TOON_THROW
00184   #include <TooN/accessorexceptions.hh>
00185 #else
00186   #define TOON_ASSERT(X,Y)
00187   #define TOON_THROW throw()
00188 #endif
00189 
00190 #include <TooN/vmagic.hh>
00191 
00192 #include <TooN/membase.hh>
00193 #include <TooN/vbase.hh>
00194 #include <TooN/vaccessor.hh>
00195 #include <TooN/mbase.hh>
00196 #include <TooN/maccessor.hh>
00197 #include <TooN/vclasses.hh>
00198 #include <TooN/mclasses.hh>
00199 #include <TooN/blasoperators.hh>
00200 #include <TooN/linoperators.hh>
00201 
00202  namespace util {
00203 #include <TooN/generated.h>
00204  }
00205 
00206 #ifndef TOON_NO_NAMESPACE
00207 }
00208 #endif
00209 
00210 #ifdef TOON_USING_NAMESPACE
00211         using namespace TooN;
00212 #endif
00213 
00214 #endif
00215 

Generated on Fri Feb 22 18:26:55 2008 for QVision by  doxygen 1.5.3