Toast++  1.0.2 (r.539)
Forward and inverse modelling in optical tomography
crmatrix_cusp.h
1 // -*-C++-*-
2 // ==========================================================================
3 // Module mathlib
4 // File crmatrix_cusp.h
5 // Declaration of template class cuspTCompRowMatrix ('CUSP template
6 // compressed-row matrix')
7 //
8 // This matrix format defines a compressed row matrix living on the GPU
9 // device memory and formatted for the CUSP GPU sparse solver library
10 //
11 // Currently only single-precision real and complex types are supported
12 //
13 // The following typedefs for specific template types have been defined
14 // for convenience:
15 // cuspFCompRowMatrix = cuspTCompRowMatrix<float> ('float')
16 // cuspSCCompRowMatrix = cuspTCompRowMatrix<scomplex> ('single complex')
17 //
18 // Inheritance:
19 // ------------
20 // TCompRowMatrix ----> cuspTCompRowMatrix
21 // ==========================================================================
22 
23 #ifndef __CRMATRIX_CUSP_H
24 #define __CRMATRIX_CUSP_H
25 
26 #include "crmatrix.h"
27 #include <thrust/extrema.h>
28 #include <cusp/csr_matrix.h>
29 
30 // ==========================================================================
31 // class cuspTCompRowMatrix
32 // ==========================================================================
33 
34 template<class MT> class cuspTCompRowMatrix: public TCompRowMatrix<MT> {
35 public:
37 
38  cuspTCompRowMatrix (int rows, int cols,
39  const idxtype *_rowptr, const idxtype *_colidx, const MT *data = 0);
40 
41  // Set from CPU matrix
42  void Set (const TCompRowMatrix<MT> &M);
43 
44  // Copy matrix from device memory to CPU matrix
45  TCompRowMatrix<MT> &Get () const;
46 
47 protected:
48  void MapHostToDev ();
49  void MapDevToHost () const;
50  cusp::csr_matrix<int,MT,cusp::device_memory> dA;
51 };
52 
53 #endif // !__CRMATRIX_CUSP_H
Compressed-row sparse matrix class.
Definition: cdmatrix.h:27
Definition: crmatrix_cusp.h:34