FlexBox - A Flexible Primal-Dual ToolBox
flexLinearOperator.h
1 #ifndef flexLinearOperator_H
2 #define flexLinearOperator_H
3 
4 #include <vector>
5 #include "tools.h"
6 
8 
11 template <typename T>
13 {
14  #ifdef __CUDACC__
15  typedef thrust::device_vector<T> Tdata;
16  #else
17  typedef std::vector<T> Tdata;
18  #endif
19 
20 private:
21  int numRows;
22  int numCols;
23 public:
25  bool isMinus;
26 
28 
34  flexLinearOperator(int aNumRows, int aNumCols, linOp aType, bool aIsMinus) : numRows(aNumRows), numCols(aNumCols), type(linearOp), isMinus(aIsMinus)
35  {
36 
37  }
38 
39  virtual ~flexLinearOperator()
40  {
41  if (VERBOSE > 0) printf("Linear operator destructor");
42  }
43 
45 
48  int getNumCols() const
49  {
50  return numCols;
51  }
52 
54 
57  int getNumRows() const
58  {
59  return numRows;
60  }
61 
63 
66  void setNumCols(int aNumCols)
67  {
68  numCols = aNumCols;
69  }
70 
72 
75  void setNumRows(int aNumRows)
76  {
77  numRows = aNumRows;
78  }
79 
81 
84  void setMinus(bool aIsMinus)
85  {
86  this->isMinus = aIsMinus;
87  }
88 
90 
93  virtual flexLinearOperator<T>* copy() = 0;
94 
96 
102  virtual void times(bool transposed, const Tdata &input, Tdata &output) = 0;
103 
105 
111  virtual void timesPlus(bool transposed, const Tdata &input, Tdata &output) = 0;
112 
114 
120  virtual void timesMinus(bool transposed, const Tdata &input, Tdata &output) = 0;
121 
123 
127  virtual std::vector<T> getAbsRowSum(bool transposed) = 0;
128 
129  #ifdef __CUDACC__
130 
135  virtual thrust::device_vector<T> getAbsRowSumCUDA(bool transposed) = 0;
136  #endif
137 
139 
143  virtual T getMaxRowSumAbs(bool transposed) = 0;
144 };
145 
146 #endif
int getNumRows() const
returns number of rows of the linear operator
Definition: flexLinearOperator.h:57
bool isMinus
determines if operator is negated
Definition: flexLinearOperator.h:25
virtual T getMaxRowSumAbs(bool transposed)=0
returns the maximum sum of absolute values per row used for preconditioning
linOp type
type of linear operator
Definition: flexLinearOperator.h:24
int getNumCols() const
returns number of columns of the linear operator
Definition: flexLinearOperator.h:48
void setMinus(bool aIsMinus)
constrols if operator should be negated or not
Definition: flexLinearOperator.h:84
void setNumCols(int aNumCols)
sets the number of columns of the linear operator
Definition: flexLinearOperator.h:66
virtual void times(bool transposed, const Tdata &input, Tdata &output)=0
applies linear operator on vector
virtual void timesPlus(bool transposed, const Tdata &input, Tdata &output)=0
applies linear operator on vector and adds its result to y
virtual thrust::device_vector< T > getAbsRowSumCUDA(bool transposed)=0
same function as getAbsRowSum() but implemented in CUDA
void setNumRows(int aNumRows)
sets the number of rows of the linear operator
Definition: flexLinearOperator.h:75
virtual std::vector< T > getAbsRowSum(bool transposed)=0
returns a vector of sum of absolute values per row used for preconditioning
virtual flexLinearOperator< T > * copy()=0
copies the linear operator
flexLinearOperator(int aNumRows, int aNumCols, linOp aType, bool aIsMinus)
initializes the linear operator
Definition: flexLinearOperator.h:34
virtual void timesMinus(bool transposed, const Tdata &input, Tdata &output)=0
applies linear operator on vector and substracts its result from y
abstract base class for linear operators
Definition: flexLinearOperator.h:12
linOp
enum representing the type of a linear operator
Definition: tools.h:83