10#ifndef THYRA_DEFAULT_PRODUCT_VECTOR_SPACE_HPP 
   11#define THYRA_DEFAULT_PRODUCT_VECTOR_SPACE_HPP 
   14#include "Thyra_DefaultProductVectorSpace_decl.hpp" 
   15#include "Thyra_DefaultProductVector.hpp" 
   16#include "Thyra_DefaultProductMultiVector.hpp" 
   17#include "Thyra_ProductMultiVectorBase.hpp" 
   18#include "Teuchos_Workspace.hpp" 
   19#include "Teuchos_dyn_cast.hpp" 
   30  : numBlocks_(-1), dim_(-1), isInCore_(false)
 
 
   38  : numBlocks_(-1), dim_(-1)
 
 
   53  const int nBlocks = vecSpaces_in.size();
 
   57  bool overallHasInCoreView = 
true;
 
   58  for (
int k = 0; k < nBlocks; ++k) {
 
   61      vecSpaces_in[k].get() == NULL, std::invalid_argument
 
   62      ,
"Error, the smart pointer vecSpaces["<<k<<
"] can not be NULL!" 
   65    if (!vecSpaces_in[k]->hasInCoreView()) overallHasInCoreView = 
false;
 
   73  *vecSpaces_ = vecSpaces_in;
 
   75  (*vecSpacesOffsets_)[0] = 0;
 
   77  for( 
int k = 1; k <= nBlocks; ++k ) {
 
   78    const Ordinal dim_km1 = vecSpaces_in[k-1]->dim();
 
   79    (*vecSpacesOffsets_)[k] = (*vecSpacesOffsets_)[k-1] + dim_km1;
 
   82  isInCore_ = overallHasInCoreView;
 
 
  101template<
class Scalar>
 
  109    !(0 <= i && i < this->dim()), std::out_of_range
 
  110    ,
"VectorSpaceBlocked::get_vector_space_position(...): Error, i = " 
  111    << i << 
" is not in range [0,"<<(this->dim()-1)<<
"]" 
  114  *kth_vector_space  = 0;
 
  115  *kth_global_offset = 0;
 
  116  while( *kth_vector_space < numBlocks_ ) {
 
  117    const Ordinal off_kp1 = (*vecSpacesOffsets_)[*kth_vector_space+1];
 
  119      *kth_global_offset = (*vecSpacesOffsets_)[*kth_vector_space];
 
  122    ++(*kth_vector_space);
 
 
  131template<
class Scalar>
 
  138template<
class Scalar>
 
  143  return (*vecSpaces_)[k];
 
 
  150template<
class Scalar>
 
  157template<
class Scalar>
 
  162  using Teuchos::ptrFromRef;
 
  163  using Teuchos::ptr_dynamic_cast;
 
  165  const int nBlocks = this->numBlocks();
 
  169    ptr_dynamic_cast<const ProductVectorSpaceBase<Scalar> >(ptrFromRef(vecSpc));
 
  173    if( nBlocks != pvsb->numBlocks() )
 
  175    for( 
int i = 0; i < nBlocks; ++i ) {
 
  176      if( !this->getBlock(i)->isCompatible(*pvsb->getBlock(i)) )
 
  184    return this->getBlock(0)->isCompatible(vecSpc);
 
 
  194template<
class Scalar>
 
  198  return defaultProductVector<Scalar>(Teuchos::rcpFromRef(*
this));
 
 
  202template<
class Scalar>
 
  208  const int nBlocks = this->numBlocks(); 
 
  215    || nBlocks!=y.productSpace()->numBlocks()
 
  219  for( 
int k = 0; k < nBlocks; ++k )
 
  220    scalarProd_rtn += (*vecSpaces_)[k]->scalarProd(
 
  223  return scalarProd_rtn;
 
 
  227template<
class Scalar>
 
  245    scalarProds_out[0] = this->scalarProd(*X_in.
col(0),*Y_in.
col(0));
 
  250  const int nBlocks = this->numBlocks(); 
 
  257  Workspace<Scalar> _scalarProds_out(wss, m, 
false);
 
  258  std::fill( scalarProds_out.
begin(), scalarProds_out.
end(),
 
  260  for( 
int k = 0; k < nBlocks; ++k ) {
 
  261    (*vecSpaces_)[k]->scalarProds(
 
  263    for( 
int j = 0; j < m; ++j )
 
  264      scalarProds_out[j] += _scalarProds_out[j];
 
 
  269template<
class Scalar>
 
  272  const Range1D rng = full_range(rng_in,0,dim_-1);
 
  274  int    kth_vector_space  = -1;
 
  276  this->getVecSpcPoss(rng.
lbound(),&kth_vector_space,&kth_global_offset);
 
  280  if( rng.
lbound() + rng.
size() <= kth_global_offset + (*vecSpaces_)[kth_vector_space]->dim() ) {
 
  281    return (*vecSpaces_)[kth_vector_space]->hasInCoreView(rng_in-kth_global_offset,viewType,strideType);
 
 
  305template<
class Scalar>
 
  310    return (*vecSpaces_)[0]->smallVecSpcFcty(); 
 
 
  315template<
class Scalar>
 
  319  return defaultProductMultiVector<Scalar>(Teuchos::rcpFromRef(*
this),
 
 
  324template<
class Scalar>
 
  332    pvs = productVectorSpace<Scalar>();
 
  333  pvs->numBlocks_          = numBlocks_;
 
  334  pvs->vecSpaces_          = vecSpaces_;
 
  335  pvs->vecSpacesOffsets_   = vecSpacesOffsets_;
 
  337  pvs->isInCore_           = isInCore_;
 
 
  345template<
class Scalar>
 
  348  std::ostringstream oss;
 
  352    << 
",numBlocks="<<numBlocks_
 
 
  358template<
class Scalar>
 
  369    *out << this->description() << std::endl;
 
  373    *out <<  
"Constituent vector spaces V[0], V[1], ... V[numBlocks-1]:\n";
 
  375    for( 
int k = 0; k < numBlocks_; ++k ) {
 
  376      *out << 
"V["<<k<<
"] = " << Teuchos::describe(*(*vecSpaces_)[k],verbLevel);
 
 
virtual std::string description() const
 
DefaultProductVectorSpace()
Default construct to uninitialized.
 
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
Prints the details about the constituent vector spaces.
 
RCP< MultiVectorBase< Scalar > > createMembers(int numMembers) const
Returns a DefaultProductMultiVector object.
 
RCP< const VectorSpaceBase< Scalar > > getBlock(const int k) const
 
RCP< const VectorSpaceBase< Scalar > > clone() const
Clones the object as promised.
 
bool hasInCoreView(const Range1D &rng, const EViewType viewType, const EStrideType strideType) const
Returns true if all of the constituent vector spaces return true.
 
void getVecSpcPoss(Ordinal i, int *kth_vector_space, Ordinal *kth_global_offset) const
Get the position of the vector space object and its offset into a composite vector that owns the ith ...
 
std::string description() const
Prints just the name DefaultProductVectorSpace along with the overall dimension and the number of blo...
 
RCP< VectorBase< Scalar > > createMember() const
Returns a DefaultProductVector object.
 
virtual void initialize(const ArrayView< const RCP< const VectorSpaceBase< Scalar > > > &vecSpaces)
Initialize with a list of constituent vector spaces.
 
virtual void uninitialize(const ArrayView< RCP< const VectorSpaceBase< Scalar > > > &vecSpaces=Teuchos::null)
Uninitialize.
 
RCP< const VectorSpaceFactoryBase< Scalar > > smallVecSpcFcty() const
Returns getBlock(0)->smallVecSpcFcty().
 
bool isCompatible(const VectorSpaceBase< Scalar > &vecSpc) const
Returns true only if also a product vector space and all constituent vectors are compatible.
 
Ordinal dim() const
Returns the summation of the constituent vector spaces.
 
void scalarProdsImpl(const MultiVectorBase< Scalar > &X, const MultiVectorBase< Scalar > &Y, const ArrayView< Scalar > &scalarProds) const
Returns the sum of the scalar products of each of the columns of the constituent multi-vectors.
 
Scalar scalarProd(const VectorBase< Scalar > &x, const VectorBase< Scalar > &y) const
Returns the sum of the scalar products of the constituent vectors.
 
virtual RCP< const VectorSpaceBase< Scalar > > domain() const =0
Return a smart pointer for the domain space for this operator.
 
Interface for a collection of column vectors called a multi-vector.
 
RCP< const VectorBase< Scalar > > col(Ordinal j) const
Calls colImpl().
 
Base interface for product multi-vectors.
 
virtual Teuchos::RCP< const ProductVectorSpaceBase< Scalar > > productSpace() const =0
Returns the associated product vector space that represents the range.
 
virtual Teuchos::RCP< const MultiVectorBase< Scalar > > getMultiVectorBlock(const int k) const =0
Returns a non-persisting const view of the (zero-based) kth block multi-vector.
 
Base interface for product vectors.
 
virtual RCP< const VectorBase< Scalar > > getVectorBlock(const int k) const =0
Returns a non-persisting const view of the (zero-based) kth block vector.
 
Abstract interface for finite-dimensional dense vectors.
 
Abstract interface for objects that represent a space for vectors.
 
virtual Ordinal dim() const =0
Return the dimension of the vector space.
 
virtual bool isCompatible(const VectorSpaceBase< Scalar > &vecSpc) const =0
Compare the compatibility of two vector spaces.
 
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
 
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
 
#define TEUCHOS_ASSERT_EQUALITY(val1, val2)
 
EStrideType
Determine if data is unit stride or non-unit stride.
 
EViewType
Determines if a view is a direct view of data or a detached copy of data.
 
Teuchos::Ordinal Ordinal
Type for the dimension of a vector space. `*.
 
@ VIEW_TYPE_DIRECT
The view is a direct view of data and no copies are made.
 
TypeTo as(const TypeFrom &t)
 
T_To & dyn_cast(T_From &from)
 
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
 
TEUCHOSCORE_LIB_DLL_EXPORT Teuchos::RCP< WorkspaceStore > get_default_workspace_store()
 
TEUCHOSCORE_LIB_DLL_EXPORT bool includesVerbLevel(const EVerbosityLevel verbLevel, const EVerbosityLevel requestedVerbLevel, const bool isDefaultLevel=false)