old_matrix.h
Go to the documentation of this file.
00001 /****************************************************************************
00002 * VCGLib                                                            o o     *
00003 * Visual and Computer Graphics Library                            o     o   *
00004 *                                                                _   O  _   *
00005 * Copyright(C) 2004                                                \/)\/    *
00006 * Visual Computing Lab                                            /\/|      *
00007 * ISTI - Italian National Research Council                           |      *
00008 *                                                                    \      *
00009 * All rights reserved.                                                      *
00010 *                                                                           *
00011 * This program is free software; you can redistribute it and/or modify      *
00012 * it under the terms of the GNU General Public License as published by      *
00013 * the Free Software Foundation; either version 2 of the License, or         *
00014 * (at your option) any later version.                                       *
00015 *                                                                           *
00016 * This program is distributed in the hope that it will be useful,           *
00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of            *
00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             *
00019 * GNU General Public License (http://www.gnu.org/licenses/gpl.txt)          *
00020 * for more details.                                                         *
00021 *                                                                           *
00022 ****************************************************************************/
00023 
00024 #ifndef VCG_USE_EIGEN
00025 #include "deprecated_matrix.h"
00026 
00027 #else
00028 
00029 #ifndef MATRIX_VCGLIB
00030 #define MATRIX_VCGLIB
00031 
00032 #include "eigen.h"
00033 #include <vcg/space/point.h>
00034 
00035 namespace vcg{
00036 namespace ndim{
00037 template<class Scalar> class Matrix;
00038 }
00039 }
00040 
00041 namespace Eigen{
00042 template<typename Scalar>
00043 struct ei_traits<vcg::ndim::Matrix<Scalar> > : ei_traits<Eigen::Matrix<Scalar,Dynamic,Dynamic> > {};
00044 template<typename XprType> struct ei_to_vcgtype<XprType,Dynamic,Dynamic,RowMajor,Dynamic,Dynamic>
00045 { typedef vcg::ndim::Matrix<typename XprType::Scalar> type; };
00046 }
00047 
00048 namespace vcg{
00049 namespace ndim{
00050 
00052 /* @{ */
00053 
00059 template<class _Scalar>
00060 class Matrix : public Eigen::Matrix<_Scalar,Eigen::Dynamic,Eigen::Dynamic,Eigen::RowMajor> // FIXME col or row major ?
00061 {
00062         typedef Eigen::Matrix<_Scalar,Eigen::Dynamic,Eigen::Dynamic,Eigen::RowMajor> _Base;
00063 
00064 public:
00065 
00066         _EIGEN_GENERIC_PUBLIC_INTERFACE(Matrix,_Base);
00067         typedef _Scalar ScalarType;
00068         VCG_EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Matrix)
00069 
00070         
00076         Matrix(int m, int n)
00077                 : Base(m,n)
00078         {
00079                 memset(Base::data(), 0, m*n*sizeof(Scalar));
00080         }
00081 
00089         Matrix(int m, int n, Scalar *values)
00090                 : Base(m,n)
00091         {
00092                 *this = Eigen::Map<Eigen::Matrix<Scalar,Eigen::Dynamic,Eigen::Dynamic,Eigen::RowMajor> >(values, m , n);
00093         }
00094 
00099         Matrix() : Base() {}
00100 
00106         Matrix(const Matrix<Scalar> &m) : Base(m) {}
00107 
00108         template<typename OtherDerived>
00109         Matrix(const Eigen::MatrixBase<OtherDerived> &m) : Base(m) {}
00110 
00114         ~Matrix() {}
00115 
00122         inline typename Base::RowXpr operator[](const unsigned int i)
00123         { return Base::row(i); }
00124 
00131         inline const typename Base::RowXpr operator[](const unsigned int i) const
00132         { return Base::row(i); }
00133 
00134 
00140         // FIXME what the hell is that !
00141         /*template <int N,int M>
00142         void DotProduct(Point<N,Scalar> &m,Point<M,Scalar> &result)
00143         {
00144                 unsigned int i, j,  p,  r;
00145                 for (i=0, p=0, r=0; i<M; i++)
00146                 { result[i]=0;
00147                         for (j=0; j<N; j++)
00148                                 result[i]+=(*this)[i][j]*m[j];
00149                 }
00150         };*/
00151 
00158         void Resize(const unsigned int m, const unsigned int n)
00159         {
00160                 assert(m>=2);
00161                 assert(n>=2);
00162                 Base::resize(m,n);
00163                 memset(Base::data(), 0, m*n*sizeof(Scalar));
00164         };
00165 };
00166 
00167 typedef vcg::ndim::Matrix<double> MatrixMNd;
00168 typedef vcg::ndim::Matrix<float>  MatrixMNf;
00169 
00172 template <class MatrixType>
00173 void Invert(MatrixType & m)
00174 {
00175         m = m.inverse();
00176 }
00177 
00178 }
00179 } // end of namespace
00180 
00181 #endif
00182 
00183 #endif
00184 


shape_reconstruction
Author(s): Roberto Martín-Martín
autogenerated on Sat Jun 8 2019 18:33:33