FlexBox - A Flexible Primal-Dual ToolBox
flexZeroOperator.h
1 #ifndef flexZeroOperator_H
2 #define flexZeroOperator_H
3 
4 #include <vector>
5 #include "flexLinearOperator.h"
6 
8 template<typename T>
10 {
11 
12 #ifdef __CUDACC__
13  typedef thrust::device_vector<T> Tdata;
14 #else
15  typedef std::vector<T> Tdata;
16 #endif
17 
18 public:
20 
25  flexZeroOperator(int aNumRows, int aNumCols, bool aMinus) : flexLinearOperator<T>(aNumRows, aNumCols, zeroOp, aMinus) {};
26 
28  {
29  flexZeroOperator<T>* A = new flexZeroOperator<T>(this->getNumRows(), this->getNumCols(), this->isMinus);
30 
31  return A;
32  }
33 
34 
35  //apply linear operator to vector
36  void times(bool transposed, const Tdata &input, Tdata &output)
37  {
38  vectorScalarSet(output, (T)0);
39  }
40 
41  void timesPlus(bool transposed, const Tdata &input, Tdata &output){}
42 
43  void timesMinus(bool transposed, const Tdata &input, Tdata &output){}
44 
45  T getMaxRowSumAbs(bool transposed)
46  {
47  return static_cast<T>(1);
48  }
49 
50  std::vector<T> getAbsRowSum(bool transposed)
51  {
52  std::vector<T> result;
53  if(transposed)
54  result = std::vector<T>(this->getNumCols(),(T)0);
55  else
56  result = std::vector<T>(this->getNumRows(),(T)0);
57 
58 
59  return result;
60  }
61 
62  #ifdef __CUDACC__
63  thrust::device_vector<T> getAbsRowSumCUDA(bool transposed)
64  {
65  Tdata result(this->getNumRows(),(T)0);
66 
67  if (transposed)
68  {
69  result.resize(this->getNumCols());
70  }
71 
72  return result;
73  }
74  #endif
75 };
76 
77 #endif
int getNumRows() const
returns number of rows of the linear operator
Definition: flexLinearOperator.h:57
T getMaxRowSumAbs(bool transposed)
returns the maximum sum of absolute values per row used for preconditioning
Definition: flexZeroOperator.h:45
bool isMinus
determines if operator is negated
Definition: flexLinearOperator.h:25
int getNumCols() const
returns number of columns of the linear operator
Definition: flexLinearOperator.h:48
flexZeroOperator(int aNumRows, int aNumCols, bool aMinus)
initializes the zero operator
Definition: flexZeroOperator.h:25
thrust::device_vector< T > getAbsRowSumCUDA(bool transposed)
same function as getAbsRowSum() but implemented in CUDA
Definition: flexZeroOperator.h:63
void timesMinus(bool transposed, const Tdata &input, Tdata &output)
applies linear operator on vector and substracts its result from y
Definition: flexZeroOperator.h:43
void timesPlus(bool transposed, const Tdata &input, Tdata &output)
applies linear operator on vector and adds its result to y
Definition: flexZeroOperator.h:41
std::vector< T > getAbsRowSum(bool transposed)
returns a vector of sum of absolute values per row used for preconditioning
Definition: flexZeroOperator.h:50
represents a zero operator (empty matrix)
Definition: flexZeroOperator.h:9
void times(bool transposed, const Tdata &input, Tdata &output)
applies linear operator on vector
Definition: flexZeroOperator.h:36
abstract base class for linear operators
Definition: flexLinearOperator.h:12
flexZeroOperator< T > * copy()
copies the linear operator
Definition: flexZeroOperator.h:27