Compressed Sparse Blocks  1.2
 All Classes Files Functions Variables Typedefs Friends Macros Pages
spvec.h
Go to the documentation of this file.
1 #ifndef _SPVEC_H_
2 #define _SPVEC_H_
3 
4 #include "csc.h"
5 #include "bicsb.h"
6 #include "matmul.h"
7 #include "Semirings.h"
8 
9 template <class T, class ITYPE>
10 class Spvec
11 {
12 public:
13  Spvec (): n(0) {};
14  Spvec (ITYPE dim);
15  Spvec (T * darr, ITYPE dim);
16  Spvec (const Spvec<T,ITYPE> & rhs);
17  ~Spvec();
19 
20  T& operator[] (const ITYPE nIndex)
21  {
22  return arr[nIndex];
23  }
24 
26  Spvec<T,ITYPE> & operator+=(const Matmul< Csc<T, ITYPE>, Spvec<T,ITYPE> > & matmul);
27  Spvec<T,ITYPE> & operator+=(const Matmul< BiCsb<T, ITYPE>, Spvec<T,ITYPE> > & matmul);
28 
29  void fillzero();
30  void fillrandom();
31  void fillone()
32  {
33  std::fill(arr,arr+n, static_cast<T>(1.0));
34  }
35  void fillfota()
36  {
37  for(ITYPE i =0; i<n; ++i)
38  arr[i] = (i+1) * static_cast<T>(1.0);
39  }
40 
41  ITYPE size() const { return n-padding;} // return the real size
42  T * getarr(){ return arr;}
43 
44 private:
45  T * arr;
46  ITYPE n;
47  ITYPE padding;
48 };
49 
50 #include "spvec.cpp"
51 #endif
52 
void fillfota()
Definition: spvec.h:35
void fillrandom()
Definition: spvec.cpp:117
T & operator[](const ITYPE nIndex)
Definition: spvec.h:20
Spvec< T, ITYPE > & operator=(const Spvec< T, ITYPE > &rhs)
Definition: spvec.cpp:54
void fillzero()
Definition: spvec.cpp:135
Definition: spvec.h:10
T * getarr()
Definition: spvec.h:42
Spvec()
Definition: spvec.h:13
~Spvec()
Definition: spvec.cpp:77
Spvec< T, ITYPE > & operator+=(const Matmul< Csc< T, ITYPE >, Spvec< T, ITYPE > > &matmul)
Delayed evaluations using compositors for SpMV operation... y <- y + Ax.
Definition: spvec.cpp:86
Definition: csc.h:15
Definition: bicsb.h:19
void fillone()
Definition: spvec.h:31
ITYPE size() const
Definition: spvec.h:41