toon-members
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Toon-members] TooN Doxyfile TooN.h determinant.h so3.h doc/do...


From: Edward Rosten
Subject: [Toon-members] TooN Doxyfile TooN.h determinant.h so3.h doc/do...
Date: Fri, 10 Jul 2009 14:05:56 +0000

CVSROOT:        /cvsroot/toon
Module name:    TooN
Changes by:     Edward Rosten <edrosten>        09/07/10 14:05:56

Modified files:
        .              : Doxyfile TooN.h determinant.h so3.h 
        doc            : documentation.h 
        internal       : allocator.hh comma.hh matrix.hh objects.h 
                         slice_error.hh 
Removed files:
        doc            : matrixdoc.h 

Log message:
        Some documentation.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/TooN/Doxyfile?cvsroot=toon&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/TooN/TooN.h?cvsroot=toon&r1=1.48&r2=1.49
http://cvs.savannah.gnu.org/viewcvs/TooN/determinant.h?cvsroot=toon&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/TooN/so3.h?cvsroot=toon&r1=1.39&r2=1.40
http://cvs.savannah.gnu.org/viewcvs/TooN/doc/documentation.h?cvsroot=toon&r1=1.30&r2=1.31
http://cvs.savannah.gnu.org/viewcvs/TooN/doc/matrixdoc.h?cvsroot=toon&r1=1.10&r2=0
http://cvs.savannah.gnu.org/viewcvs/TooN/internal/allocator.hh?cvsroot=toon&r1=1.32&r2=1.33
http://cvs.savannah.gnu.org/viewcvs/TooN/internal/comma.hh?cvsroot=toon&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/TooN/internal/matrix.hh?cvsroot=toon&r1=1.35&r2=1.36
http://cvs.savannah.gnu.org/viewcvs/TooN/internal/objects.h?cvsroot=toon&r1=1.22&r2=1.23
http://cvs.savannah.gnu.org/viewcvs/TooN/internal/slice_error.hh?cvsroot=toon&r1=1.8&r2=1.9

Patches:
Index: Doxyfile
===================================================================
RCS file: /cvsroot/toon/TooN/Doxyfile,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- Doxyfile    9 Jun 2009 13:33:22 -0000       1.6
+++ Doxyfile    10 Jul 2009 14:05:55 -0000      1.7
@@ -23,7 +23,7 @@
 # This could be handy for archiving the generated documentation or 
 # if some version control system is used.
 
-PROJECT_NUMBER         = 2.0.0-beta4
+PROJECT_NUMBER         = 2.0.0-beta5
 
 # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) 
 # base path where the generated documentation will be put. 
@@ -245,7 +245,7 @@
 # to NO (the default) then the documentation will be excluded. 
 # Set it to YES to include the internal documentation.
 
-INTERNAL_DOCS          = YES
+INTERNAL_DOCS          = NO
 
 # If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate 
 # file names in lower-case letters. If set to YES upper-case letters are also 
@@ -391,7 +391,7 @@
 # directories like "/usr/src/myproject". Separate the files or directories 
 # with spaces.
 
-INPUT                  = . doc optimization internal
+INPUT                  = . doc/documentation.h optimization internal
 
 # If the value of the INPUT tag contains directories, you can use the 
 # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 
@@ -400,7 +400,7 @@
 # *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh 
*.hxx *.hpp 
 # *.h++ *.idl *.odl *.cs *.php *.php3 *.inc
 
-FILE_PATTERNS          = documentation.h *doc.h *.h *.hh
+FILE_PATTERNS          = *.h *.hh
 
 # The RECURSIVE tag can be used to turn specify whether or not subdirectories 
 # should be searched for input files as well. Possible values are YES and NO. 

Index: TooN.h
===================================================================
RCS file: /cvsroot/toon/TooN/TooN.h,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -b -r1.48 -r1.49
--- TooN.h      2 Jul 2009 13:12:30 -0000       1.48
+++ TooN.h      10 Jul 2009 14:05:55 -0000      1.49
@@ -50,6 +50,7 @@
        #endif
 #endif
 
+///Everything lives inside this namespace
 namespace TooN {
 
 #ifdef TOON_TEST_INTERNALS
@@ -68,27 +69,39 @@
        }
 #endif
        
-       //Is the number a field? ie, *, -, *, / defined.
-       //Specialize this to make TooN work properly with new types
        using std::numeric_limits;
+       ///Is a number a field? ie, *, -, *, / defined.
+       ///Specialize this to make TooN work properly with new types.
+       ///@ingroup gLinAlg
        template<class C> struct IsField
        {
-               static const int value = numeric_limits<C>::is_specialized;
+               static const int value = numeric_limits<C>::is_specialized; 
///<Is C a field?
        };
        
+       ///@internal
+       ///@brief The namaespace holding all the internal code.
        namespace Internal
        {
+               ///@internal
+               ///@brief Maximum number of bytes to be allocated on the stack.
+               ///new is used above this number.
                static const unsigned int max_bytes_on_stack=1000;
+               ///@internal
+               ///@brief A tag used to indicate that a slice is being 
constructed.
+               ///@ingroup gInternal
                struct Slicing{};
                template<int RowStride, int ColStride> struct Slice;
+               template<int Size, typename Precision, int Stride, typename 
Mem> struct GenericVBase;
        }
 
        template<int Size, class Precision, class Base> struct Vector;
        template<int Rows, int Cols, class Precision, class Base> struct Matrix;
        template<int Size, class Precision, class Base> struct DiagonalMatrix;
 
+
        #ifdef DOXYGEN_INCLUDE_ONLY_FOR_DOCS
-               ///This is a struct used heavily in TooN.
+               ///@internal
+               ///@brief This is a struct used heavily in TooN internals.
                ///
                ///They have two main uses. The first use is in construction 
and is completely hidden.
                ///For an expression such as a+b, the return value of operator+ 
will be constructed in
@@ -99,12 +112,34 @@
                ///The features allowed (construction, addition, etc) depend on 
the members present. 
                ///For simplicity, general arguments are given below. If 
members are non-general, then the 
                ///operators will simply not be applicable to all vectors or 
matrices.
+               ///
+               ///Operators belong to any of a number of categories depending 
on the members they provide.
+               ///The categories are:
+               ///
+               /// - Sized operators
+               ///   - These know their own size and provide. 
+               ///     The sizes are used only in construction of dynamic 
vectors or
+               ///     matrices.
+               /// - Sizeable operators
+               ///   - Sizeable operators are able to generate a sized 
operator of the same sort.
+               /// - Scalable operators
+               ///   - These can be multiplied and divided by scalars.
+               ///
                ///@ingroup gInternal
                template<typename T> struct Operator{
-                       ///@name Members used by Vector
+                       ///@name Members in the category ``sized operators''
                        ///@{
-                       ///This must be provided in order to construct vectors.
+
+                       ///This must be provided in order to construct dynamic 
vectors.
                        int size() const;
+                       ///This along with num_cols() must be present in order 
to construct matrices.
+                       int num_rows() const; 
+                       ///This along with num_rows() must be present in order 
to construct matrices.
+                       int num_cols() const;
+                       ///@}
+                       
+                       ///@name Members used by Vector
+                       ///@{
 
                        ///This function must be present for construction and 
assignment
                        ///of vectors to work.
@@ -136,14 +171,6 @@
 
                        ///@name Members used by Matrix
                        ///@{
-
-                       ///This along with num_cols() must be present in order 
to construct matrices.
-                       ///The return value will be ignored for static rows.
-                       int num_rows() const; 
-                       ///This along with num_rows() must be present in order 
to construct matrices.
-                       ///The return value will be ignored for static columns.
-                       int num_cols() const;
-                       
                        ///This function must be present for construction and 
assignment
                        ///of matrices to work.
                        template<int R, int C, class P, class B>
@@ -170,10 +197,32 @@
                        ///This must be present for matrix -= operator
                        template <int Rows, int Cols, typename P1, typename B1> 
                        void minusequals(Matrix<Rows,Cols, P1, B1>& m) const;
+                       ///@}
+
+
+                       ///@name Members in the category ``sizeable oberators''
+                       ///@{
+
+                       ///Create an operator that knows its size.
+                       ///Suitable for vectors and square matrices.
+                       Operator<T> operator()(int size) const;
 
+                       ///Create an operator that knows its size, suitable for 
matrices.
+                       Operator<T> operator()(int num_rows, int num_cols) 
const;
                        ///@}
+                       
+                       ///@name Members in the category ``scalable operators''
+                       ///@{
+                       typedef T Precision; ///<Precision of the operator's 
scale.
+                       
+                       ///Scale the operator by a scalar and return a new 
opeator.
+                       template<class Pout, class Pmult> 
Operator<Internal::Identity<Pout> > scale_me(const Pmult& m) const
+                       {
+                               return Operator<Internal::Identity<Pout> 
>(val*m);
                }
+                       ///@}
 
+               };
        #else
                template<typename T> struct Operator;
        #endif

Index: determinant.h
===================================================================
RCS file: /cvsroot/toon/TooN/determinant.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- determinant.h       24 Jun 2009 15:15:43 -0000      1.2
+++ determinant.h       10 Jul 2009 14:05:55 -0000      1.3
@@ -8,32 +8,54 @@
 {
        namespace Internal
        {
+               ///@internal
+               ///@brief  Provides the static size for a square matrix. 
+               ///In
+               ///the general case, if R != C, then the matrix is not
+               ///square and so no size is provided. A compile error results.
+               ///@ingroup gInternal
                template<int R, int C> struct Square
                {
                };
 
+
+               ///@internal
+               ///@brief Provides the static size for a square matrix where 
both dimensions are the same.
+               ///@ingroup gInternal
                template<int R> struct Square<R, R>
                {
-                       static const int Size = R;
+                       static const int Size = R; ///<The size
                };
 
+               ///@internal
+               ///@brief Provides the static size for a square matrix where 
one dimension is static. 
+               ///The size must be equal to the size of the static dimension.
+               ///@ingroup gInternal
                template<int R> struct Square<R, Dynamic>
                {
-                       static const int Size = R;
+                       static const int Size = R; ///<The size
                };
+               ///@internal
+               ///@brief Provides the static size for a square matrix where 
one dimension is static. 
+               ///The size must be equal to the size of the static dimension.
+               ///@ingroup gInternal
                template<int C> struct Square<Dynamic, C>
                {
-                       static const int Size = C;
+                       static const int Size = C; ///<The size
                };
+               ///@internal
+               ///@brief Provides the static size for a square matrix where 
both dimensions are dynamic.
+               ///The size must be Dynamic.
+               ///@ingroup gInternal
                template<> struct Square<Dynamic, Dynamic>
                {
-                       static const int Size = Dynamic;
+                       static const int Size = Dynamic; ///<The size
                };
        };
 
 
        /** Compute the determinant using Gaussian elimination.
-               @param A The matrix to find the determinant of.
+               @param A_ The matrix to find the determinant of.
                @returns determinant.
                @ingroup gLinAlg
        */

Index: so3.h
===================================================================
RCS file: /cvsroot/toon/TooN/so3.h,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -b -r1.39 -r1.40
--- so3.h       6 Jul 2009 14:45:10 -0000       1.39
+++ so3.h       10 Jul 2009 14:05:55 -0000      1.40
@@ -192,11 +192,12 @@
 ///The rotation axis is given by \f$\vec{w}\f$, and the rotation angle must
 ///be computed using \f$ \theta = |\vec{w}|\f$. This is provided as a separate
 ///function primarily to allow fast and rough matrix exponentials using fast 
-///and rough approximations to \e A \nd \e B.
+///and rough approximations to \e A and \e B.
 ///
 ///@param w Vector about which to rotate.
-///@param A \f$\frac{\sin \theta}{\theta}
-///@param B \f$\frac{1 - \cos \theta}{\theta^2}
+///@param A \f$\frac{\sin \theta}{\theta}\f$
+///@param B \f$\frac{1 - \cos \theta}{\theta^2}\f$
+///@param R Matrix to hold the return value.
 ///@relates SO3
 template <typename Precision, typename VA, typename MA>
 inline void rodrigues_so3_exp(const Vector<3,Precision, VA>& w, const 
Precision A, const Precision B, Matrix<3,3,Precision,MA>& R){
@@ -229,6 +230,8 @@
        }
 }
 
+///Perform the exponential of the matrix \f$ \sum_i w_iG_i\f$
+///@param w Weightings of the generator matrices.
 template <typename Precision>
 template<int S, typename VA>
 inline SO3<Precision> SO3<Precision>::exp(const Vector<S,Precision,VA>& w){

Index: doc/documentation.h
===================================================================
RCS file: /cvsroot/toon/TooN/doc/documentation.h,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -b -r1.30 -r1.31
--- doc/documentation.h 9 Jul 2009 09:36:04 -0000       1.30
+++ doc/documentation.h 10 Jul 2009 14:05:55 -0000      1.31
@@ -757,5 +757,7 @@
 iterate function. This allows different sub algorithms (such as termination
 conditions) to be substituted in if need be.
 
address@hidden
 @defgroup gInternal TooN internals
+
 */

Index: internal/allocator.hh
===================================================================
RCS file: /cvsroot/toon/TooN/internal/allocator.hh,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -b -r1.32 -r1.33
--- internal/allocator.hh       9 Jun 2009 13:33:23 -0000       1.32
+++ internal/allocator.hh       10 Jul 2009 14:05:55 -0000      1.33
@@ -98,7 +98,9 @@
                }
 };
 
-///This allocator object sets aside memory for a statically sized object. It 
will
+///@internal
+///@brief This allocator object sets aside memory for a statically sized 
object. 
+///It will
 ///put all the data on the stack if there are less then 
TooN::max_bytes_on_stack of
 ///data, otherwise it will use new/delete.
 ///@ingroup gInternal
@@ -107,7 +109,8 @@
 };
 
 
-///Allocate memory for a Vector.
+///@internal
+///@brief Allocate memory for a Vector.
 ///@ingroup gInternal
 template<int Size, class Precision> struct VectorAlloc : public 
StaticSizedAllocator<Size, Precision> {
        
@@ -205,26 +208,37 @@
 //
 // A class similar to StrideHolder, but to hold the size information for 
matrices.
 
+///@internal
+///@brief This struct holds a size using no data for static sizes.
 ///This struct holds a size is the size is dynamic,
 ///or simply recorcs the number in the type system if
 ///the size is static.
+///@ingroup gInternal
 template<int s> struct SizeHolder
 {
        //Constructors ignore superfluous arguments
-       SizeHolder(){}
-       SizeHolder(int){}
+       SizeHolder(){}    ///<Default constrution
+       SizeHolder(int){} ///<Construct from an int and discard it.
 
+       ///Simply return the statcally known size
        int size() const{
                return s;
        }
 };
 
+///@internal
+///@brief This struct holds a size integer for dynamic sizes.
+///@ingroup gInternal
 template<> struct SizeHolder<-1>
 {
+       ///@name Construction
+       ///@{
        SizeHolder(int s)
        :my_size(s){}
+       ///@}
 
-       const int my_size;
+       const int my_size; ///<The size
+       ///Return the size
        int size() const {
                return my_size;
        }
@@ -232,38 +246,54 @@
 
 
 
+///@internal
 ///This struct holds the number of rows, only allocating space if
 ///necessary.
 ///@ingroup gInternal
 template<int S> struct RowSizeHolder: private SizeHolder<S>
 {
+       ///Construct from an int to provide a run time size if
+       ///necessary. 
+       ///@param i The size, which is discarded for the static case.
        RowSizeHolder(int i)
        :SizeHolder<S>(i){}
 
        RowSizeHolder()
        {}
 
+       ///Construct from an Operator, taking the size from the operator.
+       ///The size is only used in the dynamic case.
+       ///@param op Operator from which to determine the size.
        template<typename Op>
        RowSizeHolder(const Operator<Op>& op) : SizeHolder<S>(op.num_rows()) {}
 
+       ///Return the number of rows.
        int num_rows() const {return SizeHolder<S>::size();}
 };
 
 
+///@internal
 ///This struct holds the number of columns, only allocating space if
 ///necessary.
 ///@ingroup gInternal
 template<int S> struct ColSizeHolder: private SizeHolder<S>
 {
+       ///Construct from an int to provide a run time size if
+       ///necessary. 
+       ///@param i The size, which is discarded for the static case.
        ColSizeHolder(int i)
        :SizeHolder<S>(i){}
 
        ColSizeHolder()
        {}
 
+       ///Construct from an Operator, taking the size from the operator.
+       ///The size is only used in the dynamic case.
+       ///@param op Operator from which to determine the size.
        template<typename Op>
        ColSizeHolder(const Operator<Op>& op) : SizeHolder<S>(op.num_cols()) {}
 
+       ///Return the number of columns.
        int num_cols() const {return SizeHolder<S>::size();}    
 };
 

Index: internal/comma.hh
===================================================================
RCS file: /cvsroot/toon/TooN/internal/comma.hh,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- internal/comma.hh   18 Jun 2009 15:30:47 -0000      1.1
+++ internal/comma.hh   10 Jul 2009 14:05:55 -0000      1.2
@@ -141,7 +141,7 @@
 is detected at run-time. The checks can not be optimized out
 for dynamic vectors, so define \c TOON_NDEBUG_FILL to prevent
 the checks from being used.
address@hidden m Matrix to fill
address@hidden v Vector to fill
 @ingroup gLinAlg
 */
 template<int Size, class Precision, class Base> 
Internal::VectorStartFill<Size, Precision, Base> Fill(Vector<Size, Precision, 
Base>& v)

Index: internal/matrix.hh
===================================================================
RCS file: /cvsroot/toon/TooN/internal/matrix.hh,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -b -r1.35 -r1.36
--- internal/matrix.hh  6 May 2009 14:51:18 -0000       1.35
+++ internal/matrix.hh  10 Jul 2009 14:05:55 -0000      1.36
@@ -30,6 +30,82 @@
 
 namespace TooN {
 
+/**
+A matrix.
+Support is provided for all the usual matrix operations: 
+- the (a,b) notation can be used to access an element directly
+- the [] operator can be used to yield a vector from a matrix (which can be 
used
+as an l-value)
+- they can be added and subtracted
+- they can be multiplied (on either side) or divided by a scalar on the right:
+- they can be multiplied by matrices or vectors
+- submatrices can be extracted using the templated slice() member function
+- they can be transposed (and the transpose used as an l-value)
+- inverse is \e not supported. Use one of the @link gDecomps matrix
+decompositions @endlink instead
+
+See individual member function documentation for examples of usage.
+
+\par Statically-sized matrices
+
+The library provides classes for statically and dynamically sized matrices. As
+with @link Vector address@hidden, statically sized matrices are more efficient,
+since their size is determined at compile-time, not run-time.
+To create a \f$3\times4\f$ matrix, use:
address@hidden
+Matrix<3,4> M;
address@hidden
+or replace 3 and 4 with the dimensions of your choice. If the matrix is square,
+it can be declared as:
address@hidden
+Matrix<3> M;
address@hidden
+which just is a synonym for <code>Matrix<3,3></code>. Matrices can also be
+constructed from pointers or static 1D or 2D arrays of doubles:
address@hidden
+
+  double dvals1[9]={1,2,3,4,5,6};
+  Matrix<2,3, Reference::RowMajor> M2 (dvals1);
address@hidden
+
+\par Dynamically-sized matrices
+
+To create a dynamically sized matrix, use:
address@hidden
+Matrix<> M(num_rows, num_cols);
address@hidden
+where \a num_rows and \a num_cols are integers which will be evaluated at run
+time.
+
+Half-dynamic matriced can be constructed in either dimension:
address@hidden
+       Matrix<Dynamic, 2> M(num_rows, 2);
address@hidden
+note that the static dimension must be provided, but it is ignored.
+
address@hidden
+
+<code>Matrix<></code> is a synonym for <code> Matrix<Dynamic, Dynamic> </code> 
which is
+<code>%Matrix<-1,-1></code>
+
+\par Row-major and column-major
+
+The library supports both row major (the default - but you can change this if
+you prefer) and column major layout ordering. Row major implies that the matrix
+is laid out in memory in raster scan order:
+\f[\begin{matrix}\text{Row major} & \text {Column major}\\
+\begin{bmatrix}1&2&3\\4&5&6\\7&8&9\end{bmatrix} &
+\begin{bmatrix}1&4&7\\2&5&8\\3&6&9\end{bmatrix} \end{matrix}\f]
+You can override the default for a specific matrix by specifying the layout 
when
+you construct it:
address@hidden
+Matrix<3,3,double,ColMajor> M1;
+Matrix<-1,-1,double,RowMajor> M2(nrows, ncols);
address@hidden
+In this case the precision template argument must be given as it precedes the 
layout argument
+
address@hidden gLinAlg
+**/
 template <int Rows=-1, int Cols=Rows, class Precision=DefaultPrecision, class 
Layout = RowMajor>
 struct Matrix : public Layout::template MLayout<Rows, Cols, Precision>
 {
@@ -40,26 +116,37 @@
        using Layout::template MLayout<Rows, Cols, Precision>::num_cols;
 
        //Use Tom's sneaky constructor hack...
+
+       ///@name Construction and destruction
+       ///@{
+
+       ///Construction of static matrices. Values are not initialized.
        Matrix(){}
 
+       ///Construction of dynamic matrices. Values are not initialized.
        Matrix(int rows, int cols) :
                Layout::template MLayout<Rows,Cols,Precision>(rows, cols)
        {}
 
+       ///Construction of statically sized slice matrices
        Matrix(Precision* p) :
                Layout::template MLayout<Rows, Cols, Precision>(p)
        {}
 
+       ///Construction of dynamically sized slice matrices
        Matrix(Precision* p, int r, int c) :
                Layout::template MLayout<Rows, Cols, Precision>(p, r, c)
        {}
 
-       // Internal constructor used by GenericMBase::slice(...)
+       /// Advanced construction of dynamically sized slice matrices.
+       /// Internal constructor used by GenericMBase::slice(...).
        Matrix(Precision* data, int rows, int cols, int rowstride, int 
colstride, Internal::Slicing)
        :Layout::template MLayout<Rows, Cols, Precision>(data, rows, cols, 
rowstride, colstride){}
 
+
        //See vector.hh and allocator.hh for details about why the
        //copy constructor should be default.
+       ///Construction from an operator.
        template <class Op>
        inline Matrix(const Operator<Op>& op)
                :Layout::template MLayout<Rows,Cols,Precision>(op)
@@ -67,6 +154,16 @@
                op.eval(*this);
        }
 
+       /// constructor from arbitrary matrix
+       template<int Rows2, int Cols2, typename Precision2, typename Base2>
+       inline Matrix(const Matrix<Rows2, Cols2,Precision2,Base2>& from)
+       :Layout::template MLayout<Rows,Cols,Precision>(from.num_rows(), 
from.num_cols())
+       {
+           operator=(from);
+       }
+       ///@}
+
+
        // constructors to allow return value optimisations
        // construction from 1-ary operator
        template <class T, class Op>
@@ -84,15 +181,9 @@
            Op::eval(*this,lhs,rhs);
        }
 
-       // constructor from arbitrary matrix
-       template<int Rows2, int Cols2, typename Precision2, typename Base2>
-       inline Matrix(const Matrix<Rows2, Cols2,Precision2,Base2>& from)
-       :Layout::template MLayout<Rows,Cols,Precision>(from.num_rows(), 
from.num_cols())
-       {
-           operator=(from);
-       }
-
-       // operator = from copy
+       ///@name Assignment
+       ///@{
+       /// operator = from copy
        inline Matrix& operator= (const Matrix& from)
        {
                SizeMismatch<Rows, Rows>::test(num_rows(), from.num_rows());
@@ -125,6 +216,10 @@
 
            return *this;
        }
+       ///@}
+
+       ///@name operations on the matrix
+       ///@{
 
        Matrix& operator*=(const Precision& rhs)
        {
@@ -210,11 +305,189 @@
            return 0;
        }
 
+       ///@}
 
+       /// @name Misc
+       /// @{
+
+       /// return me as a non const reference - useful for temporaries
        Matrix& ref()
        {
                return *this;
        }
+       ///@}
+
+       #ifdef DOXYGEN_INCLUDE_ONLY_FOR_DOCS
+  
+               /**
+               Access an element from the matrix.
+               The index starts at zero, i.e. the top-left element is m(0, 0).
+               @code
+               double d[2][3] = {{1, 2, 3}, {4, 5, 6}};
+               Matrix<2,3> m(d);
+               double e = m(1,2);     // now e = 6.0;
+               @endcode
+               */
+               const double& operator() (int r, int c) const;
+
+               /**
+               Access an element from the matrix.
+               @param row_col <code>row_col.first</code> holds the row, 
<code>row_col.second</code> holds the column.
+               */
+               const double& operator[](const std::pair<int,int>& row_col) 
const;
+               /**
+                       @overload
+               */
+               double& operator[](const std::pair<int,int>& row_col);
+
+               /**
+               Access an element from the matrix.
+               This can be used as either an r-value or an l-value. The index 
starts at zero,
+               i.e. the top-left element is m(0, 0).
+               @code
+               double d[2][3] = {{1, 2, 3}, {4, 5, 6}};
+               Matrix<2,3> m(d);
+               m(1,2) = 8;     // now d = [1 2 3]
+                                         //         [4 5 8]
+               @endcode
+               */
+               double& operator() (int r, int c);
+
+               /**
+               Access a row from the matrix.
+               This can be used either as an r-value or an l-value. The index 
starts at zero,
+               i.e. the first row is m[0]. To extract a column from a matrix, 
apply [] to the
+               transpose of the matrix (see example). This can be used either 
as an r-value
+               or an l-value. The index starts at zero, i.e. the first row (or 
column) is
+               m[0].
+               @code
+               double d[2][3] = {{1, 2, 3}, {4, 5, 6}};
+               Matrix<2,3> m(d);
+               Vector<3> v = m[1];       // now v = [4 5 6];
+               Vector<2> v2 = m.T()[0];  // now v2 = [1 4];
+               @endcode
+               */
+               const Vector& operator[] (int r) const;
+
+               /**
+               Access a row from the matrix.
+               This can be used either as an r-value or an l-value. The index 
starts at zero,
+               i.e. the first row is m[0]. To extract a column from a matrix, 
apply [] to the
+               transpose of the matrix (see example). This can be used either 
as an r-value
+               or an l-value. The index starts at zero, i.e. the first row (or 
column) is
+               m[0].
+               @code
+               double d[2][3] = {{1, 2, 3}, {4, 5, 6}};
+               Matrix<2,3> m(d);
+               Zero(m[0]);   // set the first row to zero
+               Vector<2> v = 8,9;
+               m.T()[1] = v; // now m = [0 8 0]
+                                       //         [4 9 6]
+               @endcode
+               */
+               Vector& operator[] (int r);
+
+               /// How many rows does this matrix have?
+               int num_rows() const;
+
+               /// How many columns does this matrix have?
+               int num_cols() const;
+
+               /// What is the memory layout of this matrix?
+               {RowMajor, ColMajor} layout const;
+               //@}
+
+               /// @name Transpose and sub-matrices
+               //@{
+               /**
+               The transpose of the matrix. This is a very fast operation--it 
simply
+               reinterprets a row-major matrix as column-major or vice-versa. 
This can be
+               used as an l-value.
+               @code
+               double d[2][3] = {{1, 2, 3}, {4, 5, 6}};
+               Matrix<2,3> m(d);
+               Zero(m[0]);   // set the first row to zero
+               Vector<2> v = 8,9;
+               m.T()[1] = v; // now m = [0 8 0]
+                                       //         [4 9 6]
+               @endcode
+               */
+               const Matrix<Cols, Rows>& T() const;
+
+               /**
+               The transpose of the matrix. This is a very fast operation--it 
simply
+               reinterprets a row-major  matrix as column-major or vice-versa. 
The result can
+               be used as an l-value.
+               @code
+               double d[2][3] = {{1, 2, 3}, {4, 5, 6}};
+               Matrix<2,3> m(d);
+               Vector<2> v = 8,9;
+               // Set the first column to v
+               m.T()[0] = v; // now m = [8 2 3]
+                                       //         [9 5 6]
+               @endcode
+               <b>This means that the semantics of <code>M=M.T()</code> are 
broken</b>. In
+               general, it is not  necessary to say <code>M=M.T()</code>, 
since you can use
+               M.T() for free whenever you need the transpose, but if you do 
need to, you
+               have to use the Tranpose() function defined in 
<code>helpers.h</code>.
+               */
+               Matrix<Cols, Rows>& T();
+
+               /**
+               Extract a sub-matrix. The matrix extracted will be begin at 
element
+               (Rstart, Cstart) and will contain the next Rsize by Csize 
elements.
+               @code
+               double d[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
+               Matrix<3> m(d);
+               Extract the top-left 2x2 matrix
+               Matrix<2> b = m.slice<0,0,2,2>();  // b = [1 2]
+                                                                               
  //     [4 5]
+               @endcode
+               */
+               template<Rstart, Cstart, Rsize, Csize>
+               const Matrix<Rsize, Csize>& slice() const;
+
+               /**
+               Extract a sub-matrix. The matrix extracted will be begin at 
element (Rstart,
+               Cstart) and will contain the next Rsize by Csize elements. This 
can be used as
+               either an r-value or an l-value.
+               @code
+               double d[2][3] = {{1, 2, 3}, {4, 5, 6}};
+               Matrix<2,3> m(d);
+               Zero(m.slice<0,2,2,1>());  // b = [1 2 0]
+                                                                 //     [4 5 0]
+               @endcode
+               */
+               template<Rstart, Cstart, Rsize, Csize>
+               Matrix<Rsize, Csize>& slice();
+
+               /**
+               Extract a sub-matrix with runtime location and size. The matrix 
extracted will
+               begin at element (rstart, cstart) and will
+               contain the next rsize by csize elements.
+               @code
+               Matrix<> m(3,3);
+               Extract the top-left 2x2 matrix
+               Matrix<2> b = m.slice(0,0,2,2);
+               @endcode
+               */
+               const Matrix<>& slice(int rstart, int cstart, int rsize, int 
csize) const;
+
+               /**
+               Extract a sub-matrix with runtime location and size, which can 
be used as
+               an l-value. The matrix extracted will be begin at element 
(rstart, cstart) and
+               will contain the next rsize by csize elements.
+               @code
+               Matrix<> m(3,3);
+               Zero(m.slice(0,0,2,2));
+               @endcode
+               */
+               Matrix<>& slice(int rstart, int cstart, int rsize, int csize);
+
+               //@}
+
+
+       #endif
 };
 
 }

Index: internal/objects.h
===================================================================
RCS file: /cvsroot/toon/TooN/internal/objects.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -b -r1.22 -r1.23
--- internal/objects.h  10 Jul 2009 13:20:38 -0000      1.22
+++ internal/objects.h  10 Jul 2009 14:05:56 -0000      1.23
@@ -45,9 +45,13 @@
        template<class P> class SizedScalars;   
        template<class P> class RCScalars;
 
+       ///@internal
+       ///@brief This class represents 1 and only in all its forms.
+       ///@ingroup gInternal
        struct One{
-               One(){}
-               //Generic cast to anything
+
+               One(){} ///<This constructor does nothing. This allows const 
One to be declared with no initializer.
+               ///Generic cast to anything
                template<class C> operator C() const
                {
                        return 1;
@@ -64,25 +68,43 @@
                return -1;
        }
 
+       ///@internal
+       ///@brief For an instance \e i of type C, what is the type of \e -i?
+       ///Usually the answer is that is it the same type.
+       ///@ingroup gInternal
        template<class C> struct NegType
        {
-               typedef C Type;
+               typedef C Type; ///<The type of -C
        };
 
+       /address@hidden
+          @brief The type of -One
+          @ingroup gInternal
+       */
        template<> struct NegType<One>
        {
+               ///One really repersents 1. Therefore -One is not the same type
+               ///as One.
                typedef int Type;
        };
 
-       //One can be converted in to anything, so the resulting type is
-       //a field if the other type is a field.
+       ///@internal
+       ///@brief Does One behave as a field with respect to Rhs?
+       ///@ingroup gInternal
        template<class Rhs> struct Field<One, Rhs>
        {
+               ///One can be converted in to anything, so the resulting type is
+               ///a field if the other type is a field.
                static const int is = IsField<Rhs>::value;
        };
 
+       ///@internal
+       ///@brief Does One behave as a field with respect to Lhs?
+       ///@ingroup gInternal
        template<class Lhs> struct Field<Lhs, One>
        {
+               ///One can be converted in to anything, so the resulting type is
+               ///a field if the other type is a field.
                static const int is = IsField<Lhs>::value;
        };
 
@@ -98,7 +120,8 @@
 template<> struct Operator<Internal::RCZero>;
 
 
-///Object which behaves like a block of zeros. See TooN::Zeros.
+///@internal
+///@brief Object which behaves like a block of zeros. See TooN::Zeros.
 ///@ingroup gInternal
 template<> struct Operator<Internal::Zero> {
        ///@name Operator members
@@ -127,33 +150,34 @@
        
 };
 
-///Variant of the Zeros object which holds two sizes for
-///constructing dynamic matrices.
+///@internal
+///@brief Variant of the Zeros object which holds two sizes for constructing 
dynamic matrices.
 ///@ingroup gInternal
 template<> struct Operator<Internal::RCZero> : public Operator<Internal::Zero> 
{
+
+       ///@name Operator members determining the size.
+       ///@{
        Operator(int r, int c) : my_rows(r), my_cols(c) {}
 
        const int my_rows;
        const int my_cols;
        
-       ///@name Operator members
-       ///@{
        int num_rows() const {return my_rows;}
        int num_cols() const {return my_cols;}
        ///@}
 };
 
-///Variant of the Zeros object which holds a size for
-///constructing dynamic vectors.
+///@internal
+///@brief Variant of the Zeros object which holds a size for constructing 
dynamic vectors.
 ///@ingroup gInternal
 template<> struct Operator<Internal::SizedZero> : public 
Operator<Internal::Zero> {
 
+       ///@name Operator members determining the size for vectors and square 
matrices.
+       ///@{
        Operator(int s) : my_size(s) {}
                
        const int my_size;
        
-       ///@name Operator members
-       ///@{
        int size() const {return my_size;}
        int num_rows() const {return my_size;}
        int num_cols() const {return my_size;}
@@ -173,18 +197,23 @@
 // Identity
 //////////////
 
-///Operator to construct a new matrix with idendity added 
+///@internal
+///@brief Operator to construct a new matrix with idendity added 
 ///@ingroup gInternal
 template<int R, int C, class P, class B, class Precision> struct 
Operator<Internal::AddIdentity<R,C,P,B,Precision> >
 {
-       const Precision s;
-       const Matrix<R,C,P,B>& m;
-       bool invert_m;
+       const Precision s;   ///<Scale of the identity matrix
+       const Matrix<R,C,P,B>& m; ///<matrix to which the identity should be 
added
+       bool invert_m; ///<Whether the identity should be added to + or - m
 
-       ///@name Operator members
+       ///@name Construction
        ///@{
        Operator(Precision s_, const Matrix<R,C,P,B>& m_, bool b)
                :s(s_),m(m_),invert_m(b){}
+       ///@}
+
+       ///@name Operator members
+       ///@{
        template<int R1, int C1, class P1, class B1>
        void eval(Matrix<R1,C1,P1,B1>& mm) const{
                for(int r=0; r < m.num_rows(); r++)
@@ -197,7 +226,10 @@
                for(int i=0; i < m.num_rows(); i++)
                                mm[i][i] += (P)s;
        }
+       ///@}
 
+       ///@name Sized operator members
+       ///@{
        int num_rows() const
        {
                return m.num_rows();
@@ -209,21 +241,36 @@
        ///@}
 };
 
-///Object which behaves like an Identity matrix. See TooN::Identity.
+///@internal
+///@brief Object which behaves like an Identity matrix. See TooN::Identity.
 ///@ingroup gInternal
 template<class Pr> struct Operator<Internal::Identity<Pr> > {
        
+       ///@name Scalable operators members
+       ///@{
+
        typedef Pr Precision;
+       template<class Pout, class Pmult> Operator<Internal::Identity<Pout> > 
scale_me(const Pmult& m) const
+       {
+               return Operator<Internal::Identity<Pout> >(val*m);
+       }
+       ///}
+       
+       ///<Scale of the identity matrix.
        const Precision val;
+
+       ///@name Construction
+       ///@{
        Operator(const Precision& v)
                :val(v)
        {}
 
        Operator()
        {}
+       ///}
+
        ///@name Operator members
        ///@{
-       
        template<int R, int C, class P, class B>
        void eval(Matrix<R,C,P,B>& m) const {
                SizeMismatch<R, C>::test(m.num_rows(), m.num_cols());
@@ -267,42 +314,45 @@
                SizeMismatch<Rows, Cols>::test(m.num_rows(), m.num_cols());
                return 
Operator<Internal::AddIdentity<Rows,Cols,P1,B1,Precision> >(val, m, 1);
        }
-
-       template<class Pout, class Pmult> Operator<Internal::Identity<Pout> > 
scale_me(const Pmult& m) const
-       {
-               return Operator<Internal::Identity<Pout> >(val*m);
-       }
-
        ///@}
 
+       ///@name Sizeable operator members
+       ///@{
        Operator<Internal::SizedIdentity<Precision> > operator()(int s){
                return Operator<Internal::SizedIdentity<Precision> >(s, val);
        }
+       ///@}
 };
        
-///A variant of Identity which holds a size, allowing
-///dynamic matrices to be constructed
+///@internal
+///@brief A variant of Identity which holds a size, allowing dynamic matrices 
to be constructed
 ///@ingroup gInternal
 template<class Precision> struct Operator<Internal::SizedIdentity<Precision> > 
        : public  Operator<Internal::Identity<Precision> > {
 
        using Operator<Internal::Identity<Precision> >::val;
-       const int my_size;
 
+       ///@name Constructors
+       ///@{
        Operator(int s, const Precision& v)
                :Operator<Internal::Identity<Precision> > (v), my_size(s)
        {}
+       ///@}
 
-       ///@name Operator members
+       ///@name Sized operator members
        ///@{
+       const int my_size;
        int num_rows() const {return my_size;}
        int num_cols() const {return my_size;}
        ///@}
 
+       ///@name Scalable operator members
+       ///@{
        template<class Pout, class Pmult> 
Operator<Internal::SizedIdentity<Pout> > scale_me(const Pmult& m) const
        {
                return Operator<Internal::SizedIdentity<Pout> >(my_size, val*m);
        }
+       ///@}
 };
 
////////////////////////////////////////////////////////////////////////////////
 //
@@ -310,15 +360,20 @@
 //
 
        
-///Operator to construct a new vector a a vector with a scalar added to every 
element
+///@internal
+///@brief Operator to construct a new vector a a vector with a scalar added to 
every element
 ///@ingroup gInternal
 template<int S, class P, class B, class Precision> struct 
Operator<Internal::ScalarsVector<S,P,B,Precision> >
 {
-       const Precision s;
-       const Vector<S,P,B>& v;
-       const bool invert_v;
+       const Precision s;      ///<Scalar to add
+       const Vector<S,P,B>& v; ///<Vector to be added to.
+       const bool invert_v;    ///<Whether to use + or - \c v
+
+       ///@name Constructors
+       ///@{
        Operator(Precision s_, const Vector<S,P,B>& v_, bool inv)
                :s(s_),v(v_),invert_v(inv){}
+       ///@}
 
        ///@name Operator members
        ///@{
@@ -330,7 +385,10 @@
                        else
                                vv[i] = s + v[i];
        }
+       ///@}
 
+       ///@name Sized operator members
+       ///@{
        int size() const
        {
                return v.size();
@@ -338,13 +396,14 @@
        ///@}
 };
 
-///Operator to construct a new matrix a a matrix with a scalar added to every 
element
+///@internal
+///@brief Operator to construct a new matrix a a matrix with a scalar added to 
every element
 ///@ingroup gInternal
 template<int R, int C, class P, class B, class Precision> struct 
Operator<Internal::ScalarsMatrix<R,C,P,B,Precision> >
 {
-       const Precision s;
-       const Matrix<R,C,P,B>& m;
-       const bool invert_m;
+       const Precision s;        ///<Scalar to add
+       const Matrix<R,C,P,B>& m; ///<Vector to be added to.
+       const bool invert_m;      ///<Whether to use + or - \c m
        ///@name Operator members
        ///@{
        Operator(Precision s_, const Matrix<R,C,P,B>& m_, bool inv)
@@ -358,7 +417,10 @@
                                else
                                        mm[r][c] = s + m[r][c];
        }
+       ///@}
 
+       ///@name Sized operator members
+       ///@{
        int num_rows() const
        {
                return m.num_rows();
@@ -370,20 +432,27 @@
        ///@}
 };
 
-///Generic scalars object. Knows how to be added, knows how to deal with += 
and so on.
+///@internal
+///@brief Generic scalars object. Knows how to be added, knows how to deal 
with += and so on.
 ///See TooN::Ones
 ///@ingroup gInternal
 template<class P> struct Operator<Internal::Scalars<P> >
 {
+       ///@name Scalable operator members
+       ///@{
        typedef P Precision;
-       const Precision s;
-       //Default argument in constructor, otherwise Doxygen mis-parses
-       //a static object with a constructor as a function.
+       ///@}
+
+       const Precision s; ///<Value of the scalar being represented.  
+       
+       ///@name Constructors
+       ///@{
        Operator(Precision s_)
                :s(s_){}
 
        Operator()
        {}
+       ///@}
 
        ////////////////////////////////////////
        //
@@ -484,6 +553,9 @@
        // Create sized versions for initialization
        //
 
+       ///@name Sizeable operators members
+       ///@{
+
        Operator<Internal::SizedScalars<Precision> > operator()(int size) const
        {
                return Operator<Internal::SizedScalars<Precision> > (s,size);
@@ -493,29 +565,45 @@
        {
                return Operator<Internal::RCScalars<Precision> > (s,r,c);
        }
+       ///@}
 
+       ///@name Scalable operator members
+       ///@{
        template<class Pout, class Pmult> Operator<Internal::Scalars<Pout> > 
scale_me(const Pmult& m) const
        {
                return Operator<Internal::Scalars<Pout> >(s*m);
        }
+       ///@}
 };
 
-///Variant of the Operator<Internal::Scalars> object which holds a size
-///to construct dynamic vectors.
+///@internal
+///@brief Variant of the Operator<Internal::Scalars> object which holds a size 
to construct dynamic vectors or square matrices.
 ///@ingroup gInternal 
 template<class P> struct Operator<Internal::SizedScalars<P> >: public 
Operator<Internal::Scalars<P> >
 {
        using Operator<Internal::Scalars<P> >::s;
-       const int my_size;
-       ///@name Operator members
+       ///@name Sized operator members
        ///@{
+       const int my_size;
        int size() const {
                return my_size;
        }
+       int num_rows() const {
+               return my_size;
+       }
+       int num_cols() const {
+               return my_size;
+       }
+       ///@}
                
+       ///@name Constructors
+       ///@{
        Operator(P s, int sz)
                :Operator<Internal::Scalars<P> >(s),my_size(sz){}
+       ///@}
                
+       ///@name Scalable operator members
+       ///@{
        template<class Pout, class Pmult> Operator<Internal::SizedScalars<Pout> 
> scale_me(const Pmult& m) const
        {
                return Operator<Internal::SizedScalars<Pout> >(s*m, my_size);
@@ -528,8 +616,8 @@
 };
 
                
-///Variant of Scalars (see TooN::Ones) which holds two 
-///sizes to constructo dynamic matrices.
+///@internal
+///@brief Variant of Scalars (see TooN::Ones) which holds two sizes to 
construct dynamic matrices.
 ///@ingroup gInternal
 template<class P> struct Operator<Internal::RCScalars<P> >: public 
Operator<Internal::Scalars<P> >
 {

Index: internal/slice_error.hh
===================================================================
RCS file: /cvsroot/toon/TooN/internal/slice_error.hh,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- internal/slice_error.hh     29 Apr 2009 21:56:22 -0000      1.8
+++ internal/slice_error.hh     10 Jul 2009 14:05:56 -0000      1.9
@@ -34,9 +34,16 @@
        template<bool StaticBad> 
        struct BadSlice;
 
+       ///@internal
+       ///A static slice is OK.
+       ///This class is used after it has been determined that a slice is OK.
+       ///It does nothing except provide a callable function. By contrast, 
+       ///if the slice is not OK, then the class is not specified and the 
function
+       ///is therefore not callable, and a compile error results.
+       ///@ingroup gInternal
        template<> 
        struct BadSlice<0>{
-               static void check(){}
+               static void check(){} ///<This function does nothing: it merely 
exists.
        };
 
        template<int Size, int Start, int Length> 

Index: doc/matrixdoc.h
===================================================================
RCS file: doc/matrixdoc.h
diff -N doc/matrixdoc.h
--- doc/matrixdoc.h     22 May 2009 10:31:43 -0000      1.10
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,358 +0,0 @@
-/*
-    Copyright (c) 2005 Paul Smith
-
-       Permission is granted to copy, distribute and/or modify this document 
under
-       the terms of the GNU Free Documentation License, Version 1.2 or any 
later
-       version published by the Free Software Foundation; with no Invariant
-       Sections, no Front-Cover Texts, and no Back-Cover Texts.
-
-    You should have received a copy of the GNU Free Documentation License
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc.
-    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
-*/
-// A proxy version of the Matrix class,
-// cleaned up to present a comprehensible
-// version of the Mector interface
-
-#ifdef DOXYGEN_INCLUDE_ONLY_FOR_DOCS
-
-#include <iostream>
-
-/// All classes and functions are within this namespace
-namespace TooN
-{
-
-/**
address@hidden Matrix matrixdoc.h TooN/toon.h
-A matrix.
-Support is provided for all the usual matrix operations: 
-- the (a,b) notation can be used to access an element directly
-- the [] operator can be used to yield a vector from a matrix (which can be 
used
-as an l-value)
-- they can be added and subtracted
-- they can be multiplied (on either side) or divided by a scalar on the right:
-- they can be multiplied by matrices or vectors
-- submatrices can be extracted using the templated slice() member function
-- they can be transposed (and the transpose used as an l-value)
-- inverse is \e not supported. Use one of the @link gDecomps matrix
-decompositions @endlink instead
-
-See individual member function documentation for examples of usage.
-
-\par Statically-sized matrices
-
-The library provides classes for statically and dynamically sized matrices. As
-with @link Vector address@hidden, statically sized matrices are more efficient,
-since their size is determined at compile-time, not run-time.
-To create a \f$3\times4\f$ matrix, use:
address@hidden
-Matrix<3,4> M;
address@hidden
-or replace 3 and 4 with the dimensions of your choice. If the matrix is square,
-it can be declared as:
address@hidden
-Matrix<3> M;
address@hidden
-which just is a synonym for <code>Matrix<3,3></code>. Matrices can also be
-constructed from pointers or static 1D or 2D arrays of doubles:
address@hidden
-void foo(double* dptr) {
-
-  Matrix<3> M1 (dptr);
-
-  double dvals1[9]={1,2,3,4,5,6};
-  Matrix<2,3> M2 (dvals1);
-
-  double dvals2[2][3]={{1,2,3},{4,5,6}};
-  Matrix<2,3> M3 (dvals2);
-
-  // ...
-}
address@hidden
-
-\par Dynamically-sized matrices
-
-To create a dynamically sized matrix, use:
address@hidden
-Matrix<> M(num_rows, num_cols);
address@hidden
-where \a num_rows and \a num_cols are integers which will be evaluated at run
-time. Dynamically-sized matrices can be constructed from pointers in a similar
-manner to static sized matrices:
address@hidden
-void bar(int r, int c, double* dptr) {
-  Matrix<> M (r,c,dptr);
-  // ...
-}
address@hidden
-
-<code>Matrix<></code> is a synonym for <code> Matrix<Dynamic, Dynamic> </code> 
which is
-<code>%Matrix<-1,-1></code>
-
-\par Row-major and column-major
-
-The library supports both row major (the default - but you can change this if
-you prefer) and column major layout ordering. Row major implies that the matrix
-is laid out in memory in raster scan order:
-\f[\begin{matrix}\text{Row major} & \text {Column major}\\
-\begin{bmatrix}1&2&3\\4&5&6\\7&8&9\end{bmatrix} &
-\begin{bmatrix}1&4&7\\2&5&8\\3&6&9\end{bmatrix} \end{matrix}\f]
-You can override the default for a specific matrix by specifying the layout 
when
-you construct it:
address@hidden
-Matrix<3,3,double,ColMajor> M1;
-Matrix<-1,-1,double,RowMajor> M2(nrows, ncols);
address@hidden
-In this case the precision template argument must be given as it precedes the 
layout argument
-
address@hidden gLinAlg
-**/
-template<int Rows, int Cols>
-class Matrix
-{
-public:
-  /// @name Constructors
-  //@{
-  
-  /// Default constructor.
-  /// For fixed sized matrices, this does nothing, i.e. does not guarantee to
-  initialise the vector to any particular values.
-  /// For dynamically sized matrices, this sets up a 0x0 matrix.
-  Matrix();
-  
-  /**
-  Construct a (fixed-size) matrix from a 1D array of doubles. By default the
-  layout ordering is row major (along the rows first i.e. raster scan order),
-  unless <code>ColMajor</code> is specified in the template arguments (see
-  detailed description). No errors are generated if the array is the wrong
-  length.
-  @code
-  double d[4] = {1, 2, 3, 4};
-  Matrix<2> m(d);  // now m = [1 2]
-                    //         [3 4]
-  @endcode
-  */
-  Matrix(double darray[Rows*Cols]);
-  
-  /**
-  Construct a (fixed-size) matrix from a 2D array of doubles. No errors
-  are generated if the array is the wrong length.
-  @code
-  double d[2][3] = {{1, 2, 3}, {4, 5, 6}};
-  Matrix<2,3> m(d);  // now m = [1 2 3]
-                      //         [4 5 6]
-  @endcode
-  */
-  Matrix(double darray[Rows][Cols]);
-  
-  /// Copy constructor.
-  Matrix(const Matrix<Rows, Cols>& from);
-  
-  //@}
-  
-  
-  /// @name Reading and writing elements
-  //@{
-  
-  /// Assignment operator.
-  /// For dynamically sized matrices this will not cause a resize if the sizes
-are  mismatched.
-  Matrix<Rows, Cols>& operator=(const Matrix<Rows, Cols>& from);
-  
-  /// Resize a dynamically sized matrix.
-  resize(int rows, int cols);
-  
-  /**
-  Access an element from the matrix.
-  The index starts at zero, i.e. the top-left element is m(0, 0).
-  @code
-  double d[2][3] = {{1, 2, 3}, {4, 5, 6}};
-  Matrix<2,3> m(d);
-  double e = m(1,2);     // now e = 6.0;
-  @endcode
-  */
-  const double& operator() (int r, int c) const;
-
-  /**
-  Access an element from the matrix.
-  @param row_col <code>row_col.first</code> holds the row, 
<code>row_col.second</code> holds the column.
-  */
-  const double& operator[](const std::pair<int,int>& row_col) const;
-  ///@overload
-  double& operator[](const std::pair<int,int>& row_col);
-  
-  /**
-  Access an element from the matrix.
-  This can be used as either an r-value or an l-value. The index starts at 
zero,
-  i.e. the top-left element is m(0, 0).
-  @code
-  double d[2][3] = {{1, 2, 3}, {4, 5, 6}};
-  Matrix<2,3> m(d);
-  m(1,2) = 8;     // now d = [1 2 3]
-                  //         [4 5 8]
-  @endcode
-  */
-  double& operator() (int r, int c);
-  
-  /**
-  Access a row from the matrix.
-  This can be used either as an r-value or an l-value. The index starts at 
zero,
-  i.e. the first row is m[0]. To extract a column from a matrix, apply [] to 
the
-  transpose of the matrix (see example). This can be used either as an r-value
-  or an l-value. The index starts at zero, i.e. the first row (or column) is
-  m[0].
-  @code
-  double d[2][3] = {{1, 2, 3}, {4, 5, 6}};
-  Matrix<2,3> m(d);
-  Vector<3> v = m[1];       // now v = [4 5 6];
-  Vector<2> v2 = m.T()[0];  // now v2 = [1 4];
-  @endcode
-  */
-  const Vector& operator[] (int r) const;
-  
-  /**
-  Access a row from the matrix.
-  This can be used either as an r-value or an l-value. The index starts at 
zero,
-  i.e. the first row is m[0]. To extract a column from a matrix, apply [] to 
the
-  transpose of the matrix (see example). This can be used either as an r-value
-  or an l-value. The index starts at zero, i.e. the first row (or column) is
-  m[0].
-  @code
-  double d[2][3] = {{1, 2, 3}, {4, 5, 6}};
-  Matrix<2,3> m(d);
-  Zero(m[0]);   // set the first row to zero
-  Vector<2> v = 8,9;
-  m.T()[1] = v; // now m = [0 8 0]
-                //         [4 9 6]
-  @endcode
-  */
-  Vector& operator[] (int r);
-  
-  /// How many rows does this matrix have?
-  int num_rows() const;
-  
-  /// How many columns does this matrix have?
-  int num_cols() const;
-  
-  /// What is the memory layout of this matrix?
-  {RowMajor, ColMajor} layout const;
-  //@}
-  
-  /// @name Transpose and sub-matrices
-  //@{
-  /**
-  The transpose of the matrix. This is a very fast operation--it simply
-  reinterprets a row-major matrix as column-major or vice-versa. This can be
-  used as an l-value.
-  @code
-  double d[2][3] = {{1, 2, 3}, {4, 5, 6}};
-  Matrix<2,3> m(d);
-  Zero(m[0]);   // set the first row to zero
-  Vector<2> v = 8,9;
-  m.T()[1] = v; // now m = [0 8 0]
-                //         [4 9 6]
-  @endcode
-  */
-  const Matrix<Cols, Rows>& T() const;
-  
-  /**
-  The transpose of the matrix. This is a very fast operation--it simply
-  reinterprets a row-major  matrix as column-major or vice-versa. The result 
can
-  be used as an l-value.
-  @code
-  double d[2][3] = {{1, 2, 3}, {4, 5, 6}};
-  Matrix<2,3> m(d);
-  Vector<2> v = 8,9;
-  // Set the first column to v
-  m.T()[0] = v; // now m = [8 2 3]
-                //         [9 5 6]
-  @endcode
-  <b>This means that the semantics of <code>M=M.T()</code> are broken</b>. In
-  general, it is not  necessary to say <code>M=M.T()</code>, since you can use
-  M.T() for free whenever you need the transpose, but if you do need to, you
-  have to use the Tranpose() function defined in <code>helpers.h</code>.
-  */
-  Matrix<Cols, Rows>& T();
-  
-  /**
-  Extract a sub-matrix. The matrix extracted will be begin at element
-  (Rstart, Cstart) and will contain the next Rsize by Csize elements.
-  @code
-  double d[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
-  Matrix<3> m(d);
-  Extract the top-left 2x2 matrix
-  Matrix<2> b = m.slice<0,0,2,2>();  // b = [1 2]
-                                      //     [4 5]
-  @endcode
-  */
-  template<Rstart, Cstart, Rsize, Csize>
-  const Matrix<Rsize, Csize>& slice() const;
-  
-  /**
-  Extract a sub-matrix. The matrix extracted will be begin at element (Rstart,
-  Cstart) and will contain the next Rsize by Csize elements. This can be used 
as
-  either an r-value or an l-value.
-  @code
-  double d[2][3] = {{1, 2, 3}, {4, 5, 6}};
-  Matrix<2,3> m(d);
-  Zero(m.slice<0,2,2,1>());  // b = [1 2 0]
-                              //     [4 5 0]
-  @endcode
-  */
-  template<Rstart, Cstart, Rsize, Csize>
-  Matrix<Rsize, Csize>& slice();
-  
-  /**
-  Extract a sub-matrix with runtime location and size. The matrix extracted 
will
-  begin at element (rstart, cstart) and will
-  contain the next rsize by csize elements.
-  @code
-  Matrix<> m(3,3);
-  Extract the top-left 2x2 matrix
-  Matrix<2> b = m.slice(0,0,2,2);
-  @endcode
-  */
-  const Matrix<>& slice(int rstart, int cstart, int rsize, int csize) const;
-  
-  /**
-  Extract a sub-matrix with runtime location and size, which can be used as
-  an l-value. The matrix extracted will be begin at element (rstart, cstart) 
and
-  will contain the next rsize by csize elements.
-  @code
-  Matrix<> m(3,3);
-  Zero(m.slice(0,0,2,2));
-  @endcode
-  */
-  Matrix<>& slice(int rstart, int cstart, int rsize, int csize);
-  
-  //@}
-};
-
-/// @name Input/output
-//@{
-
-/**
-Write the matrix to a stream. The elements are space-separated with rows
-being separated by new lines. The numbers are printed with a minimum field 
width
-of 12 characters.
address@hidden Matrix
-*/
-template <int Rows, Cols>
-std::ostream& operator<< (std::ostream& os, const Matrix<Rows, Cols>& v);
-
-/**
-Read a matrix from a stream. The numbers can be comma or white-space
-separated, and are assumed to be in row-major layout (i.e. scanline order)
-unless the matrix is defined as <code>ColMajor</code>
address@hidden Matrix
-*/
-template <int Rows, Cols>
-std::istream& operator<< (std::istream& is, Matrix<Rows, Cols>& v);
-//@}
-
-
-}
-
-#endif




reply via email to

[Prev in Thread] Current Thread [Next in Thread]