34 #ifndef AIMS_SPARSEMATRIX_SPARSEMATRIX_H 
   35 #define AIMS_SPARSEMATRIX_SPARSEMATRIX_H 
   38 #include <boost/numeric/ublas/matrix_sparse.hpp> 
   39 #include <boost/numeric/ublas/vector_sparse.hpp> 
   40 #include <boost/numeric/ublas/io.hpp> 
   41 #include <boost/version.hpp> 
   48 #if BOOST_VERSION >= 103300 
   62       typedef boost_sparse_matrix::reference
 
   64       typedef boost_sparse_matrix::const_reference
 
   70       typedef boost_sparse_matrix::const_iterator1
 
   72       typedef boost_sparse_matrix::const_iterator2
 
  108       void setRow( int32_t s1, 
const std::vector<double>& row );
 
  109       void setColumn( int32_t s2, 
const std::vector<double>& column );
 
  110       void fill( 
const double& value );
 
  115                  const double& value );
 
  130       std::vector<double> 
getRow( int32_t i ) 
const;
 
  133       template <
typename VectorType>
 
  135       template <
typename VectorType>
 
  143       void read( 
const std::string& filename,
 
  144                  const std::string & openmode = 
"binar", 
 
  145                  bool bswap = 
false );
 
  149       void write( 
const std::string& filename,
 
  150                   const std::string & openmode = 
"binar", 
 
  151                   bool bswap = 
false ) 
const;
 
  177   template <
typename VectorType>
 
  185       VectorType row( getSize2() );
 
  186       boost_sparse_matrix::const_iterator1
 
  187         ir = _matrix.find1( 0, i, 0 );
 
  188       if( (ir != _matrix.end1()) && ((
int)ir.index1() == i ))
 
  190         boost_sparse_matrix::const_iterator2
 
  193         for( ic=ir.begin(); ic!=ec; ++ic, ++n )
 
  194           row[ic.index2()] = *ic;
 
  199     catch( std::exception & e )
 
  201       throw std::runtime_error( std::string(
 
  202           "aims::SparseMatrix::getSparseRow( " 
  203           "int32_t i ) const" ) + e.what() );
 
  209   template <
typename VectorType>
 
  217       VectorType column( getSize1() );
 
  218       for ( int32_t s = 0; s < getSize1(); s++ )
 
  221         column[ s ] = ( *this )( s, j );
 
  227     catch( std::exception & e )
 
  229       throw std::runtime_error( std::string(
 
  230           "aims::SparseMatrix::getSparseColumn( " 
  231           "int32_t j ) const" ) + e.what() );
 
  280                  const std::vector<double>& thing2 );
 
  285                  const double& thing2 );
 
  295                  const double& thing2 );
 
  309 #ifndef DOXYGEN_HIDE_INTERNAL_CLASSES 
  318     { 
return "SparseMatrix"; }
 
  323       return std::string(
"SparseMatrix_") + 
dataType();
 
aims::SparseMatrix & operator+=(const aims::SparseMatrix &thing)
const_iterator2 end2() const
const_iterator1 begin1() const
void read(const std::string &filename, const std::string &openmode="binar", bool bswap=false)
Avoid using this function, prefer the more standard Reader<SparseMatrix> instead.
void setHeader(carto::Object ph)
void reallocate(int32_t size1, int32_t size2)
SparseMatrix(int32_t size1=1, int32_t size2=1)
void fill(const double &value)
const_reference operator()(int32_t i, int32_t j) const
const carto::Object header() const
std::vector< double > getComposition(const std::vector< double > &other) const
boost_sparse_matrix & boostMatrix()
for low-level boost operations
SparseMatrix getTransposition() const
VectorType getSparseRow(int32_t i) const
boost_sparse_matrix::iterator2 iterator2
boost_sparse_matrix::const_reference const_reference
reference operator()(int32_t i, int32_t j)
const_iterator1 end1() const
const boost_sparse_matrix & boostMatrix() const
void fill(int32_t offset1, int32_t offset2, const SparseMatrix &other, int32_t size1=0, int32_t size2=0)
void fill(int32_t offset1, int32_t offset2, int32_t size1, int32_t size2, const double &value)
boost_sparse_matrix::iterator1 iterator1
boost_sparse_matrix _matrix
std::vector< double > getRow(int32_t i) const
void setColumn(int32_t s2, const std::vector< double > &column)
void setRow(int32_t s1, const std::vector< double > &row)
boost_sparse_matrix::reference reference
aims::SparseMatrix & operator-=(const aims::SparseMatrix &thing)
boost_sparse_matrix::const_iterator1 const_iterator1
SparseMatrix & operator=(const SparseMatrix &other)
void setDiagonal(const double &value)
boost_sparse_matrix::const_iterator2 const_iterator2
bool hasElement(int32_t i, int32_t j) const
aims::SparseMatrix & operator/=(double x)
aims::SparseMatrix & operator*=(double x)
const_iterator2 begin2() const
VectorType getSparseColumn(int32_t i) const
std::vector< double > toVector() const
void erase_element(int32_t i, int32_t j)
SparseMatrix(const SparseMatrix &other)
std::vector< double > getColumn(int32_t j) const
void write(const std::string &filename, const std::string &openmode="binar", bool bswap=false) const
Avoid using this function, prefer the more standard Writer<SparseMatrix> instead.
SparseMatrix getComposition(const SparseMatrix &other) const
int32_t getNonZeroElementCount() const
static std::string name()
static std::string dataType()
static std::string objectType()
The class for EcatSino data write operation.
aims::SparseMatrix operator+(const aims::SparseMatrix &thing)
boost::numeric::ublas::sparse_matrix< double > boost_sparse_matrix
aims::SparseMatrix operator/(const aims::SparseMatrix &thing1, const double &thing2)
boost::numeric::ublas::sparse_vector< double > boost_sparse_vector
Quaternion operator*(const Quaternion &a, const Quaternion &b)
aims::SparseMatrix operator-(const aims::SparseMatrix &thing)
#define DECLARE_GENERIC_OBJECT_TYPE(T)