41 #ifndef __SPARSE_MATRIX_HPP__
42 #define __SPARSE_MATRIX_HPP__
48 #include <cuv/tensor_ops/tensor_ops.hpp>
49 #include <cuv/basics/matrix.hpp>
50 #include <cuv/tools/cuv_general.hpp>
57 template<
class __value_type,
class __memory_space_type,
class __index_type=
unsigned int>
59 :
public matrix<__value_type, __index_type>{
122 std::vector<index_type>
124 std::vector<index_type> s(2);
172 for(
unsigned int i=0;i<v.size();i++)
200 typename std::map<int,index_type>::const_iterator it =
m_dia2off.find(k);
201 int off = it->second;
202 const index_type i_start = std::max((
int)0,-k);
203 const index_type j_start = std::max((
int)0, k);
212 const index_type i_start = std::max((
int)0,-k);
213 const index_type j_start = std::max((
int)0, k);
231 typename std::map<int,index_type>::const_iterator it =
m_dia2off.find(off);
234 (*m_vec)[it->second *
m_stride +i]=val;
239 typename std::map<int,index_type>::const_iterator it =
m_dia2off.find(off);
247 typename std::map<int,index_type>::const_iterator it =
m_dia2off.find(off);
261 if(
this==&o)
return *
this;
273 (
const_cast< my_type *
>(&o))->m_vec = NULL;
287 template<
class V,
class T,
class I>
289 operator<<(ostream& o, const cuv::dia_matrix<V,T,I>& w2){
290 cout <<
"Dia-Matrix: "<<endl;
291 for(I i=0;i<w2.h();i++){
292 for(I j=0;j<w2.w();j++){