本文整理汇总了C++中MultiVectorBase::range方法的典型用法代码示例。如果您正苦于以下问题:C++ MultiVectorBase::range方法的具体用法?C++ MultiVectorBase::range怎么用?C++ MultiVectorBase::range使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MultiVectorBase
的用法示例。
在下文中一共展示了MultiVectorBase::range方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createMembers
void LinearOpScalarProd<Scalar>::scalarProdsImpl(
const MultiVectorBase<Scalar>& X, const MultiVectorBase<Scalar>& Y,
const ArrayView<Scalar> &scalarProds_out
) const
{
Teuchos::RCP<MultiVectorBase<Scalar> >
T = createMembers(Y.range() ,Y.domain()->dim());
Thyra::apply(*op_, NOTRANS,Y, T.ptr());
dots(X, *T, scalarProds_out);
}
示例2: fmt
void SpmdMultiVectorSerializer<Scalar>::serialize(
const MultiVectorBase<Scalar>& mv, std::ostream& out
) const
{
Teuchos::RCP<const SpmdVectorSpaceBase<Scalar> >
mpi_vec_spc
= Teuchos::rcp_dynamic_cast<const SpmdVectorSpaceBase<Scalar> >(mv.range());
std::ios::fmtflags fmt(out.flags());
out.precision(std::numeric_limits<Scalar>::digits10+4);
if( mpi_vec_spc.get() ) {
// This is a mpi-based vector space so let's just write the local
// multi-vector elements (row-by-row).
const Ordinal
localOffset = mpi_vec_spc->localOffset(),
localSubDim = mpi_vec_spc->localSubDim();
const Range1D localRng( localOffset, localOffset+localSubDim-1 );
ConstDetachedMultiVectorView<Scalar> local_mv(mv,localRng,Range1D());
out << localSubDim << " " << local_mv.numSubCols() << std::endl;
if( binaryMode() ) {
// Write column-wise for better cache performance
for( Ordinal j = 0; j < local_mv.numSubCols(); ++j )
out.write( reinterpret_cast<const char*>(&local_mv(0,j)), sizeof(Scalar)*localSubDim );
}
else {
// Write row-wise for better readability
for( Ordinal i = 0; i < localSubDim; ++i ) {
out << " " << i;
for( Ordinal j = 0; j < local_mv.numSubCols(); ++j ) {
out << " " << local_mv(i,j);
}
out << std::endl;
}
}
}
else {
// This is a serial (or locally replicated) vector space so
// just write all of the multi-vector elements here.
TEUCHOS_TEST_FOR_EXCEPTION( true, std::logic_error, "Does not handle non-SPMD spaces yet" );
}
out.flags(fmt);
}
示例3: doExplicitMultiVectorAdjoint
void doExplicitMultiVectorAdjoint(
const MultiVectorBase<Scalar>& mvIn, MultiVectorBase<Scalar>* mvTransOut
)
{
typedef Teuchos::ScalarTraits<Scalar> ST;
#ifdef TEUCHOS_DEBUG
TEST_FOR_EXCEPT(0==mvTransOut);
THYRA_ASSERT_VEC_SPACES("doExplicitMultiVectorAdjoint(...)",
*mvIn.domain(), *mvTransOut->range()
);
THYRA_ASSERT_VEC_SPACES("doExplicitMultiVectorAdjoint(...)",
*mvIn.range(), *mvTransOut->domain()
);
#endif
ConstDetachedMultiVectorView<Scalar> dMvIn(mvIn);
DetachedMultiVectorView<Scalar> dMvTransOut(*mvTransOut);
const int m = dMvIn.subDim();
const int n = dMvIn.numSubCols();
for ( int j = 0; j < n; ++j ) {
for ( int i = 0; i < m; ++i ) {
dMvTransOut(j,i) = ST::conjugate(dMvIn(i,j));
}
}
}
示例4: totalTimer
SolveStatus<Scalar>
BelosLinearOpWithSolve<Scalar>::solveImpl(
const EOpTransp M_trans,
const MultiVectorBase<Scalar> &B,
const Ptr<MultiVectorBase<Scalar> > &X,
const Ptr<const SolveCriteria<Scalar> > solveCriteria
) const
{
TEUCHOS_FUNC_TIME_MONITOR("BelosLOWS");
using Teuchos::rcp;
using Teuchos::rcpFromRef;
using Teuchos::rcpFromPtr;
using Teuchos::FancyOStream;
using Teuchos::OSTab;
using Teuchos::describe;
typedef Teuchos::ScalarTraits<Scalar> ST;
typedef typename ST::magnitudeType ScalarMag;
Teuchos::Time totalTimer(""), timer("");
totalTimer.start(true);
assertSolveSupports(*this, M_trans, solveCriteria);
// 2010/08/22: rabartl: Bug 4915 ToDo: Move the above into the NIV function
// solve(...).
const int numRhs = B.domain()->dim();
const int numEquations = B.range()->dim();
const RCP<FancyOStream> out = this->getOStream();
const Teuchos::EVerbosityLevel verbLevel = this->getVerbLevel();
OSTab tab = this->getOSTab();
if (out.get() && static_cast<int>(verbLevel) > static_cast<int>(Teuchos::VERB_LOW)) {
*out << "\nStarting iterations with Belos:\n";
OSTab tab2(out);
*out << "Using forward operator = " << describe(*fwdOpSrc_->getOp(),verbLevel);
*out << "Using iterative solver = " << describe(*iterativeSolver_,verbLevel);
*out << "With #Eqns="<<numEquations<<", #RHSs="<<numRhs<<" ...\n";
}
//
// Set RHS and LHS
//
bool ret = lp_->setProblem( rcpFromPtr(X), rcpFromRef(B) );
TEST_FOR_EXCEPTION(
ret == false, CatastrophicSolveFailure
,"Error, the Belos::LinearProblem could not be set for the current solve!"
);
//
// Set the solution criteria
//
const RCP<Teuchos::ParameterList> tmpPL = Teuchos::parameterList();
SolveMeasureType solveMeasureType;
RCP<GeneralSolveCriteriaBelosStatusTest<Scalar> > generalSolveCriteriaBelosStatusTest;
if (nonnull(solveCriteria)) {
solveMeasureType = solveCriteria->solveMeasureType;
const ScalarMag requestedTol = solveCriteria->requestedTol;
if (solveMeasureType.useDefault()) {
tmpPL->set("Convergence Tolerance", defaultTol_);
}
else if (solveMeasureType(SOLVE_MEASURE_NORM_RESIDUAL, SOLVE_MEASURE_NORM_RHS)) {
if (requestedTol != SolveCriteria<Scalar>::unspecifiedTolerance()) {
tmpPL->set("Convergence Tolerance", requestedTol);
}
else {
tmpPL->set("Convergence Tolerance", defaultTol_);
}
tmpPL->set("Explicit Residual Scaling", "Norm of RHS");
}
else if (solveMeasureType(SOLVE_MEASURE_NORM_RESIDUAL, SOLVE_MEASURE_NORM_INIT_RESIDUAL)) {
if (requestedTol != SolveCriteria<Scalar>::unspecifiedTolerance()) {
tmpPL->set("Convergence Tolerance", requestedTol);
}
else {
tmpPL->set("Convergence Tolerance", defaultTol_);
}
tmpPL->set("Explicit Residual Scaling", "Norm of Initial Residual");
}
else {
// Set the most generic (and inefficient) solve criteria
generalSolveCriteriaBelosStatusTest = createGeneralSolveCriteriaBelosStatusTest(
*solveCriteria, convergenceTestFrequency_);
// Set the verbosity level (one level down)
generalSolveCriteriaBelosStatusTest->setOStream(out);
generalSolveCriteriaBelosStatusTest->setVerbLevel(incrVerbLevel(verbLevel, -1));
// Set the default convergence tolerance to always converged to allow
// the above status test to control things.
tmpPL->set("Convergence Tolerance", 1.0);
}
}
else {
// No solveCriteria was even passed in!
tmpPL->set("Convergence Tolerance", defaultTol_);
}
//
//.........这里部分代码省略.........
示例5: totalTimer
SolveStatus<Scalar>
BelosLinearOpWithSolve<Scalar>::solveImpl(
const EOpTransp M_trans,
const MultiVectorBase<Scalar> &B,
const Ptr<MultiVectorBase<Scalar> > &X,
const Ptr<const SolveCriteria<Scalar> > solveCriteria
) const
{
THYRA_FUNC_TIME_MONITOR("Stratimikos: BelosLOWS");
using Teuchos::rcp;
using Teuchos::rcpFromRef;
using Teuchos::rcpFromPtr;
using Teuchos::FancyOStream;
using Teuchos::OSTab;
using Teuchos::ParameterList;
using Teuchos::parameterList;
using Teuchos::describe;
typedef Teuchos::ScalarTraits<Scalar> ST;
typedef typename ST::magnitudeType ScalarMag;
Teuchos::Time totalTimer(""), timer("");
totalTimer.start(true);
assertSolveSupports(*this, M_trans, solveCriteria);
// 2010/08/22: rabartl: Bug 4915 ToDo: Move the above into the NIV function
// solve(...).
const RCP<FancyOStream> out = this->getOStream();
const Teuchos::EVerbosityLevel verbLevel = this->getVerbLevel();
OSTab tab = this->getOSTab();
if (out.get() && static_cast<int>(verbLevel) > static_cast<int>(Teuchos::VERB_LOW)) {
*out << "\nStarting iterations with Belos:\n";
OSTab tab2(out);
*out << "Using forward operator = " << describe(*fwdOpSrc_->getOp(),verbLevel);
*out << "Using iterative solver = " << describe(*iterativeSolver_,verbLevel);
*out << "With #Eqns="<<B.range()->dim()<<", #RHSs="<<B.domain()->dim()<<" ...\n";
}
//
// Set RHS and LHS
//
bool ret = lp_->setProblem( rcpFromPtr(X), rcpFromRef(B) );
TEUCHOS_TEST_FOR_EXCEPTION(
ret == false, CatastrophicSolveFailure
,"Error, the Belos::LinearProblem could not be set for the current solve!"
);
//
// Set the solution criteria
//
// Parameter list for the current solve.
const RCP<ParameterList> tmpPL = Teuchos::parameterList();
// The solver's valid parameter list.
RCP<const ParameterList> validPL = iterativeSolver_->getValidParameters();
SolveMeasureType solveMeasureType;
RCP<GeneralSolveCriteriaBelosStatusTest<Scalar> > generalSolveCriteriaBelosStatusTest;
if (nonnull(solveCriteria)) {
solveMeasureType = solveCriteria->solveMeasureType;
const ScalarMag requestedTol = solveCriteria->requestedTol;
if (solveMeasureType.useDefault()) {
tmpPL->set("Convergence Tolerance", defaultTol_);
}
else if (solveMeasureType(SOLVE_MEASURE_NORM_RESIDUAL, SOLVE_MEASURE_NORM_RHS)) {
if (requestedTol != SolveCriteria<Scalar>::unspecifiedTolerance()) {
tmpPL->set("Convergence Tolerance", requestedTol);
}
else {
tmpPL->set("Convergence Tolerance", defaultTol_);
}
setResidualScalingType (tmpPL, validPL, "Norm of RHS");
}
else if (solveMeasureType(SOLVE_MEASURE_NORM_RESIDUAL, SOLVE_MEASURE_NORM_INIT_RESIDUAL)) {
if (requestedTol != SolveCriteria<Scalar>::unspecifiedTolerance()) {
tmpPL->set("Convergence Tolerance", requestedTol);
}
else {
tmpPL->set("Convergence Tolerance", defaultTol_);
}
setResidualScalingType (tmpPL, validPL, "Norm of Initial Residual");
}
else {
// Set the most generic (and inefficient) solve criteria
generalSolveCriteriaBelosStatusTest = createGeneralSolveCriteriaBelosStatusTest(
*solveCriteria, convergenceTestFrequency_);
// Set the verbosity level (one level down)
generalSolveCriteriaBelosStatusTest->setOStream(out);
generalSolveCriteriaBelosStatusTest->setVerbLevel(incrVerbLevel(verbLevel, -1));
// Set the default convergence tolerance to always converged to allow
// the above status test to control things.
tmpPL->set("Convergence Tolerance", 1.0);
}
// maximum iterations
if (nonnull(solveCriteria->extraParameters)) {
if (Teuchos::isParameterType<int>(*solveCriteria->extraParameters,"Maximum Iterations")) {
tmpPL->set("Maximum Iterations", Teuchos::get<int>(*solveCriteria->extraParameters,"Maximum Iterations"));
//.........这里部分代码省略.........
示例6:
bool SpmdMultiVectorSerializer<Scalar>::isCompatible(
const MultiVectorBase<Scalar> &mv
) const
{
return 0!=dynamic_cast<const SpmdVectorSpaceBase<Scalar>*>(&*mv.range());
}