42 #ifndef THYRA_VECTOR_DEFAULT_BASE_DEF_HPP 
   43 #define THYRA_VECTOR_DEFAULT_BASE_DEF_HPP 
   50 #include "Thyra_VectorDefaultBase_decl.hpp" 
   51 #include "Thyra_VectorSpaceFactoryBase.hpp" 
   52 #include "Thyra_VectorBase.hpp" 
   53 #include "Thyra_VectorStdOps.hpp" 
   54 #include "Thyra_MultiVectorDefaultBase.hpp" 
   55 #include "Thyra_AssertOp.hpp" 
   56 #include "Thyra_MultiVectorBase.hpp" 
   57 #include "Thyra_DetachedVectorView.hpp" 
   58 #include "RTOpPack_ROpGetSubVector.hpp" 
   59 #include "RTOpPack_TOpSetSubVector.hpp" 
   60 #include "RTOpPack_ROpNorm1.hpp" 
   61 #include "RTOpPack_ROpNorm2.hpp" 
   62 #include "RTOpPack_ROpWeightedNorm2.hpp" 
   63 #include "RTOpPack_ROpNormInf.hpp" 
   64 #include "RTOpPack_TOpAbs.hpp" 
   65 #include "RTOpPack_TOpAssignVectors.hpp" 
   66 #include "RTOpPack_TOpAXPY.hpp" 
   67 #include "RTOpPack_TOpEleWiseScale.hpp" 
   68 #include "RTOpPack_TOpLinearCombination.hpp" 
   69 #include "RTOpPack_TOpScaleVector.hpp" 
   70 #include "RTOpPack_TOpReciprocal.hpp" 
   71 #include "RTOpPack_TOpRandomize.hpp" 
   72 #include "Teuchos_Assert.hpp" 
   75 #ifdef THYRA_VECTOR_VERBOSE_TO_ERROR_OUT 
   76 #  include "Teuchos_VerboseObject.hpp" 
   77 #  define THYRA_VECTOR_VERBOSE_OUT_STATEMENT \ 
   78      RCP<Teuchos::FancyOStream> dbgout = Teuchos::VerboseObjectBase::getDefaultOStream() 
   79 #endif // THYRA_VECTOR_VERBOSE_TO_ERROR_OUT 
   89 template<
class Scalar>
 
   92   std::ostringstream oss;
 
   96     oss << 
"{space=NULL}"; 
 
  100     oss << 
"{dim=" << dim << 
"}";
 
  106 template<
class Scalar>
 
  116   *out << this->description() << 
"\n";
 
  117   if (this->space()->dim()) {
 
  122         *out << i << 
":" << dvv[i] << std::endl;
 
  131 template<
class Scalar>
 
  135 #ifdef THYRA_VECTOR_VERBOSE_TO_ERROR_OUT 
  136   THYRA_VECTOR_VERBOSE_OUT_STATEMENT;
 
  137   *dbgout << 
"\nThyra::VectorDefaultBase<" 
  139           <<
">::range() called!\n";
 
  141   return this->space();
 
  145 template<
class Scalar>
 
  149 #ifdef THYRA_VECTOR_VERBOSE_TO_ERROR_OUT 
  150   THYRA_VECTOR_VERBOSE_OUT_STATEMENT;
 
  151   *dbgout << 
"\nThyra::VectorDefaultBase<" 
  153           <<
">::domain() called!\n";
 
  156     domain_ = range()->smallVecSpcFcty()->createVecSpc(1);
 
  165 template<
class Scalar>
 
  169 #ifdef THYRA_VECTOR_VERBOSE_TO_ERROR_OUT 
  170   THYRA_VECTOR_VERBOSE_OUT_STATEMENT;
 
  171   *dbgout << 
"\nThyra::VectorDefaultBase<" 
  173           <<
">::clone_mv() called!\n";
 
  175   return this->clone_v();
 
  182 template<
class Scalar>
 
  186 #ifdef THYRA_VECTOR_VERBOSE_TO_ERROR_OUT 
  187   THYRA_VECTOR_VERBOSE_OUT_STATEMENT;
 
  188   *dbgout << 
"\nThyra::VectorDefaultBase<" 
  190           <<
">::clone_v() called!\n";
 
  193   ::Thyra::assign<Scalar>(copy.
ptr(), *
this);
 
  201 template<
class Scalar>
 
  208 template<
class Scalar>
 
  211   using Teuchos::tuple; 
using Teuchos::null;
 
  213   Thyra::applyOp<Scalar>(random_vector_op,
 
  220 template<
class Scalar>
 
  223   using Teuchos::tuple; 
using Teuchos::ptrInArg; 
using Teuchos::null;
 
  224   RTOpPack::TOpAbs<Scalar> abs_op;
 
  225   Thyra::applyOp<Scalar>(abs_op, tuple(ptrInArg(x)),
 
  226     tuple<Ptr<VectorBase<Scalar> > >(ptr(
this)), null);
 
  230 template<
class Scalar>
 
  233   using Teuchos::tuple; 
using Teuchos::ptrInArg; 
using Teuchos::null;
 
  234   RTOpPack::TOpReciprocal<Scalar> recip_op;
 
  235   Thyra::applyOp<Scalar>(recip_op, tuple(ptrInArg(x)),
 
  236     tuple<Ptr<VectorBase<Scalar> > >(ptr(
this)), null);
 
  240 template<
class Scalar>
 
  243   using Teuchos::tuple; 
using Teuchos::ptrInArg; 
using Teuchos::null;
 
  245   Thyra::applyOp<Scalar>(scale_op, tuple(ptrInArg(x)),
 
  246     tuple<Ptr<VectorBase<Scalar> > >(ptr(
this)), null);
 
  250 template<
class Scalar>
 
  259 template<
class Scalar>
 
  267   for (
Ordinal i = 0; i < x.size(); ++i)
 
  269   this->linear_combination(alpha, mv(), beta);
 
  273 template<
class Scalar>
 
  277   this->dots(x, Teuchos::arrayView(&prod, 1));
 
  282 template<
class Scalar>
 
  287   this->norms_1(Teuchos::arrayView(&norm, 1));
 
  292 template<
class Scalar>
 
  297   this->norms_2(Teuchos::arrayView(&norm, 1));
 
  302 template<
class Scalar>
 
  306   using Teuchos::tuple; 
using Teuchos::ptrInArg; 
using Teuchos::null;
 
  309   Thyra::applyOp<Scalar>(norm_op,
 
  313   return norm_op(*norm_targ);
 
  316 template<
class Scalar>
 
  321   this->norms_inf(Teuchos::arrayView(&norm, 1));
 
  329 template<
class Scalar>
 
  333 #ifdef THYRA_VECTOR_VERBOSE_TO_ERROR_OUT 
  334   THYRA_VECTOR_VERBOSE_OUT_STATEMENT;
 
  335   *dbgout << 
"\nThyra::VectorDefaultBase<" 
  347 template<
class Scalar>
 
  351 #ifdef THYRA_VECTOR_VERBOSE_TO_ERROR_OUT 
  352   THYRA_VECTOR_VERBOSE_OUT_STATEMENT;
 
  353   *dbgout << 
"\nThyra::VectorDefaultBase<" 
  355           <<
">::contigSubViewImpl(col_rng) const called!\n";
 
  357   validateColRng(col_rng);
 
  362 template<
class Scalar>
 
  366 #ifdef THYRA_VECTOR_VERBOSE_TO_ERROR_OUT 
  367   THYRA_VECTOR_VERBOSE_OUT_STATEMENT;
 
  368   *dbgout << 
"\nThyra::VectorDefaultBase<" 
  370           <<
">::nonconstContigSubViewImpl(col_rng) called!\n";
 
  372   validateColRng(col_rng);
 
  377 template<
class Scalar>
 
  382 #ifdef THYRA_VECTOR_VERBOSE_TO_ERROR_OUT 
  383   THYRA_VECTOR_VERBOSE_OUT_STATEMENT;
 
  384   *dbgout << 
"\nThyra::VectorDefaultBase<" 
  386           <<
">::nonContigSubViewImpl(cols) called!\n";
 
  388   validateColIndexes(cols);
 
  393 template<
class Scalar>
 
  398 #ifdef THYRA_VECTOR_VERBOSE_TO_ERROR_OUT 
  399   THYRA_VECTOR_VERBOSE_OUT_STATEMENT;
 
  400   *dbgout << 
"\nThyra::VectorDefaultBase<" 
  402           <<
">::nonconstNonContigSubViewImpl(cols) called!\n";
 
  404   validateColIndexes(cols);
 
  409 template<
class Scalar>
 
  416 #ifdef THYRA_VECTOR_VERBOSE_TO_ERROR_OUT 
  417   THYRA_VECTOR_VERBOSE_OUT_STATEMENT;
 
  418   *dbgout << 
"\nThyra::VectorDefaultBase<" 
  420           <<
">::acquireDetachedMultiVectorViewImpl() const called!\n";
 
  425   validateColRng(colRng);
 
  427   this->acquireDetachedView(rowRng,&sv);
 
  435 template<
class Scalar>
 
  445 template<
class Scalar>
 
  452 #ifdef THYRA_VECTOR_VERBOSE_TO_ERROR_OUT 
  453   THYRA_VECTOR_VERBOSE_OUT_STATEMENT;
 
  454   *dbgout << 
"\nThyra::VectorDefaultBase<" 
  456           <<
">::acquireNonconstDetachedMultiVectorViewImpl() called!\n";
 
  461   validateColRng(colRng);
 
  463   this->acquireDetachedView(rowRng,&sv);
 
  471 template<
class Scalar>
 
  476 #ifdef THYRA_VECTOR_VERBOSE_TO_ERROR_OUT 
  477   THYRA_VECTOR_VERBOSE_OUT_STATEMENT;
 
  478   *dbgout << 
"\nThyra::VectorDefaultBase<" 
  480           <<
">::commitNonconstDetachedMultiVectorViewImpl() called!\n";
 
  487   this->commitDetachedView(&sv);
 
  495 template<
class Scalar>
 
  501   using Teuchos::tuple;
 
  505     !(rng.
ubound() < this->space()->dim()), std::out_of_range
 
  506     ,
"VectorDefaultBase<Scalar>::acquireDetachedVectorViewImpl(rng,...):" 
  508     <<
"] is not in range = [0,"<<(this->space()->dim()-1)<<
"]" );
 
  514     reduct_obj = get_sub_vector_op.reduct_obj_create(); 
 
  516   ::Thyra::applyOp<Scalar>(get_sub_vector_op, tuple(Teuchos::ptr<
const VectorBase<Scalar> >(
this))(),
 
  517     Teuchos::null, reduct_obj.ptr());
 
  519   *sub_vec_inout = get_sub_vector_op(*reduct_obj);
 
  523 template<
class Scalar>
 
  533 template<
class Scalar>
 
  551     Teuchos::arcp_const_cast<Scalar>(sub_vec.
values()), sub_vec.
stride()
 
  556 template<
class Scalar>
 
  571 template<
class Scalar>
 
  575   ::Thyra::applyOp<Scalar>(set_sub_vector_op, Teuchos::null,
 
  583 template<
class Scalar>
 
  587   return ( ST::isComplex ? ( M_trans==
NOTRANS || M_trans==
CONJTRANS ) : 
true );
 
  591 template<
class Scalar>
 
  606     "VectorDefaultBase<Scalar>::apply()", *
this, M_trans, X, &*Y);
 
  611   for (
Ordinal col_j = 0; col_j < numCols; ++col_j) {
 
  618     if( M_trans == 
NOTRANS || (M_trans == 
CONJ && !ST::isComplex) ) {
 
  620 #ifdef THYRA_VECTOR_VERBOSE_TO_ERROR_OUT 
  621       THYRA_VECTOR_VERBOSE_OUT_STATEMENT;
 
  622       *dbgout << 
"\nThyra::VectorDefaultBase<" 
  624               <<
">::apply(...) : y = beta*y + alpha*m*x  (x is a scalar!)\n";
 
  626       Vt_S( y.
ptr(), beta );
 
  627       Vp_StV( y.
ptr(), Scalar(alpha*get_ele(*x,0)), *this );
 
  629     else if( M_trans == 
CONJTRANS || (M_trans == 
TRANS && !ST::isComplex) ) {
 
  631 #ifdef THYRA_VECTOR_VERBOSE_TO_ERROR_OUT 
  632       THYRA_VECTOR_VERBOSE_OUT_STATEMENT;
 
  633       *dbgout << 
"\nThyra::VectorDefaultBase<" 
  635               <<
">::apply(...) : y = beta*y + alpha*m'*x  (y is a scalar!)\n";
 
  638       if( beta == ST::zero() ) {
 
  639         y_inout = ST::zero();
 
  642         y_inout = beta*get_ele(*y,0);
 
  644 #if defined(THYRA_VECTOR_VERBOSE_TO_ERROR_OUT) && defined(RTOPPACK_SPMD_APPLY_OP_DUMP) 
  645       RTOpPack::show_spmd_apply_op_dump = 
true;
 
  647 #if defined(THYRA_VECTOR_VERBOSE_TO_ERROR_OUT) && defined(RTOPPACK_RTOPT_HELPER_DUMP_OUTPUT) 
  648       RTOpPack::rtop_helpers_dump_all = 
true;
 
  650       y_inout += alpha * this->space()->scalarProd(*
this, *x);
 
  651 #if defined(THYRA_VECTOR_VERBOSE_TO_ERROR_OUT) && defined(RTOPPACK_SPMD_APPLY_OP_DUMP) 
  652       RTOpPack::show_spmd_apply_op_dump = 
false;
 
  654 #if defined(THYRA_VECTOR_VERBOSE_TO_ERROR_OUT) && defined(RTOPPACK_RTOPT_HELPER_DUMP_OUTPUT) 
  655       RTOpPack::rtop_helpers_dump_all = 
false;
 
  657       set_ele(0, y_inout, y.
ptr());
 
  658 #ifdef THYRA_VECTOR_VERBOSE_TO_ERROR_OUT 
  660         << 
"\nThyra::VectorDefaultBase<"<<ST::name()<<
">::apply(...) : y_inout = " 
  666         "VectorBase<"<<ST::name()<<
">::apply(M_trans,...): Error, M_trans=" 
  667         <<
toString(M_trans)<<
" not supported!" );
 
  678 template<
class Scalar>
 
  691 template<
class Scalar>
 
  693 void VectorDefaultBase<Scalar>::validateColIndexes(
 
  694   const ArrayView<const int>&cols )
 const 
  707 #endif  // THYRA_VECTOR_DEFAULT_BASE_DEF_HPP 
virtual Scalar dotImpl(const VectorBase< Scalar > &x) const 
Default implementation of dot using RTOps. 
RCP< MultiVectorBase< Scalar > > clone_mv() const 
Returns this->clone_v(). 
virtual RCP< MultiVectorBase< Scalar > > nonconstContigSubViewImpl(const Range1D &col_rng)
Returns Teuchos::rcp(this,false). 
bool is_null(const boost::shared_ptr< T > &p)
EOpTransp
Enumeration for determining how a linear operator is applied. `*. 
basic_OSTab< char > OSTab
virtual void acquireDetachedMultiVectorViewImpl(const Range1D &rowRng, const Range1D &colRng, RTOpPack::ConstSubMultiVectorView< Scalar > *sub_mv) const 
Implemented in terms of this->acquireDetachedView(). 
#define THYRA_ASSERT_LINEAR_OP_MULTIVEC_APPLY_SPACES(FUNC_NAME, M, M_T, X, Y)
This is a very useful macro that should be used to validate that the spaces for the multi-vector vers...
virtual std::string description() const 
Default description that gives the label, type, and dimenstion . 
virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const 
Generates a default outputting for all vectors. 
virtual void releaseDetachedVectorViewImpl(RTOpPack::ConstSubVectorView< Scalar > *sub_vec) const 
basic_FancyOStream< char > FancyOStream
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Use the non-transposed operator. 
T_To & dyn_cast(T_From &from)
virtual Teuchos::ScalarTraits< Scalar >::magnitudeType norm1Impl() const 
Default implementation of norm_1 using RTOps. 
virtual void eleWiseScaleImpl(const VectorBase< Scalar > &x)
Default implementation of ele_wise_scale using RTOps. 
virtual void reciprocalImpl(const VectorBase< Scalar > &x)
Default implementation of reciprocal using RTOps. 
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)...
const ArrayRCP< Scalar > values() const 
virtual Teuchos::ScalarTraits< Scalar >::magnitudeType norm2Impl() const 
Default implementation of norm_2 using RTOps. 
virtual void absImpl(const VectorBase< Scalar > &x)
Default implementation of abs using RTOps. 
RCP< VectorBase< Scalar > > clone_v() const 
Simply creates a new vector and copies the contents from *this. 
static std::string name()
Use the non-transposed operator with complex-conjugate elements (same as NOTRANS for real scalar type...
Ordinal globalOffset() const 
Use the transposed operator. 
virtual RCP< const VectorSpaceBase< Scalar > > range() const 
Returns this->space(). 
virtual RCP< const MultiVectorBase< Scalar > > nonContigSubViewImpl(const ArrayView< const int > &cols) const 
Returns Teuchos::rcp(this,false). 
const ArrayRCP< Scalar > values() const 
virtual void releaseDetachedMultiVectorViewImpl(RTOpPack::ConstSubMultiVectorView< Scalar > *sub_mv) const 
Implemented in terms of this->releaseDetachedView(). 
virtual void acquireNonconstDetachedMultiVectorViewImpl(const Range1D &rowRng, const Range1D &colRng, RTOpPack::SubMultiVectorView< Scalar > *sub_mv)
Implemented in terms of this->acquireDetachedView(). 
Convenient node subclass for concrete VectorBase subclasses that relies on a default MultiVectorBase ...
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Teuchos::Ordinal Ordinal
Type for the dimension of a vector space. `*. 
Interface for a collection of column vectors called a multi-vector. 
Teuchos_Ordinal subDim() const 
Returns the dimension of the explicit view. 
virtual RCP< VectorBase< Scalar > > nonconstColImpl(Ordinal j)
Returns Teuchos::rcp(this,false). 
void initialize(Ordinal globalOffset_in, Ordinal subDim_in, Ordinal colOffset_in, Ordinal numSubCols_in, const ArrayRCP< Scalar > &values_in, Ordinal leadingDim_in)
void initialize(Ordinal globalOffset_in, Ordinal subDim_in, const ArrayRCP< Scalar > &values_in, ptrdiff_t stride_in)
RCP< const VectorBase< Scalar > > col(Ordinal j) const 
Calls colImpl(). 
virtual std::string description() const 
Abstract interface for finite-dimensional dense vectors. 
TEUCHOSCORE_LIB_DLL_EXPORT std::string toString(const EVerbosityLevel verbLevel)
bool opSupportedImpl(EOpTransp M_trans) const 
For complex Scalar types returns true for NOTRANS and CONJTRANS and for real types returns true for a...
void applyImpl(const EOpTransp M_trans, const MultiVectorBase< Scalar > &X, const Ptr< MultiVectorBase< Scalar > > &Y, const Scalar alpha, const Scalar beta) const 
. Applies vector or its adjoint (transpose) as a linear operator. 
virtual RCP< const MultiVectorBase< Scalar > > contigSubViewImpl(const Range1D &col_rng) const 
Returns Teuchos::rcp(this,false). 
Ordinal globalOffset() const 
virtual void assignVecImpl(const VectorBase< Scalar > &x)
Default implementation of assign(vector) using RTOps. 
Teuchos::RCP< ReductTarget > reduct_obj_create() const
virtual void updateVecImpl(Scalar alpha, const VectorBase< Scalar > &x)
Default implementation of update using RTOps. 
virtual RCP< const VectorSpaceBase< Scalar > > domain() const =0
Return a smart pointer for the domain space for this operator. 
virtual Teuchos::ScalarTraits< Scalar >::magnitudeType normInfImpl() const 
Default implementation of norm_inf using RTOps. 
virtual RCP< const VectorSpaceBase< Scalar > > domain() const 
Returns a DefaultSerialVectorSpace object with dimension 1. 
virtual Teuchos::ScalarTraits< Scalar >::magnitudeType norm2WeightedImpl(const VectorBase< Scalar > &x) const 
Default implementation of norm_2 (weighted) using RTOps. 
virtual void acquireDetachedVectorViewImpl(const Range1D &rng, RTOpPack::ConstSubVectorView< Scalar > *sub_vec) const 
void initialize(Ordinal globalOffset_in, Ordinal subDim_in, Ordinal colOffset_in, Ordinal numSubCols_in, const ArrayRCP< const Scalar > &values_in, Ordinal leadingDim_in)
virtual void setSubVectorImpl(const RTOpPack::SparseSubVectorT< Scalar > &sub_vec)
virtual void commitNonconstDetachedMultiVectorViewImpl(RTOpPack::SubMultiVectorView< Scalar > *sub_mv)
Implemented in terms of this->commitDetachedView(). 
virtual void acquireNonconstDetachedVectorViewImpl(const Range1D &rng, RTOpPack::SubVectorView< Scalar > *sub_vec)
virtual void randomizeImpl(Scalar l, Scalar u)
Default implementation of randomize using RTOps. 
virtual RCP< MultiVectorBase< Scalar > > nonconstNonContigSubViewImpl(const ArrayView< const int > &cols)
Returns Teuchos::rcp(this,false). 
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
const ArrayRCP< const Scalar > values() const 
virtual void linearCombinationVecImpl(const ArrayView< const Scalar > &alpha, const ArrayView< const Ptr< const VectorBase< Scalar > > > &x, const Scalar &beta)
Default implementation of linear_combination using RTOps. 
virtual void commitNonconstDetachedVectorViewImpl(RTOpPack::SubVectorView< Scalar > *sub_vec)