1 #ifndef flexConcatOperator_H 2 #define flexConcatOperator_H 7 #include "flexLinearOperator.h" 15 typedef thrust::device_vector<T> Tdata;
17 typedef std::vector<T> Tdata;
35 flexConcatOperator(
flexLinearOperator<T>* aA,
flexLinearOperator<T>* aB,
mySign aS,
bool aMinus) : A(aA), B(aB), s(aS), tmpVec(aA->
getNumCols()),
flexLinearOperator<T>(aA->
getNumRows(), aB->
getNumCols(), concatOp, aMinus)
48 void times(
bool transposed,
const Tdata &input, Tdata &output)
52 void timesPlus(
bool transposed,
const Tdata &input, Tdata &output)
90 thrust::fill(this->tmpVec.begin(), this->tmpVec.end(), (T)0);
92 std::fill(this->tmpVec.begin(), this->tmpVec.end(), (T)0);
103 B->
timesPlus(
true, this->tmpVec, output);
110 thrust::fill(this->tmpVec.begin(), this->tmpVec.end(), (T)0);
112 std::fill(this->tmpVec.begin(), this->tmpVec.end(), (T)0);
115 B->
timesPlus(
false, input, this->tmpVec);
123 A->
timesPlus(
false, this->tmpVec, output);
131 void timesMinus(
bool transposed,
const Tdata &input, Tdata &output)
169 thrust::fill(this->tmpVec.begin(), this->tmpVec.end(), (T)0);
171 std::fill(this->tmpVec.begin(), this->tmpVec.end(), (T)0);
177 B->
timesPlus(
true, this->tmpVec, output);
188 thrust::fill(this->tmpVec.begin(), this->tmpVec.end(), (T)0);
190 std::fill(this->tmpVec.begin(), this->tmpVec.end(), (T)0);
193 B->
timesPlus(
false, input, this->tmpVec);
196 A->
timesPlus(
false, this->tmpVec, output);
211 return static_cast<T
>(1);
216 std::vector<T> result;
224 result.resize(rowSumA.size());
226 #pragma omp parallel for 227 for (
int k = 0; k < result.size(); ++k)
229 result[k] = rowSumA[k] + rowSumB[k];
234 result.resize(rowSumA.size());
236 #pragma omp parallel for 237 for (
int k = 0; k < result.size(); ++k)
239 result[k] = rowSumA[k] + rowSumB[k];
245 T maxA = *std::max_element(rowSumA.begin(), rowSumA.end());
246 T maxB = *std::max_element(rowSumB.begin(), rowSumB.end());
247 T maxProd = maxA * maxB;
250 result.resize(this->B->
getNumCols(), maxProd);
252 result.resize(this->A->
getNumRows(), maxProd);
273 result.resize(rowSumA.size());
275 #pragma omp parallel for 276 for (
int k = 0; k < result.size(); ++k)
278 result[k] = rowSumA[k] + rowSumB[k];
284 result.resize(rowSumA.size());
286 #pragma omp parallel for 287 for (
int k = 0; k < result.size(); ++k)
289 result[k] = rowSumA[k] + rowSumB[k];
295 T maxA = *thrust::max_element(rowSumA.begin(), rowSumA.end());
296 T maxB = *thrust::max_element(rowSumB.begin(), rowSumB.end());
297 T maxProd = maxA * maxB;
300 result.resize(this->B->
getNumCols(), maxProd);
302 result.resize(this->A->
getNumRows(), maxProd);
int getNumRows() const
returns number of rows of the linear operator
Definition: flexLinearOperator.h:57
void timesPlus(bool transposed, const Tdata &input, Tdata &output)
applies linear operator on vector and adds its result to y
Definition: flexConcatOperator.h:52
void timesMinus(bool transposed, const Tdata &input, Tdata &output)
applies linear operator on vector and substracts its result from y
Definition: flexConcatOperator.h:131
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
thrust::device_vector< T > getAbsRowSumCUDA(bool transposed)
same function as getAbsRowSum() but implemented in CUDA
Definition: flexConcatOperator.h:262
represents a concatenation operator
Definition: flexConcatOperator.h:11
flexConcatOperator(flexLinearOperator< T > *aA, flexLinearOperator< T > *aB, mySign aS, bool aMinus)
initializes the concatenation operator
Definition: flexConcatOperator.h:35
virtual void timesPlus(bool transposed, const Tdata &input, Tdata &output)=0
applies linear operator on vector and adds its result to y
std::vector< T > getAbsRowSum(bool transposed)
returns a vector of sum of absolute values per row used for preconditioning
Definition: flexConcatOperator.h:214
T getMaxRowSumAbs(bool transposed)
returns the maximum sum of absolute values per row used for preconditioning
Definition: flexConcatOperator.h:209
flexConcatOperator< T > * copy()
copies the linear operator
Definition: flexConcatOperator.h:40
virtual thrust::device_vector< T > getAbsRowSumCUDA(bool transposed)=0
same function as getAbsRowSum() but implemented in CUDA
virtual std::vector< T > getAbsRowSum(bool transposed)=0
returns a vector of sum of absolute values per row used for preconditioning
void times(bool transposed, const Tdata &input, Tdata &output)
applies linear operator on vector
Definition: flexConcatOperator.h:48
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