21 #include "bempp/common/config_trilinos.hpp"
23 #ifndef bempp_discrete_boundary_operator_hpp
24 #define bempp_discrete_boundary_operator_hpp
26 #include "../common/common.hpp"
27 #include "../common/shared_ptr.hpp"
29 #include "transposition_mode.hpp"
30 #include "boost/enable_shared_from_this.hpp"
32 #include "../common/armadillo_fwd.hpp"
35 #include <Thyra_LinearOpDefaultBase_decl.hpp>
38 #include <boost/mpl/set.hpp>
39 #include <boost/mpl/has_key.hpp>
40 #include <boost/utility/enable_if.hpp>
75 template <
typename ValueType>
76 class DiscreteBoundaryOperator :
77 public boost::enable_shared_from_this<DiscreteBoundaryOperator<ValueType> >
79 ,
public Thyra::LinearOpDefaultBase<ValueType>
90 using Thyra::LinearOpDefaultBase<ValueType>::apply;
115 void apply(
const Thyra::EOpTransp M_trans,
116 const Thyra::MultiVectorBase<ValueType>& x_in,
117 const Thyra::Ptr<Thyra::MultiVectorBase<ValueType> >& y_inout,
118 const ValueType alpha,
119 const ValueType beta)
const;
121 #endif // WITH_TRILINOS
148 const arma::Mat<ValueType>& x_in,
149 arma::Mat<ValueType>& y_inout,
150 const ValueType alpha,
151 const ValueType beta)
const;
180 virtual shared_ptr<const DiscreteBoundaryOperator>
182 bool interleave=
false)
const;
188 virtual void dump()
const;
193 virtual arma::Mat<ValueType>
asMatrix()
const;
196 virtual unsigned int rowCount()
const = 0;
220 virtual void addBlock(
const std::vector<int>& rows,
221 const std::vector<int>& cols,
222 const ValueType alpha,
223 arma::Mat<ValueType>& block)
const = 0;
227 virtual void applyImpl(
228 const Thyra::EOpTransp M_trans,
229 const Thyra::MultiVectorBase<ValueType> &X_in,
230 const Teuchos::Ptr<Thyra::MultiVectorBase<ValueType> > &Y_inout,
231 const ValueType alpha,
232 const ValueType beta)
const;
237 const arma::Col<ValueType>& x_in,
238 arma::Col<ValueType>& y_inout,
239 const ValueType alpha,
240 const ValueType beta)
const = 0;
245 template <
typename ValueType>
246 shared_ptr<const DiscreteBoundaryOperator<ValueType> > operator+(
247 const shared_ptr<
const DiscreteBoundaryOperator<ValueType> >& op);
254 template <
typename ValueType>
255 shared_ptr<const DiscreteBoundaryOperator<ValueType> > operator-(
256 const shared_ptr<
const DiscreteBoundaryOperator<ValueType> >& op);
263 template <
typename ValueType>
264 shared_ptr<DiscreteBoundaryOperator<ValueType> > operator+(
265 const shared_ptr<
const DiscreteBoundaryOperator<ValueType> >& op1,
266 const shared_ptr<
const DiscreteBoundaryOperator<ValueType> >& op2);
273 template <
typename ValueType>
274 shared_ptr<DiscreteBoundaryOperator<ValueType> > operator-(
275 const shared_ptr<
const DiscreteBoundaryOperator<ValueType> >& op1,
276 const shared_ptr<
const DiscreteBoundaryOperator<ValueType> >& op2);
283 template <
typename ValueType,
typename ScalarType>
284 typename boost::enable_if<
285 typename boost::mpl::has_key<
286 boost::mpl::set<float, double, std::complex<float>, std::complex<double> >,
288 shared_ptr<DiscreteBoundaryOperator<ValueType> > >::type
291 const shared_ptr<
const DiscreteBoundaryOperator<ValueType> >& op);
298 template <
typename ValueType,
typename ScalarType>
299 typename boost::enable_if<
300 typename boost::mpl::has_key<
301 boost::mpl::set<float, double, std::complex<float>, std::complex<double> >,
303 shared_ptr<DiscreteBoundaryOperator<ValueType> > >::type
305 const shared_ptr<
const DiscreteBoundaryOperator<ValueType> >& op,
313 template <
typename ValueType>
314 shared_ptr<DiscreteBoundaryOperator<ValueType> > operator*(
315 const shared_ptr<
const DiscreteBoundaryOperator<ValueType> >& op1,
316 const shared_ptr<
const DiscreteBoundaryOperator<ValueType> >& op2);
323 template <
typename ValueType>
324 shared_ptr<DiscreteBoundaryOperator<ValueType> > mul(
325 const shared_ptr<
const DiscreteBoundaryOperator<ValueType> >& op1,
326 const shared_ptr<
const DiscreteBoundaryOperator<ValueType> >& op2);
333 template <
typename ValueType,
typename ScalarType>
334 shared_ptr<DiscreteBoundaryOperator<ValueType> > operator/(
335 const shared_ptr<
const DiscreteBoundaryOperator<ValueType> >& op,
343 template <
typename ValueType>
344 shared_ptr<DiscreteBoundaryOperator<ValueType> > transpose(
345 const shared_ptr<
const DiscreteBoundaryOperator<ValueType> >& op);
352 template <
typename ValueType>
353 shared_ptr<DiscreteBoundaryOperator<ValueType> > conjugate(
354 const shared_ptr<
const DiscreteBoundaryOperator<ValueType> >& op);
361 template <
typename ValueType>
362 shared_ptr<DiscreteBoundaryOperator<ValueType> > conjugateTranspose(
363 const shared_ptr<
const DiscreteBoundaryOperator<ValueType> >& op);
371 template <
typename ValueType>
372 shared_ptr<DiscreteBoundaryOperator<ValueType> > transpose(
374 const shared_ptr<
const DiscreteBoundaryOperator<ValueType> >& op);
384 template <
typename RealType>
385 shared_ptr<DiscreteBoundaryOperator<std::complex<RealType> > > complexify(
386 const shared_ptr<
const DiscreteBoundaryOperator<RealType> >& op);
388 template <
typename ValueType>
389 shared_ptr<DiscreteBoundaryOperator<ValueType> > sum(
390 const shared_ptr<
const DiscreteBoundaryOperator<ValueType> >& op1,
391 const shared_ptr<
const DiscreteBoundaryOperator<ValueType> >& op2);
virtual void addBlock(const std::vector< int > &rows, const std::vector< int > &cols, const ValueType alpha, arma::Mat< ValueType > &block) const =0
Add a subblock of this operator to a matrix.
void apply(const Thyra::EOpTransp M_trans, const Thyra::MultiVectorBase< ValueType > &x_in, const Thyra::Ptr< Thyra::MultiVectorBase< ValueType > > &y_inout, const ValueType alpha, const ValueType beta) const
Apply the linear operator to a multivector.
TranspositionMode
Enumeration determining how a discrete boundary operator is transformed before being applied...
Definition: transposition_mode.hpp:37
virtual unsigned int rowCount() const =0
Number of rows of the operator.
virtual ~DiscreteBoundaryOperator()
Destructor.
Definition: discrete_boundary_operator.hpp:84
virtual arma::Mat< ValueType > asMatrix() const
Matrix representation of the operator.
Definition: discrete_boundary_operator.cpp:40
virtual shared_ptr< const DiscreteBoundaryOperator > asDiscreteAcaBoundaryOperator(double eps=-1, int maximumRank=-1, bool interleave=false) const
Return a representation that can be cast to a DiscreteAcaBoundaryOperator.
Definition: discrete_boundary_operator.cpp:92
virtual void dump() const
Write a textual representation of the operator to standard output.
Definition: discrete_boundary_operator.cpp:110
virtual unsigned int columnCount() const =0
Number of columns of the operator.