DMRITool  v0.1.1-139-g860d86b4
Diffusion MRI Tool
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
spams::SpMatrix< T > Class Template Reference

#include <linalg.h>

+ Inheritance diagram for spams::SpMatrix< T >:
+ Collaboration diagram for spams::SpMatrix< T >:

Detailed Description

template<typename T>
class spams::SpMatrix< T >

Sparse Matrix class.

Sparse Matrix class, CSC format.

Definition at line 63 of file linalg.h.

Public Member Functions

void AAt (Matrix< T > &aat) const
 
void AAt (Matrix< T > &aat, const Vector< int > &indices) const
 
void add_direct (const SpMatrix< T > &mat, const T a)
 
void addVecToCols (const Vector< T > &diag, const T a=1.0)
 
void addVecToColsWeighted (const Vector< T > &diag, const T *weights, const T a=1.0)
 
asum () const
 
void clear ()
 
void convert (const Matrix< T > &v, const Matrix< int > &r, const int K)
 
void convert2 (const Matrix< T > &v, const Vector< int > &r, const int K)
 
void copy (const SpMatrix< T > &mat)
 
void copy_direct (const SpMatrix< T > &mat)
 
void copyRow (const int i, Vector< T > &x) const
 
void copyTo (Matrix< T > &mat) const
 
dot (const Matrix< T > &x) const
 
dot_direct (const SpMatrix< T > &mat) const
 
void getData (Vector< T > &data, const int index) const
 
void getGroup (Matrix< T > &data, const vector_groups &groups, const int i) const
 
int m () const
 
void mult (const SpVector< T > &x, Vector< T > &b, const T alpha=1.0, const T beta=0.0) const
 
void mult (const Vector< T > &x, Vector< T > &b, const T alpha=1.0, const T beta=0.0) const
 
void mult (const Matrix< T > &B, Matrix< T > &C, const bool transA=false, const bool transB=false, const T a=1.0, const T b=0.0) const
 
void mult (const SpMatrix< T > &B, Matrix< T > &C, const bool transA=false, const bool transB=false, const T a=1.0, const T b=0.0) const
 
void multSwitch (const Matrix< T > &B, Matrix< T > &C, const bool transA=false, const bool transB=false, const T a=1.0, const T b=0.0) const
 
void multTrans (const Vector< T > &x, Vector< T > &y, const T alpha=1.0, const T beta=0.0) const
 
void multTrans (const SpVector< T > &x, Vector< T > &y, const T alpha=1.0, const T beta=0.0) const
 
int n () const
 
int nnz () const
 
void norm_0_cols (Vector< T > &norms) const
 
void norm_1_cols (Vector< T > &norms) const
 
void norm_2sq_cols (Vector< T > &norms) const
 
normFsq () const
 
int nzmax () const
 
operator[] (const int index) const
 
int pB (const int i) const
 
int * pB () const
 
int * pE () const
 
void print (const string &name) const
 
int r (const int i) const
 
int * r () const
 
void refCol (int i, SpVector< T > &vec) const
 
void resize (const int m, const int n, const int nzmax)
 
void scal (const T a) const
 
 SpMatrix (T *v, int *r, int *pB, int *pE, int m, int n, int nzmax)
 
 SpMatrix (int m, int n, int nzmax)
 
 SpMatrix ()
 
void sum_cols (Vector< T > &sum) const
 
void toFull (Matrix< T > &matrix) const
 
void toFullTrans (Matrix< T > &matrix) const
 
v (const int i) const
 
int V () const
 
T * v () const
 
void wAAt (const Vector< T > &w, Matrix< T > &aat) const
 
void wXAt (const Vector< T > &w, const Matrix< T > &X, Matrix< T > &XAt, const int numthreads=-1) const
 
void XAt (const Matrix< T > &X, Matrix< T > &XAt) const
 
void XAt (const Matrix< T > &X, Matrix< T > &XAt, const Vector< int > &indices) const
 
void XtX (Matrix< T > &XtX) const
 
 ~SpMatrix ()
 
- Public Member Functions inherited from spams::Data< T >
virtual ~Data ()
 
- Public Member Functions inherited from spams::AbstractMatrixB< T >
virtual ~AbstractMatrixB ()
 

Private Member Functions

SpMatrix< T > & operator= (const SpMatrix< T > &matrix)
 
 SpMatrix (const SpMatrix< T > &matrix)
 

Private Attributes

bool _externAlloc
 
int _m
 
int _n
 
int _nzmax
 
int * _pB
 
int * _pE
 
int * _r
 
T * _v
 

Friends

class Matrix< T >
 
class SpVector< T >
 

Constructor & Destructor Documentation

template<typename T >
spams::SpMatrix< T >::SpMatrix ( T *  v,
int *  r,
int *  pB,
int *  pE,
int  m,
int  n,
int  nzmax 
)

Constructor, CSC format, existing data.

Definition at line 4078 of file linalg.h.

template<typename T >
spams::SpMatrix< T >::SpMatrix ( int  m,
int  n,
int  nzmax 
)

Constructor, new m x n matrix, with at most nzmax non-zeros values.

Definition at line 4084 of file linalg.h.

References spams::SpMatrix< T >::_n, spams::SpMatrix< T >::_pB, spams::SpMatrix< T >::_pE, spams::SpMatrix< T >::_r, spams::SpMatrix< T >::_v, and spams::SpMatrix< T >::nzmax().

+ Here is the call graph for this function:

template<typename T >
spams::SpMatrix< T >::SpMatrix ( )

Empty constructor.

Definition at line 4096 of file linalg.h.

template<typename T >
spams::SpMatrix< T >::~SpMatrix ( )

Destructor.

Definition at line 4111 of file linalg.h.

References spams::SpMatrix< T >::clear().

+ Here is the call graph for this function:

template<typename T>
spams::SpMatrix< T >::SpMatrix ( const SpMatrix< T > &  matrix)
explicitprivate

forbid copy constructor

Member Function Documentation

template<typename T >
void spams::SpMatrix< T >::AAt ( Matrix< T > &  aat) const
inline
template<typename T >
void spams::SpMatrix< T >::AAt ( Matrix< T > &  aat,
const Vector< int > &  indices 
) const
inline
template<typename T >
void spams::SpMatrix< T >::add_direct ( const SpMatrix< T > &  mat,
const T  a 
)
inline

Definition at line 4183 of file linalg.h.

References spams::SpMatrix< T >::_nzmax, spams::SpMatrix< T >::_v, and spams::Vector< T >::add().

Referenced by spams::FISTA::ADMM(), and spams::FISTA::LinADMM().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename T >
void spams::SpMatrix< T >::addVecToCols ( const Vector< T > &  diag,
const T  a = 1.0 
)
inline

Definition at line 4494 of file linalg.h.

References spams::SpMatrix< T >::_n, spams::SpMatrix< T >::_pB, spams::SpMatrix< T >::_pE, spams::SpMatrix< T >::_r, spams::SpMatrix< T >::_v, spams::isEqual(), and spams::Vector< T >::rawX().

Referenced by spams::FISTA::ADMM(), spams::FISTA::LagrangianADMM(), and spams::FISTA::LinADMM().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename T >
void spams::SpMatrix< T >::addVecToColsWeighted ( const Vector< T > &  diag,
const T *  weights,
const T  a = 1.0 
)
inline

Definition at line 4509 of file linalg.h.

References spams::SpMatrix< T >::_n, spams::SpMatrix< T >::_pB, spams::SpMatrix< T >::_pE, spams::SpMatrix< T >::_r, spams::SpMatrix< T >::_v, spams::isEqual(), and spams::Vector< T >::rawX().

Referenced by spams::FISTA::ADMM().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename T >
T spams::SpMatrix< T >::asum ( ) const
inline

compute the sum of the matrix elements

Definition at line 4173 of file linalg.h.

References spams::SpMatrix< T >::_n, spams::SpMatrix< T >::_pB, and spams::SpMatrix< T >::_v.

template<typename T >
void spams::SpMatrix< T >::clear ( )
inline
template<typename T >
void spams::SpMatrix< T >::convert ( const Matrix< T > &  v,
const Matrix< int > &  r,
const int  K 
)
inline
template<typename T >
void spams::SpMatrix< T >::convert2 ( const Matrix< T > &  v,
const Vector< int > &  r,
const int  K 
)
inline
template<typename T >
void spams::SpMatrix< T >::copy ( const SpMatrix< T > &  mat)
inline
template<typename T >
void spams::SpMatrix< T >::copy_direct ( const SpMatrix< T > &  mat)
inline

Definition at line 4190 of file linalg.h.

References spams::SpMatrix< T >::_n, spams::SpMatrix< T >::_pB, spams::SpMatrix< T >::_v, and spams::Vector< T >::copy().

+ Here is the call graph for this function:

template<typename T >
void spams::SpMatrix< T >::copyRow ( const int  i,
Vector< T > &  x 
) const
inlinevirtual
template<typename T>
void spams::SpMatrix< T >::copyTo ( Matrix< T > &  mat) const
inlinevirtual

make a copy of the matrix mat in the current matrix

Implements spams::AbstractMatrixB< T >.

Definition at line 866 of file linalg.h.

References spams::Data< T >::norm_2sq_cols().

+ Here is the call graph for this function:

template<typename T >
T spams::SpMatrix< T >::dot ( const Matrix< T > &  x) const
inlinevirtual
template<typename T >
T spams::SpMatrix< T >::dot_direct ( const SpMatrix< T > &  mat) const
inline

Definition at line 4197 of file linalg.h.

References spams::SpMatrix< T >::_n, spams::SpMatrix< T >::_pB, spams::SpMatrix< T >::_v, and spams::Vector< T >::dot().

Referenced by spams::FISTA::LagrangianADMM().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename T >
void spams::SpMatrix< T >::getData ( Vector< T > &  data,
const int  index 
) const
virtual

Implements spams::Data< T >.

Definition at line 4151 of file linalg.h.

References spams::SpMatrix< T >::_m, spams::SpMatrix< T >::_pB, spams::SpMatrix< T >::_r, spams::SpMatrix< T >::_v, spams::Vector< T >::resize(), and spams::Vector< T >::setZeros().

Referenced by spams::SpMatrix< T >::getGroup().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename T >
void spams::SpMatrix< T >::getGroup ( Matrix< T > &  data,
const vector_groups groups,
const int  i 
) const
virtual

Implements spams::Data< T >.

Definition at line 4159 of file linalg.h.

References spams::SpMatrix< T >::_m, spams::SpMatrix< T >::getData(), spams::Matrix< T >::refCol(), and spams::Matrix< T >::resize().

+ Here is the call graph for this function:

template<typename T>
int spams::SpMatrix< T >::m ( ) const
inlinevirtual

returns the number of columns

Implements spams::Data< T >.

Definition at line 789 of file linalg.h.

Referenced by spams::FISTA::GraphLasso< T >::eval_weighted(), spams::Matrix< T >::mult(), spams::SpMatrix< T >::mult(), spams::SpMatrix< T >::resize(), spams::SpMatrixToUtlMatrix(), and spams::SpMatrixToVnlMatrix().

+ Here is the caller graph for this function:

template<typename T >
void spams::SpMatrix< T >::mult ( const SpVector< T > &  x,
Vector< T > &  b,
const T  alpha = 1.0,
const T  beta = 0.0 
) const
inlinevirtual
template<typename T >
void spams::SpMatrix< T >::mult ( const Vector< T > &  x,
Vector< T > &  b,
const T  alpha = 1.0,
const T  beta = 0.0 
) const
inlinevirtual
template<typename T >
void spams::SpMatrix< T >::mult ( const Matrix< T > &  B,
Matrix< T > &  C,
const bool  transA = false,
const bool  transB = false,
const T  a = 1.0,
const T  b = 0.0 
) const
inlinevirtual
template<typename T >
void spams::SpMatrix< T >::mult ( const SpMatrix< T > &  B,
Matrix< T > &  C,
const bool  transA = false,
const bool  transB = false,
const T  a = 1.0,
const T  b = 0.0 
) const
inlinevirtual
template<typename T >
void spams::SpMatrix< T >::multSwitch ( const Matrix< T > &  B,
Matrix< T > &  C,
const bool  transA = false,
const bool  transB = false,
const T  a = 1.0,
const T  b = 0.0 
) const
inlinevirtual

perform C = a*B*A + b*C, possibly transposing A or B.

Implements spams::AbstractMatrixB< T >.

Definition at line 4461 of file linalg.h.

References spams::Matrix< T >::mult().

+ Here is the call graph for this function:

template<typename T >
void spams::SpMatrix< T >::multTrans ( const Vector< T > &  x,
Vector< T > &  y,
const T  alpha = 1.0,
const T  beta = 0.0 
) const
inlinevirtual
template<typename T >
void spams::SpMatrix< T >::multTrans ( const SpVector< T > &  x,
Vector< T > &  y,
const T  alpha = 1.0,
const T  beta = 0.0 
) const
inline

perform b = alpha*A*x + beta*b, when x is sparse

Definition at line 4266 of file linalg.h.

References spams::SpMatrix< T >::_n, spams::SpVector< T >::dot(), spams::Vector< T >::rawX(), spams::SpMatrix< T >::refCol(), spams::Vector< T >::resize(), spams::Vector< T >::scal(), and spams::Vector< T >::setZeros().

+ Here is the call graph for this function:

template<typename T>
int spams::SpMatrix< T >::n ( ) const
inlinevirtual
template<typename T>
int spams::SpMatrix< T >::nnz ( ) const
inline

number of nonzeros elements

Definition at line 812 of file linalg.h.

References spams::Data< T >::m(), and spams::Data< T >::n().

+ Here is the call graph for this function:

template<typename T >
void spams::SpMatrix< T >::norm_0_cols ( Vector< T > &  norms) const
inline

returns the l0 norms of the columns

Definition at line 4842 of file linalg.h.

References spams::SpMatrix< T >::_n, spams::SpVector< T >::length(), spams::SpMatrix< T >::refCol(), and spams::Vector< T >::resize().

+ Here is the call graph for this function:

template<typename T >
void spams::SpMatrix< T >::norm_1_cols ( Vector< T > &  norms) const
inline

returns the l1 norms of the columns

Definition at line 4852 of file linalg.h.

References spams::SpMatrix< T >::_n, spams::SpVector< T >::asum(), spams::SpMatrix< T >::refCol(), and spams::Vector< T >::resize().

+ Here is the call graph for this function:

template<typename T >
void spams::SpMatrix< T >::norm_2sq_cols ( Vector< T > &  norms) const
inlinevirtual

returns the l2 norms ^2 of the columns

Reimplemented from spams::Data< T >.

Definition at line 4832 of file linalg.h.

References spams::SpMatrix< T >::_n, spams::SpVector< T >::nrm2sq(), spams::SpMatrix< T >::refCol(), and spams::Vector< T >::resize().

+ Here is the call graph for this function:

template<typename T >
T spams::SpMatrix< T >::normFsq ( ) const
inline

compute the sum of the matrix elements

Definition at line 4178 of file linalg.h.

References spams::SpMatrix< T >::_n, spams::SpMatrix< T >::_pB, and spams::SpMatrix< T >::_v.

Referenced by spams::FISTA::LagrangianADMM(), and spams::FISTA::SqLossMat< T >::test_backtracking().

+ Here is the caller graph for this function:

template<typename T>
int spams::SpMatrix< T >::nzmax ( ) const
inline

returns the maximum number of non-zero elements

Definition at line 785 of file linalg.h.

Referenced by spams::SpMatrix< T >::resize(), and spams::SpMatrix< T >::SpMatrix().

+ Here is the caller graph for this function:

template<typename T>
SpMatrix<T>& spams::SpMatrix< T >::operator= ( const SpMatrix< T > &  matrix)
private
template<typename T >
T spams::SpMatrix< T >::operator[] ( const int  index) const
inlinevirtual

returns X[index]

Implements spams::Data< T >.

Definition at line 4138 of file linalg.h.

References spams::SpMatrix< T >::_m, spams::SpMatrix< T >::_pB, spams::SpMatrix< T >::_r, and spams::SpMatrix< T >::_v.

template<typename T>
int spams::SpMatrix< T >::pB ( const int  i) const
inline
template<typename T>
int* spams::SpMatrix< T >::pB ( ) const
inline

Direct access to _pB.

Definition at line 804 of file linalg.h.

template<typename T>
int* spams::SpMatrix< T >::pE ( ) const
inline

Direct access to _pE.

Definition at line 806 of file linalg.h.

Referenced by spams::FISTA::convert_paths_to_mat(), spams::SpMatrixToUtlMatrix(), and spams::SpMatrixToVnlMatrix().

+ Here is the caller graph for this function:

template<typename T >
void spams::SpMatrix< T >::print ( const string &  name) const
inlinevirtual

print the sparse matrix

Implements spams::AbstractMatrixB< T >.

Definition at line 4127 of file linalg.h.

References spams::SpMatrix< T >::_m, spams::SpMatrix< T >::_n, spams::SpMatrix< T >::_nzmax, spams::SpMatrix< T >::_pB, spams::SpMatrix< T >::_pE, spams::SpMatrix< T >::_r, and spams::SpMatrix< T >::_v.

Referenced by mexFunction().

+ Here is the caller graph for this function:

template<typename T>
int spams::SpMatrix< T >::r ( const int  i) const
inline
template<typename T>
int* spams::SpMatrix< T >::r ( ) const
inline

Direct access to _r.

Definition at line 808 of file linalg.h.

Referenced by spams::SpMatrix< T >::convert(), and spams::SpMatrix< T >::convert2().

+ Here is the caller graph for this function:

template<typename T >
void spams::SpMatrix< T >::refCol ( int  i,
SpVector< T > &  vec 
) const
inline
template<typename T >
void spams::SpMatrix< T >::resize ( const int  m,
const int  n,
const int  nzmax 
)
inline
template<typename T >
void spams::SpMatrix< T >::scal ( const T  a) const
inline

scale the matrix by a

resize the matrix

Definition at line 4240 of file linalg.h.

References spams::SpMatrix< T >::_n, spams::SpMatrix< T >::_pB, and spams::SpMatrix< T >::_v.

Referenced by spams::FISTA::ADMM(), and spams::FISTA::LinADMM().

+ Here is the caller graph for this function:

template<typename T >
void spams::SpMatrix< T >::sum_cols ( Vector< T > &  sum) const
inline
template<typename T >
void spams::SpMatrix< T >::toFull ( Matrix< T > &  matrix) const
inline

copy the sparse matrix into a dense matrix

Conversions copy the sparse matrix into a dense matrix

Definition at line 4760 of file linalg.h.

References spams::SpMatrix< T >::_m, spams::SpMatrix< T >::_n, spams::SpMatrix< T >::_pB, spams::SpMatrix< T >::_pE, spams::SpMatrix< T >::_r, spams::SpMatrix< T >::_v, spams::Matrix< T >::_X, spams::Matrix< T >::resize(), and spams::Matrix< T >::setZeros().

Referenced by spams::ist().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename T >
void spams::SpMatrix< T >::toFullTrans ( Matrix< T > &  matrix) const
inline

copy the sparse matrix into a dense transposed matrix

copy the sparse matrix into a full dense matrix

Definition at line 4772 of file linalg.h.

References spams::SpMatrix< T >::_m, spams::SpMatrix< T >::_n, spams::SpMatrix< T >::_pB, spams::SpMatrix< T >::_pE, spams::SpMatrix< T >::_r, spams::SpMatrix< T >::_v, spams::Matrix< T >::_X, spams::Matrix< T >::resize(), and spams::Matrix< T >::setZeros().

+ Here is the call graph for this function:

template<typename T>
T spams::SpMatrix< T >::v ( const int  i) const
inline
template<typename T>
int spams::SpMatrix< T >::V ( ) const
inlinevirtual

returns the number of columns

Implements spams::Data< T >.

Definition at line 791 of file linalg.h.

References spams::Data< T >::getData(), spams::Data< T >::getGroup(), and spams::Data< T >::operator[]().

+ Here is the call graph for this function:

template<typename T>
T* spams::SpMatrix< T >::v ( ) const
inline

Direct access to _v.

Definition at line 810 of file linalg.h.

Referenced by spams::SpMatrix< T >::convert(), and spams::SpMatrix< T >::convert2().

+ Here is the caller graph for this function:

template<typename T >
void spams::SpMatrix< T >::wAAt ( const Vector< T > &  w,
Matrix< T > &  aat 
) const
inline
template<typename T >
void spams::SpMatrix< T >::wXAt ( const Vector< T > &  w,
const Matrix< T > &  X,
Matrix< T > &  XAt,
const int  numthreads = -1 
) const
inline
template<typename T >
void spams::SpMatrix< T >::XAt ( const Matrix< T > &  X,
Matrix< T > &  XAt 
) const
inline
template<typename T >
void spams::SpMatrix< T >::XAt ( const Matrix< T > &  X,
Matrix< T > &  XAt,
const Vector< int > &  indices 
) const
inline
template<typename T >
void spams::SpMatrix< T >::XtX ( Matrix< T > &  XtX) const
inlinevirtual

Friends And Related Function Documentation

template<typename T>
friend class Matrix< T >
friend

Definition at line 762 of file linalg.h.

template<typename T>
friend class SpVector< T >
friend

Definition at line 763 of file linalg.h.

Member Data Documentation

template<typename T>
bool spams::SpMatrix< T >::_externAlloc
private

if the data has been externally allocated

Definition at line 900 of file linalg.h.

Referenced by spams::SpMatrix< T >::clear(), spams::SpMatrix< T >::resize(), spams::Matrix< T >::toSparse(), and spams::Matrix< T >::toSparseTrans().

template<typename T>
int spams::SpMatrix< T >::_m
private
template<typename T>
int spams::SpMatrix< T >::_n
private
template<typename T>
int spams::SpMatrix< T >::_nzmax
private
template<typename T>
int* spams::SpMatrix< T >::_pB
private
template<typename T>
int* spams::SpMatrix< T >::_pE
private
template<typename T>
int* spams::SpMatrix< T >::_r
private
template<typename T>
T* spams::SpMatrix< T >::_v
private

The documentation for this class was generated from the following file: