10 #ifndef THYRA_EXAMPLE_TRIDIAG_SERIAL_LINEAR_OP_HPP
11 #define THYRA_EXAMPLE_TRIDIAG_SERIAL_LINEAR_OP_HPP
13 #include "Thyra_LinearOpDefaultBase.hpp"
14 #include "Thyra_DefaultSpmdVectorSpace.hpp"
15 #include "Thyra_DetachedVectorView.hpp"
16 #include "Teuchos_Assert.hpp"
46 template<
class Scalar>
92 space_ = Thyra::defaultSpmdVectorSpace<Scalar>(dim);
133 template<
class Scalar>
146 const Ordinal dim = space_->dim();
150 const Ordinal m = X_in.
domain()->dim();
152 for (Ordinal col_j = 0; col_j < m; ++col_j) {
162 if( beta == ST::zero() ) {
163 for( Ordinal k = 0; k < dim; ++k ) y[k] = ST::zero();
165 else if( beta != ST::one() ) {
166 for( Ordinal k = 0; k < dim; ++k ) y[k] *= beta;
172 y[k] += alpha * ( diag_[k]*x[k] + upper_[k]*x[k+1] );
173 for( k = 1; k < dim - 1; ++k )
174 y[k] += alpha * ( lower_[k-1]*x[k-1] + diag_[k]*x[k] + upper_[k]*x[k+1] );
175 y[k] += alpha * ( lower_[k-1]*x[k-1] + diag_[k]*x[k] );
178 y[k] += alpha * ( ST::conjugate(diag_[k])*x[k] + ST::conjugate(upper_[k])*x[k+1] );
179 for( k = 1; k < dim - 1; ++k )
180 y[k] += alpha * ( ST::conjugate(lower_[k-1])*x[k-1]
181 + ST::conjugate(diag_[k])*x[k] + ST::conjugate(upper_[k])*x[k+1] );
182 y[k] += alpha * ( ST::conjugate(lower_[k-1])*x[k-1] + ST::conjugate(diag_[k])*x[k] );
185 y[k] += alpha * ( diag_[k]*x[k] + lower_[k]*x[k+1] );
186 for( k = 1; k < dim - 1; ++k )
187 y[k] += alpha * ( upper_[k-1]*x[k-1] + diag_[k]*x[k] + lower_[k]*x[k+1] );
188 y[k] += alpha * ( upper_[k-1]*x[k-1] + diag_[k]*x[k] );
191 y[k] += alpha * ( ST::conjugate(diag_[k])*x[k] + ST::conjugate(lower_[k])*x[k+1] );
192 for( k = 1; k < dim - 1; ++k )
193 y[k] += alpha * ( ST::conjugate(upper_[k-1])*x[k-1]
194 + ST::conjugate(diag_[k])*x[k] + ST::conjugate(lower_[k])*x[k+1] );
195 y[k] += alpha * ( ST::conjugate(upper_[k-1])*x[k-1] + ST::conjugate(diag_[k])*x[k] );
205 #endif // THYRA_EXAMPLE_TRIDIAG_SERIAL_LINEAR_OP_HPP
ExampleTridiagSerialLinearOp(const Thyra::Ordinal dim, const Teuchos::ArrayView< const Scalar > &lower, const Teuchos::ArrayView< const Scalar > &diag, const Teuchos::ArrayView< const Scalar > &upper)
initialize().
EOpTransp
Enumeration for determining how a linear operator is applied. `*.
void initialize(const Thyra::Ordinal dim, const Teuchos::ArrayView< const Scalar > &lower, const Teuchos::ArrayView< const Scalar > &diag, const Teuchos::ArrayView< const Scalar > &upper)
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > domain() const
void applyImpl(const Thyra::EOpTransp M_trans, const Thyra::MultiVectorBase< Scalar > &X_in, const Teuchos::Ptr< Thyra::MultiVectorBase< Scalar > > &Y_inout, const Scalar alpha, const Scalar beta) const
Use the non-transposed operator.
Node subclass that provides a good default implementation for the describe() function.
Create an explicit non-mutable (const) view of a VectorBase object.
Use the transposed operator with complex-conjugate clements (same as TRANS for real scalar types)...
Use the non-transposed operator with complex-conjugate elements (same as NOTRANS for real scalar type...
Use the transposed operator.
Teuchos::Ordinal Ordinal
Type for the dimension of a vector space. `*.
Interface for a collection of column vectors called a multi-vector.
Create an explicit mutable (non-const) view of a VectorBase object.
RCP< const VectorBase< Scalar > > col(Ordinal j) const
Calls colImpl().
bool opSupportedImpl(Thyra::EOpTransp M_trans) const
ExampleTridiagSerialLinearOp()
Construct to uninitialized.
virtual RCP< const VectorSpaceBase< Scalar > > domain() const =0
Return a smart pointer for the domain space for this operator.
Teuchos::RCP< const Thyra::VectorSpaceBase< Scalar > > range() const
Simple example subclass for serial tridiagonal matrices.
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)