123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- /**
- * @file GenericMatrix.h
- * @brief matrix interface for indirect matrix multiplications
- * @author Erik Rodner
- * @date 05/14/2009
- */
- #ifndef GENERICMATRIXINCLUDE
- #define GENERICMATRIXINCLUDE
- #include "core/basics/triplet.h"
- #include "AlgebraTools.h"
- #include "core/vector/SparseVector.h"
-
- namespace OBJREC {
- /** matrix interface for indirect matrix multiplications */
- class GenericMatrix
- {
- protected:
- public:
- /** multiply with a vector: A*x = y */
- virtual void multiply ( NICE::Vector & y, const NICE::Vector & x ) const = 0;
- /** get the number of rows in A */
- virtual uint rows() const = 0;
- /** get the number of columns in A */
- virtual uint cols() const = 0;
- /** simple destructor */
- virtual ~GenericMatrix() {};
-
- };
- class GMSlowICE : public GenericMatrix
- {
- protected:
- NICE::Matrix A;
- public:
- GMSlowICE ( const NICE::Matrix & _A ) : A(_A) {};
-
- /** get the number of rows in A */
- uint rows() const { return A.rows(); };
- /** get the number of columns in A */
- uint cols() const { return A.cols(); };
- /** multiply with a vector: A*x = y */
- void multiply ( NICE::Vector & y, const NICE::Vector & x ) const
- { y.multiply ( A, x ); };
- };
- class GMSparse : public GenericMatrix
- {
- protected:
- std::vector< NICE::triplet<int, int, double> > A;
- uint m_rows;
- uint m_cols;
- public:
- GMSparse ( uint _rows, uint _cols ) : m_rows(_rows), m_cols(_cols) {}
- GMSparse ( const NICE::Matrix & A, double epsilon = 1e-9 );
- /** get the number of rows in A */
- uint rows() const { return m_rows; };
- /** get the number of columns in A */
- uint cols() const { return m_cols; };
- /** multiply with a vector: A*x = y */
- void multiply ( NICE::Vector & y, const NICE::Vector & x ) const;
- };
- class GMCovariance : public GenericMatrix
- {
- protected:
- const NICE::Matrix *data;
- uint m_rows;
- uint m_cols;
- public:
- GMCovariance ( const NICE::Matrix *data );
- /** get the number of rows in A */
- uint rows() const { return m_rows; };
- /** get the number of columns in A */
- uint cols() const { return m_cols; };
- /** multiply with a vector: A*x = y */
- void multiply ( NICE::Vector & y, const NICE::Vector & x ) const;
- };
- } // namespace
- #endif
|