matrix_n.h
Go to the documentation of this file.
00001 // HOG-Man - Hierarchical Optimization for Pose Graphs on Manifolds
00002 // Copyright (C) 2010 G. Grisetti, R. Kümmerle, C. Stachniss
00003 // 
00004 // HOG-Man is free software: you can redistribute it and/or modify
00005 // it under the terms of the GNU Lesser General Public License as published
00006 // by the Free Software Foundation, either version 3 of the License, or
00007 // (at your option) any later version.
00008 // 
00009 // HOG-Man is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU Lesser General Public License for more details.
00013 // 
00014 // You should have received a copy of the GNU Lesser General Public License
00015 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016 
00017 #ifndef _MATRIXN_H_
00018 #define _MATRIXN_H_
00019 #include <assert.h>
00020 #include <iostream>
00021 #include <limits>
00022 #include "vector_n.h"
00023 
00024 using namespace std;
00027 
00038 template <int Rows, int Cols, typename Base=double>
00039   struct _Matrix{
00040     typedef Base BaseType;
00041     
00042     _Matrix(int r=Rows, int c=Cols):_allocator(r,c){}
00043     inline const Base* operator[](int row) const {return _allocator[row];}
00044     inline Base* operator[](int row) {return _allocator[row];}
00045     inline int cols() const {return _allocator.cols();}
00046     inline int rows() const {return _allocator.rows();}
00047     _Matrix<Rows, Cols, Base>& operator += (const _Matrix<Rows, Cols, Base>& v);
00048     _Matrix<Rows, Cols, Base>& operator -= (const _Matrix<Rows, Cols, Base>& v);
00049     _Matrix<Rows, Cols, Base> operator - (const _Matrix<Rows, Cols, Base>& v) const;
00050     _Matrix<Rows, Cols, Base> operator + (const _Matrix<Rows, Cols, Base>& v) const;
00051     _Matrix<Cols, Rows, Base> transpose() const;
00052     _Matrix<Cols, Rows, Base>& transposeInPlace();
00053     _Matrix<Rows, Cols, Base>& operator*=(const _Matrix<Rows, Cols, Base>& m);
00054     _Matrix<Rows, Cols, Base>& operator*=(Base c);
00055     _Matrix<Rows, Cols, Base> operator*(Base c) const;
00056 
00057     template <int Rows1, int Cols1>
00058       _Matrix<Rows, Cols1, Base> operator*(const _Matrix<Rows1, Cols1, Base>& m) const;
00059     _Vector<Rows, Base> operator* (const _Vector<Cols, Base>& v) const;
00060     int nullSpace(_Matrix<Rows, Cols, Base>& nullS, Base epsilon=std::numeric_limits<Base>::epsilon() ) const;
00061     static _Matrix<Rows, Rows, Base> eye(Base factor, int dim=Rows);
00062     static _Matrix<Rows, Rows, Base> diag(const _Vector<Rows, Base>& v);
00063     static _Matrix<Rows, Rows, Base> outerProduct(const _Vector<Rows, Base>& v1, const _Vector<Rows, Base>& v2);
00064     static _Matrix<Rows, Rows, Base> permutation(const _Vector<Rows, int>& p);
00065     _Matrix<Rows, Rows, Base> inverse() const;
00066     _Matrix<Rows, Rows, Base> cholesky() const;
00067 
00068     Base det() const;
00069 
00070     void swapRows(int r1, int r2);
00071     void sumRow(int dest, Base destFactor, int src, Base srcFactor);
00072     void multRow(int dest, Base destFactor);
00073     void fill(Base scalar);
00074     
00075     _Array2DAllocator<Rows, Cols, Base> _allocator;
00076 
00077   };
00078 
00079 template <int R, int C, typename Base>
00080   std::ostream& operator << (std::ostream& os, const _Matrix<R, C, Base>& m);
00081 
00083 template <int R, int C, typename Base>
00084 _Matrix<R, C, Base> operator* (Base x, const _Matrix<R, C, Base>& m);
00085 
00086 template <int M, int N, typename Base>
00087   void st2dyn(_Matrix<0,0,Base>& dest, const _Matrix<M,N,Base> src){
00088   st2dyn(dest._allocator, src._allocator);
00089 }
00090 
00091 
00092 template <int M, int N, typename Base>
00093   void dyn2st(_Matrix<M,N,Base>& dest, const _Matrix<0,0,Base> src){
00094   dyn2st(dest._allocator, src._allocator);
00095 }
00096 
00097 typedef _Matrix<3, 3, float>  Matrix3f;
00098 typedef _Matrix<2, 2, float>  Matrix2f;
00099 typedef _Matrix<6, 6, float>  Matrix6f;
00100 typedef _Matrix<3, 3, double> Matrix3;
00101 typedef _Matrix<2, 2, double> Matrix2;
00102 typedef _Matrix<6, 6, double> Matrix6;
00103 
00104 typedef _Matrix<0, 0, double> MatrixX;
00105 typedef _Matrix<0, 0, float> MatrixXf;
00106 
00108 
00109 #include "matrix_n.hpp"
00110 
00111 
00112 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines


hogman_minimal
Author(s): Maintained by Juergen Sturm
autogenerated on Wed Dec 26 2012 15:36:48