SparseMatrix.h
Go to the documentation of this file.
00001 
00028 #pragma once
00029 
00030 #include <iostream>
00031 #include <Eigen/Dense>
00032 
00033 #include "SparseVector.h"
00034 
00035 namespace isam {
00036 
00037 typedef SparseVector* SparseVector_p;
00038 
00039 class SparseMatrix {
00040   int _num_rows; // current number of rows
00041   int _num_cols; // current number of columns
00042   int _max_num_rows; // allocated number of row indices
00043   int _max_num_cols; // allocated number of columns
00044   SparseVector_p* _rows;  // pointers to the actual rows
00045 
00053   void _allocate_SparseMatrix(int num_rows, int num_cols, int max_num_rows, int max_num_cols, bool init_rows = true);
00054 
00059   void _copy_from_SparseMatrix(const SparseMatrix& mat);
00060 
00064   void _dealloc_SparseMatrix();
00065 
00066 public:
00067 
00073   SparseMatrix(int num_rows, int num_cols);
00074 
00079   SparseMatrix(const SparseMatrix& mat);
00080 
00089   SparseMatrix(const SparseMatrix& mat, int num_rows, int num_cols, int first_row = 0, int first_col = 0);
00090 
00091   SparseMatrix(int num_rows, int num_cols, SparseVector_p* rows);
00092 
00096   virtual ~SparseMatrix();
00097 
00103   const SparseMatrix& operator= (const SparseMatrix& mat);
00104 
00111   virtual double operator()(int row, int col) const;
00112 
00120   virtual void set(int row, int col, const double val, bool grow_matrix = false);
00121 
00128   virtual void append_in_row(int row, int col,const double val);
00129 
00134   virtual int nnz() const;
00135 
00140   virtual int max_nz() const;
00141 
00147   virtual void print(std::ostream& out = std::cout) const;
00148 
00153   virtual void print(const std::string& file_name) const;
00154 
00158   virtual void print_stats() const;
00159 
00163   virtual void print_pattern() const;
00164 
00168   virtual void save_pattern_eps(const std::string& file_name) const;
00169 
00175   virtual const SparseVector& get_row(int row) const;
00176 
00182   virtual void set_row(int row, const SparseVector& new_row);
00183 
00190   virtual void import_rows(int num_rows, int num_cols, SparseVector_p* rows);
00191 
00196   virtual void append_new_rows(int num);
00197 
00202   virtual void append_new_cols(int num);
00203 
00208   virtual void ensure_num_rows(int num_rows);
00209 
00214   virtual void ensure_num_cols(int num_cols);
00215 
00219   virtual void remove_row();
00220 
00229   virtual void apply_givens(int row, int col, double* c_givens = NULL, double* s_givens = NULL);
00230 
00235   virtual int triangulate_with_givens();
00236 
00237   inline int num_rows() const {return _num_rows;}
00238   inline int num_cols() const {return _num_cols;}
00239 
00240   friend class OrderedSparseMatrix;
00241 };
00242 
00243 const Eigen::VectorXd operator*(const SparseMatrix& lhs, const Eigen::VectorXd& rhs);
00244 Eigen::VectorXd mul_SparseMatrixTrans_Vector(const SparseMatrix& lhs, const Eigen::VectorXd& rhs);
00245 SparseMatrix sparseMatrix_of_matrix(const Eigen::MatrixXd& m);
00246 Eigen::MatrixXd matrix_of_sparseMatrix(const SparseMatrix& s);
00247 
00248 }


demo_rgbd
Author(s): Ji Zhang
autogenerated on Mon Jan 6 2014 11:16:08