Skip to content
Snippets Groups Projects
Commit 50ee728a authored by Uli Sack's avatar Uli Sack Committed by usack
Browse files

added support for coefficients in the sumoperator, e.g. now implementing aA+bB

[[Imported from SVN: r7056]]
parent 036da4c3
No related branches found
No related tags found
No related merge requests found
......@@ -22,15 +22,28 @@ class SumOperator
//! default constructor - allocates memory for summand operators internally
SumOperator():
alpha_(1.0),
beta_(1.0),
summands_allocated_internally_(true)
{
sparse_matrix_ = new SparseMatrixType;
lowrank_matrix_ = new LowRankMatrixType;
}
//! construct from summands
SumOperator(double a, SparseMatrixType& A, double b, LowRankMatrixType& M):
alpha_(a),
sparse_matrix_(&A),
beta_(b),
lowrank_matrix_(&M),
summands_allocated_internally_(false)
{}
//! construct from summands
SumOperator(SparseMatrixType& A, LowRankMatrixType& M):
alpha_(1.0),
sparse_matrix_(&A),
beta_(1.0),
lowrank_matrix_(&M),
summands_allocated_internally_(false)
{}
......@@ -48,32 +61,33 @@ class SumOperator
template <class LVectorType, class RVectorType>
void umv(const LVectorType& x, RVectorType& b) const
{
sparse_matrix_->umv(x,b);
lowrank_matrix_->umv(x,b);
sparse_matrix_->usmv(alpha_,x,b);
lowrank_matrix_->usmv(beta_,x,b);
}
//! b -= (A+M)x
template <class LVectorType, class RVectorType>
void mmv(const LVectorType& x, RVectorType& b) const
{
sparse_matrix_->mmv(x,b);
lowrank_matrix_->mmv(x,b);
sparse_matrix_->usmv(-alpha_,x,b);
lowrank_matrix_->usmv(-beta_,x,b);
}
//! b = (A+M)x
template <class LVectorType, class RVectorType>
void mv(const LVectorType& x, RVectorType& b) const
{
sparse_matrix_->mv(x,b);
lowrank_matrix_->umv(x,b);
b = 0.0;
sparse_matrix_->usmv(alpha_,x,b);
lowrank_matrix_->usmv(beta_,x,b);
}
//! b += a*(A+M)x
template <class LVectorType, class RVectorType>
void usmv(const field_type a, const LVectorType& x, RVectorType& b) const
{
sparse_matrix_->usmv(a,x,b);
lowrank_matrix_->usmv(a,x,b);
sparse_matrix_->usmv(a*alpha_,x,b);
lowrank_matrix_->usmv(a*beta_,x,b);
}
//! return the number of rows
......@@ -112,6 +126,8 @@ class SumOperator
return *lowrank_matrix_;
}
double alpha_,
beta_;
private:
//! one summand
SparseMatrixType* sparse_matrix_;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment