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
81 void reallocate( int32_t size1, int32_t size2 );
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 );
111 void fill( int32_t offset1,
115 const double& value );
116 void fill( int32_t offset1,
127 std::vector<double>
getComposition(
const std::vector<double>& other )
const;
128 std::vector<double>
toVector()
const;
130 std::vector<double>
getRow( int32_t i )
const;
131 std::vector<double>
getColumn( int32_t j )
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>
186 boost_sparse_matrix::const_iterator1
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>
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();
329 #endif // DOXYGEN_HIDE_INTERNAL_CLASSES #define DECLARE_GENERIC_OBJECT_TYPE(T)
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. ...
aims::SparseMatrix & operator*=(double x)
const_reference operator()(int32_t i, int32_t j) const
static std::string objectType()
aims::SparseMatrix & operator+=(const aims::SparseMatrix &thing)
boost_sparse_matrix _matrix
SparseMatrix & operator=(const SparseMatrix &other)
void erase_element(int32_t i, int32_t j)
aims::SparseMatrix & operator/=(double x)
bool hasElement(int32_t i, int32_t j) const
The class for EcatSino data write operation.
boost_sparse_matrix::const_iterator1 const_iterator1
void setDiagonal(const double &value)
boost_sparse_matrix::reference reference
SparseMatrix getTransposition() const
const carto::Object header() const
boost_sparse_matrix::const_reference const_reference
int32_t getNonZeroElementCount() const
void reallocate(int32_t size1, int32_t size2)
aims::SparseMatrix & operator-=(const aims::SparseMatrix &thing)
const boost_sparse_matrix & boostMatrix() const
static std::string dataType()
VectorType getSparseColumn(int32_t i) 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. ...
boost_sparse_matrix::const_iterator2 const_iterator2
void setRow(int32_t s1, const std::vector< double > &row)
void setHeader(carto::Object ph)
boost::numeric::ublas::sparse_matrix< double > boost_sparse_matrix
boost_sparse_matrix::iterator1 iterator1
boost::numeric::ublas::sparse_vector< double > boost_sparse_vector
SparseMatrix getComposition(const SparseMatrix &other) const
void setColumn(int32_t s2, const std::vector< double > &column)
boost_sparse_matrix & boostMatrix()
for low-level boost operations
aims::SparseMatrix operator/(const aims::SparseMatrix &thing1, const double &thing2)
static std::string name()
aims::SparseMatrix operator+(const aims::SparseMatrix &thing)
aims::SparseMatrix operator-(const aims::SparseMatrix &thing)
MotionWriter & operator<<(MotionWriter &writer, const AffineTransformation3d &thing) __attribute__((__deprecated__("OBSOLETE")))
— OBSOLETE —
std::vector< double > getRow(int32_t i) const
std::vector< double > toVector() const
boost_sparse_matrix::iterator2 iterator2
void fill(const double &value)
SparseMatrix(int32_t size1=1, int32_t size2=1)
std::vector< double > getColumn(int32_t j) const
Quaternion operator*(const Quaternion &a, const Quaternion &b)
VectorType getSparseRow(int32_t i) const