RCP<const MultiVectorBase<Scalar> > DefaultSpmdVectorSpace<Scalar>::createMembersView( const RTOpPack::ConstSubMultiVectorView<Scalar> &raw_mv ) const { #ifdef TEUCHOS_DEBUG TEUCHOS_TEST_FOR_EXCEPT( localSubDim_ != raw_mv.subDim() ); #endif return Teuchos::rcp( new DefaultSpmdMultiVector<Scalar>( weakSelfPtr_.create_strong(), Teuchos::rcp_dynamic_cast<const ScalarProdVectorSpaceBase<Scalar> >( this->smallVecSpcFcty()->createVecSpc(raw_mv.numSubCols()),true), Teuchos::arcp( const_cast<Scalar*>(raw_mv.values().get()), 0,raw_mv.leadingDim()*raw_mv.numSubCols(),false), raw_mv.leadingDim() ) ); }
TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( SpmdLocalDataAccess, getLocalSubMultiVectorView_empty_p0, Scalar ) { typedef typename ScalarTraits<Scalar>::magnitudeType ScalarMag; const RCP<const DefaultSpmdVectorSpace<Scalar> > vs = createZeroEleProcVS<Scalar>(g_localDim); const RCP<const Teuchos::Comm<Ordinal> > comm = vs->getComm(); const int procRank = comm->getRank(); PRINT_VAR(procRank); const int numProcs = comm->getSize(); PRINT_VAR(numProcs); const RCP<MultiVectorBase<Scalar> > mv = createMembers<Scalar>(vs, g_numCols); const Scalar val = as<Scalar>(1.5); PRINT_VAR(val); assign<Scalar>(mv.ptr(), val); out << "*** Test that we get the view correctly including an empty view on p0 ...\n"; RTOpPack::ConstSubMultiVectorView<Scalar> lsmv = getLocalSubMultiVectorView<Scalar>(mv); if (procRank == 0) { TEST_EQUALITY_CONST(lsmv.globalOffset(), 0); TEST_EQUALITY_CONST(lsmv.subDim(), 0); TEST_EQUALITY_CONST(lsmv.values(), null); } else { TEST_EQUALITY(lsmv.globalOffset(), as<Ordinal>((procRank-1)*g_localDim)); TEST_EQUALITY(lsmv.subDim(), g_localDim); } TEST_EQUALITY(lsmv.leadingDim(), lsmv.subDim()); TEST_EQUALITY_CONST(lsmv.colOffset(), 0); TEST_EQUALITY(lsmv.numSubCols(), g_numCols); for (int i = 0; i < lsmv.subDim(); ++i) { for (int j = 0; j < lsmv.numSubCols(); ++j) { TEST_EQUALITY(lsmv(i,j), val); } } }