TooN 2.0.0-beta8
internal/data.hh
00001 namespace TooN{
00002     namespace Internal{
00003         template<int N, class P> class Data;
00004     }
00005 
00006 
00007     ///@internal
00008     ///@brief Object which fills a matrix some data.
00009     ///There is no size known, since the size of the data is known at compile time.
00010     ///Therefore if the size of the matrix is not known, then something deeply strange is
00011     ///going on.
00012     ///@ingroup gInternal
00013     template<int N, class P> struct Operator<Internal::Data<N, P> >
00014     {
00015         P vals[N];
00016 
00017         template<int R, int C, class T, class B>
00018         void eval(Matrix<R, C, T, B>& m) const
00019         {
00020             SizeMismatch<(R==-1?-1:(C==-1?-1:(R*C))), N>:: test(m.num_rows()*m.num_cols(), N);
00021             for(int r=0, n=0; r < R; r++)
00022                 for(int c=0; c < C; c++, n++)
00023                     m[r][c] = vals[n];
00024         }
00025     };
00026 
00027     #ifdef DOXYGEN_INCLUDE_ONLY_FOR_DOCS
00028     
00029         ///Package up the function arguments as some data for filling matrices.
00030         ///Matrices are filled in row major order.
00031         ///For example:
00032         ///@code
00033         ///   double theta = 2;
00034         ///   Matrix<2> rotation = data( cos(theta), sin(theta)
00035         ///                             -sin(theta), cos(theta));
00036         ///@endcode
00037         ///See also TooN::wrapMatrix().
00038         ///@param a The first data element.
00039         ///@ingroup gLinAlg
00040         inline Operator<Internal::Data<N, double> > Data(double a, ...);
00041 
00042         ///Package up the function arguments as some data for filling matrices.
00043         ///Any type can be uses. Matrices are filled in row-major order.
00044         ///@code
00045         ///   Matrix<2,2,float> rotation = data(1f, 2f, 3f, 4f);
00046         ///@endcode
00047         ///See also TooN::wrapMatrix().
00048         ///@param a The first data element.
00049         ///@ingroup gLinAlg
00050         template<typename Precision> inline Operator<Internal::Data<N, Precision> > Data(const Precision& a, ...);
00051 
00052     #endif
00053 
00054 }