SHOGUN  v3.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
List of all members | Public Member Functions | Public Attributes | Protected Member Functions
SGSparseMatrix< T > Class Template Reference

Detailed Description

template<class T>
class shogun::SGSparseMatrix< T >

template class SGSparseMatrix

Definition at line 32 of file SGSparseMatrix.h.

Inheritance diagram for SGSparseMatrix< T >:
Inheritance graph
[legend]

Public Member Functions

 SGSparseMatrix ()
 SGSparseMatrix (SGSparseVector< T > *vecs, index_t num_feat, index_t num_vec, bool ref_counting=true)
 SGSparseMatrix (index_t num_feat, index_t num_vec, bool ref_counting=true)
 SGSparseMatrix (SGMatrix< T > dense)
 SGSparseMatrix (const SGSparseMatrix &orig)
virtual ~SGSparseMatrix ()
const SGSparseVector< T > & operator[] (index_t index) const
SGSparseVector< T > & operator[] (index_t index)
SGSparseMatrix< T > get ()
const SGVector< T > operator* (SGVector< T > v) const
template<class ST >
const SGVector< T > operator* (SGVector< ST > v) const
const T operator() (index_t i_row, index_t i_col) const
T & operator() (index_t i_row, index_t i_col)
void load (CFile *loader)
SGVector< float64_tload_with_labels (CLibSVMFile *libsvm_file, bool do_sort_features=true)
void save (CFile *saver)
void save_with_labels (CLibSVMFile *saver, SGVector< float64_t > labels)
SGSparseMatrix< T > get_transposed ()
void from_dense (SGMatrix< T > full)
void sort_features ()
template<>
const SGVector< complex128_toperator* (SGVector< float64_t > v) const
template<>
const SGVector< complex128_toperator* (SGVector< int32_t > v) const
template<>
const SGVector< float64_toperator* (SGVector< int32_t > v) const
template<>
void load (CFile *loader)
template<>
SGVector< float64_tload_with_labels (CLibSVMFile *file, bool do_sort_features)
template<>
void save (CFile *saver)
template<>
void save_with_labels (CLibSVMFile *saver, SGVector< float64_t > labels)
int32_t ref_count ()

Public Attributes

index_t num_vectors
 total number of vectors
index_t num_features
 total number of features
SGSparseVector< T > * sparse_matrix
 array of sparse vectors of size num_vectors

Protected Member Functions

virtual void copy_data (const SGReferencedData &orig)
virtual void init_data ()
virtual void free_data ()
void copy_refcount (const SGReferencedData &orig)
int32_t ref ()
int32_t unref ()

Constructor & Destructor Documentation

default constructor

Definition at line 11 of file SGSparseMatrix.cpp.

SGSparseMatrix ( SGSparseVector< T > *  vecs,
index_t  num_feat,
index_t  num_vec,
bool  ref_counting = true 
)

constructor for setting params

Definition at line 17 of file SGSparseMatrix.cpp.

SGSparseMatrix ( index_t  num_feat,
index_t  num_vec,
bool  ref_counting = true 
)

constructor to create new matrix in memory

Definition at line 26 of file SGSparseMatrix.cpp.

SGSparseMatrix ( SGMatrix< T >  dense)

constructor to create new sparse matrix from a dense one

Parameters
densedense matrix to be converted

Definition at line 34 of file SGSparseMatrix.cpp.

SGSparseMatrix ( const SGSparseMatrix< T > &  orig)

copy constructor

Definition at line 40 of file SGSparseMatrix.cpp.

~SGSparseMatrix ( )
virtual

destructor

Definition at line 46 of file SGSparseMatrix.cpp.

Member Function Documentation

void copy_data ( const SGReferencedData orig)
protectedvirtual

copy data

Implements SGReferencedData.

Definition at line 159 of file SGSparseMatrix.cpp.

void copy_refcount ( const SGReferencedData orig)
protectedinherited

copy refcount

Definition at line 58 of file SGReferencedData.cpp.

void free_data ( )
protectedvirtual

free data

Implements SGReferencedData.

Definition at line 175 of file SGSparseMatrix.cpp.

void from_dense ( SGMatrix< T >  full)

Definition at line 232 of file SGSparseMatrix.cpp.

SGSparseMatrix<T> get ( )

get the sparse matrix (no copying is done here)

Returns
the refcount increased matrix

Definition at line 74 of file SGSparseMatrix.h.

SGSparseMatrix< T > get_transposed ( )

return the transposed of the sparse matrix

Definition at line 182 of file SGSparseMatrix.cpp.

void init_data ( )
protectedvirtual

init data

Implements SGReferencedData.

Definition at line 167 of file SGSparseMatrix.cpp.

void load ( CFile loader)

Definition at line 102 of file SGSparseMatrix.cpp.

void load ( CFile loader)

load sparse matrix from file

Parameters
loaderFile object via which to load data

Definition at line 91 of file SGSparseMatrix.cpp.

SGVector< float64_t > load_with_labels ( CLibSVMFile file,
bool  do_sort_features 
)

Definition at line 123 of file SGSparseMatrix.cpp.

SGVector< float64_t > load_with_labels ( CLibSVMFile libsvm_file,
bool  do_sort_features = true 
)

load sparse matrix from libsvm file together with labels

Parameters
thelibsvm file
whetherto sort the vector indices (such that they are in ascending order) after loading
Returns
label vector

Definition at line 107 of file SGSparseMatrix.cpp.

const T operator() ( index_t  i_row,
index_t  i_col 
) const

operator overload for sparse-matrix read only access

Parameters
i_row
i_col

Definition at line 105 of file SGSparseMatrix.h.

T& operator() ( index_t  i_row,
index_t  i_col 
)

operator overload for sparse-matrix r/w access

Parameters
i_row
i_col

Definition at line 126 of file SGSparseMatrix.h.

const SGVector< complex128_t > operator* ( SGVector< float64_t v) const

Definition at line 52 of file SGSparseMatrix.cpp.

const SGVector< complex128_t > operator* ( SGVector< int32_t >  v) const

Definition at line 65 of file SGSparseMatrix.cpp.

const SGVector< float64_t > operator* ( SGVector< int32_t >  v) const

Definition at line 78 of file SGSparseMatrix.cpp.

const SGVector<T> operator* ( SGVector< T >  v) const

compute sparse-matrix dense-vector multiplication

Parameters
vthe dense-vector to be multiplied with
Returns
the result vector \(Q*v\), Q being this sparse matrix

Definition at line 83 of file SGSparseMatrix.h.

const SGVector<T> operator* ( SGVector< ST >  v) const

compute sparse-matrix dense-vector multiplication

Parameters
vthe dense-vector to be multiplied with
Returns
the result vector \(Q*v\), Q being this sparse matrix
const SGSparseVector<T>& operator[] ( index_t  index) const

index access operator

Definition at line 58 of file SGSparseMatrix.h.

SGSparseVector<T>& operator[] ( index_t  index)

index access operator

Definition at line 64 of file SGSparseMatrix.h.

int32_t ref ( )
protectedinherited

increase reference counter

Returns
reference count

Definition at line 67 of file SGReferencedData.cpp.

int32_t ref_count ( )
inherited

display reference counter

Returns
reference count

Definition at line 44 of file SGReferencedData.cpp.

void save ( CFile saver)

Definition at line 137 of file SGSparseMatrix.cpp.

void save ( CFile saver)

save sparse matrix to file

Parameters
saverFile object via which to save data

Definition at line 127 of file SGSparseMatrix.cpp.

void save_with_labels ( CLibSVMFile saver,
SGVector< float64_t labels 
)

Definition at line 155 of file SGSparseMatrix.cpp.

void save_with_labels ( CLibSVMFile saver,
SGVector< float64_t labels 
)

save sparse matrix together with labels to file

Parameters
saverFile object via which to save data
labelslabel vector

Definition at line 142 of file SGSparseMatrix.cpp.

void sort_features ( )

sort the indices of the sparse matrix such that they are in ascending order

Definition at line 224 of file SGSparseMatrix.cpp.

int32_t unref ( )
protectedinherited

decrement reference counter and deallocate object if refcount is zero before or after decrementing it

Returns
reference count

Definition at line 87 of file SGReferencedData.cpp.

Member Data Documentation

index_t num_features

total number of features

Definition at line 203 of file SGSparseMatrix.h.

index_t num_vectors

total number of vectors

Definition at line 200 of file SGSparseMatrix.h.

SGSparseVector<T>* sparse_matrix

array of sparse vectors of size num_vectors

Definition at line 206 of file SGSparseMatrix.h.


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

SHOGUN Machine Learning Toolbox - Documentation