本文整理汇总了C++中Teuchos::outArg方法的典型用法代码示例。如果您正苦于以下问题:C++ Teuchos::outArg方法的具体用法?C++ Teuchos::outArg怎么用?C++ Teuchos::outArg使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Teuchos
的用法示例。
在下文中一共展示了Teuchos::outArg方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: validateRowRange
void SpmdMultiVectorBase<Scalar>::acquireNonconstDetachedMultiVectorViewImpl(
const Range1D &rowRng_in,
const Range1D &colRng_in,
RTOpPack::SubMultiVectorView<Scalar> *sub_mv
)
{
using Teuchos::outArg;
const Range1D rowRng = validateRowRange(rowRng_in);
const Range1D colRng = validateColRange(colRng_in);
if(
rowRng.lbound() < localOffset_
||
localOffset_+localSubDim_-1 < rowRng.ubound()
)
{
// rng consists of off-processor elements so use the default implementation!
MultiVectorDefaultBase<Scalar>::acquireNonconstDetachedMultiVectorViewImpl(
rowRng_in, colRng_in, sub_mv
);
return;
}
ArrayRCP<Scalar> localValues;
Ordinal leadingDim = 0;
this->getNonconstLocalData(outArg(localValues), outArg(leadingDim));
sub_mv->initialize(
rowRng.lbound() // globalOffset
,rowRng.size() // subDim
,colRng.lbound() // colOffset
,colRng.size() // numSubCols
,localValues
+(rowRng.lbound()-localOffset_)
+colRng.lbound()*leadingDim // values
,leadingDim // leadingDim
);
}
示例2: if
Teuchos::RCP<const Epetra_MultiVector>
Thyra::get_Epetra_MultiVector(
const Epetra_Map &map,
const MultiVectorBase<double> &mv
)
{
using Teuchos::rcpWithEmbeddedObj;
using Teuchos::rcpFromRef;
using Teuchos::outArg;
ArrayRCP<const double> mvData;
Ordinal mvLeadingDim = -1;
const SpmdMultiVectorBase<double> *mvSpmdMv = 0;
const SpmdVectorBase<double> *mvSpmdV = 0;
if ((mvSpmdMv = dynamic_cast<const SpmdMultiVectorBase<double>*>(&mv))) {
mvSpmdMv->getLocalData(outArg(mvData), outArg(mvLeadingDim));
}
else if ((mvSpmdV = dynamic_cast<const SpmdVectorBase<double>*>(&mv))) {
mvSpmdV->getLocalData(outArg(mvData));
mvLeadingDim = mvSpmdV->spmdSpace()->localSubDim();
}
if (nonnull(mvData)) {
return rcpWithEmbeddedObj(
new Epetra_MultiVector(
::View,map, const_cast<double*>(mvData.getRawPtr()), mvLeadingDim, mv.domain()->dim()
),
mvData
);
}
return ::Thyra::get_Epetra_MultiVector(map, rcpFromRef(mv));
}
示例3: iss
TEUCHOS_UNIT_TEST( Rythmos_StateSerializerStrategy, ScalarsAndInts ) {
std::string data;
{
std::ostringstream oss;
int i = -1;
double d = 31.4159e-1;
int k = 600;
XMLStateSerializerStrategy<double> ss;
ss.serializeInt(i,oss);
ss.serializeScalar(d,oss);
ss.serializeInt(k,oss);
data = oss.str();
}
{
std::istringstream iss(data);
int i = 0;
double d = 0.0;
XMLStateSerializerStrategy<double> ss;
ss.deSerializeInt(outArg(i),iss);
TEST_EQUALITY_CONST(i,-1);
ss.deSerializeScalar(outArg(d),iss);
TEST_EQUALITY_CONST(d,3.14159);
ss.deSerializeInt(outArg(i),iss);
TEST_EQUALITY_CONST(i,600);
}
}
示例4: gathervPrint
void
gathervPrint (std::ostream& out,
const std::string& s,
const Teuchos::Comm<int>& comm)
{
using Teuchos::ArrayRCP;
using Teuchos::CommRequest;
using Teuchos::ireceive;
using Teuchos::isend;
using Teuchos::outArg;
using Teuchos::RCP;
using Teuchos::wait;
const int myRank = comm.getRank ();
const int rootRank = 0;
if (myRank == rootRank) {
out << s; // Proc 0 prints its buffer first
}
const int numProcs = comm.getSize ();
const int sizeTag = 42;
const int msgTag = 43;
ArrayRCP<size_t> sizeBuf (1);
ArrayRCP<char> msgBuf; // to be resized later
RCP<CommRequest<int> > req;
for (int p = 1; p < numProcs; ++p) {
if (myRank == p) {
sizeBuf[0] = s.size ();
req = isend<int, size_t> (sizeBuf, rootRank, sizeTag, comm);
(void) wait<int> (comm, outArg (req));
const size_t msgSize = s.size ();
msgBuf.resize (msgSize + 1); // for the '\0'
std::copy (s.begin (), s.end (), msgBuf.begin ());
msgBuf[msgSize] = '\0';
req = isend<int, char> (msgBuf, rootRank, msgTag, comm);
(void) wait<int> (comm, outArg (req));
}
else if (myRank == rootRank) {
sizeBuf[0] = 0; // just a precaution
req = ireceive<int, size_t> (sizeBuf, p, sizeTag, comm);
(void) wait<int> (comm, outArg (req));
const size_t msgSize = sizeBuf[0];
msgBuf.resize (msgSize + 1); // for the '\0'
req = ireceive<int, char> (msgBuf, p, msgTag, comm);
(void) wait<int> (comm, outArg (req));
std::string msg (msgBuf.getRawPtr ());
out << msg;
}
}
}
示例5: computePoint
PointEval1D<Scalar>
computePoint(const MeritFunc1DBase<Scalar> &phi, const Scalar &alpha,
const bool compute_phi = true, const bool compute_Dphi = false)
{
using Teuchos::null;
using Teuchos::outArg;
PointEval1D<Scalar> p;
p.alpha = alpha;
phi.eval( alpha, compute_phi ? outArg(p.phi) : null ,
compute_Dphi ? outArg(p.Dphi) : null );
return p;
}
示例6: outArg
ReductTargetSerializer<Scalar>::ReductTargetSerializer(
const Teuchos::RCP<const RTOpT<Scalar> > &op
)
:op_(op.assert_not_null())
{
using Teuchos::outArg;
typedef typename RTOpT<Scalar>::primitive_value_type PrimitiveScalar;
op_->get_reduct_type_num_entries(
outArg(num_values_), outArg(num_indexes_), outArg(num_chars_) );
reduct_obj_ext_size_ =
serializedSize<PrimitiveScalar>(num_values_,num_indexes_,num_chars_);
}
示例7: rcp
int
Piro::Thyra::PerformOptiPackAnalysis(
::Thyra::ModelEvaluatorDefaultBase<double>& piroModel,
Teuchos::ParameterList& optipackParams,
Teuchos::ParameterList& globipackParams,
RCP< ::Thyra::VectorBase<double> >& p)
{
RCP<Teuchos::FancyOStream> out = Teuchos::VerboseObjectBase::getDefaultOStream();
#ifdef Piro_ENABLE_OptiPack
// First, Linesearch stuff
const RCP<GlobiPack::BrentsLineSearch<double> >
linesearch = GlobiPack::brentsLineSearch<double>();
const RCP<ParameterList> lsPL = rcp(&globipackParams, false);
linesearch->setParameterList(lsPL);
// Temporary Debug
*out << "\nCurrent LineSearch parameters" << endl;
lsPL->print(*out);
// Second, Optimization stuff
p = ::Thyra::createMember(piroModel.get_p_space(0));
RCP<const ::Thyra::VectorBase<double> > p_init = piroModel.getNominalValues().get_p(0);
::Thyra::copy(*p_init, p.ptr());
const RCP<OptiPack::NonlinearCG<double> > cgSolver =
OptiPack::nonlinearCG<double>(rcp(&piroModel,false), 0, 0, linesearch);
const RCP<ParameterList> pl = rcp(&optipackParams,false);
cgSolver->setParameterList(pl);
// Temporary Debug Info
*out << "\nCurrent nonlinearCG parameter list" << endl;
pl->print(*out);
// Solve the prob
double g_opt; // optimal value of the response
int numIters; // number of iteration taken
const OptiPack::NonlinearCGUtils::ESolveReturn solveResult =
cgSolver->doSolve( p.ptr(), outArg(g_opt),
null, null, null, outArg(numIters) );
return (int) solveResult;
#else
*out << "ERROR: Trilinos/Piro was not configured to include OptiPack analysis."
<< endl;
return 0; // should not fail tests
#endif
}
示例8: dot
Scalar
Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node,true>::
dot (const Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node,true>& a) const
{
using Teuchos::outArg;
using Teuchos::REDUCE_SUM;
using Teuchos::reduceAll;
TEUCHOS_TEST_FOR_EXCEPTION(
this->getGlobalLength () != a.getGlobalLength (), std::runtime_error,
"Tpetra::Vector::dots: Vectors do not have the same global length. "
"this->getGlobalLength() = " << this->getGlobalLength () << " != "
"a.getGlobalLength() = " << a.getGlobalLength () << ".");
#ifdef HAVE_TPETRA_DEBUG
TEUCHOS_TEST_FOR_EXCEPTION(
! this->getMap ()->isCompatible (*a.getMap ()), std::runtime_error,
"Tpetra::Vector::dots: Vectors do not have compatible Maps:" << std::endl
<< "this->getMap(): " << std::endl << * (this->getMap ())
<< "a.getMap(): " << std::endl << * (a.getMap ()) << std::endl);
#else
TEUCHOS_TEST_FOR_EXCEPTION(
this->getLocalLength () != a.getLocalLength (), std::runtime_error,
"Tpetra::Vector::dots: Vectors do not have the same local length.");
#endif
Scalar gbldot;
gbldot = MVT::Dot (this->lclMV_, a.lclMV_);
if (this->isDistributed ()) {
Scalar lcldot = gbldot;
reduceAll (*this->getMap ()->getComm (), REDUCE_SUM,
lcldot, outArg (gbldot));
}
return gbldot;
}
示例9: replaceCommWithSubset
Teuchos::RCP<const Map<LocalOrdinal,GlobalOrdinal,Kokkos::Compat::KokkosDeviceWrapperNode<DeviceType> > >
Map<LocalOrdinal,GlobalOrdinal,Kokkos::Compat::KokkosDeviceWrapperNode<DeviceType> >::
replaceCommWithSubset (const Teuchos::RCP<const Teuchos::Comm<int> >& newComm) const
{
using Teuchos::ArrayView;
using Teuchos::outArg;
using Teuchos::RCP;
using Teuchos::REDUCE_MIN;
using Teuchos::reduceAll;
typedef global_size_t GST;
typedef LocalOrdinal LO;
typedef GlobalOrdinal GO;
typedef Map<LO, GO, node_type> map_type;
// mfh 26 Mar 2013: The lazy way to do this is simply to recreate
// the Map by calling its ordinary public constructor, using the
// original Map's data. This only involves O(1) all-reduces over
// the new communicator, which in the common case only includes a
// small number of processes.
// Create the Map to return.
if (newComm.is_null ()) {
return Teuchos::null; // my process does not participate in the new Map
} else {
// Map requires that the index base equal the global min GID.
// Figuring out the global min GID requires a reduction over all
// processes in the new communicator. It could be that some (or
// even all) of these processes contain zero entries. (Recall
// that this method, unlike removeEmptyProcesses(), may remove
// an arbitrary subset of processes.) We deal with this by
// doing a min over the min GID on each process if the process
// has more than zero entries, or the global max GID, if that
// process has zero entries. If no processes have any entries,
// then the index base doesn't matter anyway.
const GO myMinGid = (this->getNodeNumElements () == 0) ?
this->getMaxAllGlobalIndex () : this->getMinGlobalIndex ();
GO newIndexBase = this->getInvalidGlobalIndex ();
reduceAll<int, GO> (*newComm, REDUCE_MIN, myMinGid, outArg (newIndexBase));
// Make Map's constructor compute the global number of indices.
const GST globalNumInds = Teuchos::OrdinalTraits<GST>::invalid ();
if (mapDevice_.initialized ()) {
Kokkos::View<const GO*, DeviceType> myGIDs =
mapDevice_.getMyGlobalIndices ();
return rcp (new map_type (globalNumInds, myGIDs, newIndexBase,
newComm, this->getNode ()));
}
else {
Kokkos::View<const GO*, host_mirror_device_type> myGidsHostView =
mapHost_.getMyGlobalIndices ();
ArrayView<const GO> myGidsArrayView (myGidsHostView.ptr_on_device (),
myGidsHostView.dimension_0 ());
return rcp (new map_type (globalNumInds, myGidsArrayView, newIndexBase,
newComm, this->getNode ()));
}
}
}
示例10:
typename Teuchos::ScalarTraits<Scalar>::magnitudeType Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node>::normInf() const {
using Teuchos::outArg;
typedef typename Teuchos::ScalarTraits<Scalar>::magnitudeType Mag;
Mag norm = MVT::NormInf(this->lclMV_);
if (this->isDistributed()) {
Mag lnorm = norm;
Teuchos::reduceAll(*this->getMap()->getComm(),Teuchos::REDUCE_MAX,lnorm,outArg(norm));
}
return norm;
}
示例11: p
void DiagonalROME<Scalar>::evalModelImpl(
const Thyra::ModelEvaluatorBase::InArgs<Scalar>& inArgs,
const Thyra::ModelEvaluatorBase::OutArgs<Scalar>& outArgs
) const
{
using Teuchos::as;
using Teuchos::outArg;
typedef Teuchos::ScalarTraits<Scalar> ST;
using Thyra::get_mv;
using Thyra::ConstDetachedSpmdVectorView;
using Thyra::DetachedSpmdVectorView;
typedef Thyra::Ordinal Ordinal;
typedef Thyra::ModelEvaluatorBase MEB;
typedef MEB::DerivativeMultiVector<Scalar> DMV;
const ConstDetachedSpmdVectorView<Scalar> p(inArgs.get_p(0));
const ConstDetachedSpmdVectorView<Scalar> ps(ps_);
const ConstDetachedSpmdVectorView<Scalar> diag(diag_);
const ConstDetachedSpmdVectorView<Scalar> s_bar(s_bar_);
// g(p)
if (!is_null(outArgs.get_g(0))) {
Scalar g_val = ST::zero();
for (Ordinal i = 0; i < p.subDim(); ++i) {
const Scalar p_ps = p[i] - ps[i];
g_val += diag[i] * p_ps*p_ps;
if (nonlinearTermFactor_ != ST::zero()) {
g_val += nonlinearTermFactor_ * p_ps * p_ps * p_ps;
}
}
Scalar global_g_val;
Teuchos::reduceAll<Ordinal, Scalar>(*comm_, Teuchos::REDUCE_SUM,
g_val, outArg(global_g_val) );
DetachedSpmdVectorView<Scalar>(outArgs.get_g(0))[0] =
as<Scalar>(0.5) * global_g_val + g_offset_;
}
// DgDp[i]
if (!outArgs.get_DgDp(0,0).isEmpty()) {
const RCP<Thyra::MultiVectorBase<Scalar> > DgDp_trans_mv =
get_mv<Scalar>(outArgs.get_DgDp(0,0), "DgDp^T", MEB::DERIV_TRANS_MV_BY_ROW);
const DetachedSpmdVectorView<Scalar> DgDp_grad(DgDp_trans_mv->col(0));
for (Thyra::Ordinal i = 0; i < p.subDim(); ++i) {
const Scalar p_ps = p[i] - ps[i];
Scalar DgDp_grad_i = diag[i] * p_ps;
if (nonlinearTermFactor_ != ST::zero()) {
DgDp_grad_i += as<Scalar>(1.5) * nonlinearTermFactor_ * p_ps * p_ps;
}
DgDp_grad[i] = DgDp_grad_i / s_bar[i];
}
}
}
示例12: isCompatible
bool IfpackPreconditionerFactory::isCompatible(
const LinearOpSourceBase<double> &fwdOpSrc
) const
{
using Teuchos::outArg;
Teuchos::RCP<const Epetra_Operator> epetraFwdOp;
EOpTransp epetraFwdOpTransp;
EApplyEpetraOpAs epetraFwdOpApplyAs;
EAdjointEpetraOp epetraFwdOpAdjointSupport;
double epetraFwdOpScalar;
epetraFwdOpViewExtractor_->getEpetraOpView(
fwdOpSrc.getOp(),
outArg(epetraFwdOp), outArg(epetraFwdOpTransp),
outArg(epetraFwdOpApplyAs), outArg(epetraFwdOpAdjointSupport),
outArg(epetraFwdOpScalar)
);
if( !dynamic_cast<const Epetra_RowMatrix*>(&*epetraFwdOp) )
return false;
return true;
}
示例13: isCompatible
bool DiagonalEpetraLinearOpWithSolveFactory::isCompatible(
const LinearOpSourceBase<double> &fwdOpSrc
) const
{
using Teuchos::outArg;
RCP<const LinearOpBase<double> >
fwdOp = fwdOpSrc.getOp();
const EpetraLinearOpBase *eFwdOp = NULL;
if( ! (eFwdOp = dynamic_cast<const EpetraLinearOpBase*>(&*fwdOp)) )
return false;
RCP<const Epetra_Operator> epetraFwdOp;
EOpTransp epetraFwdOpTransp;
EApplyEpetraOpAs epetraFwdOpApplyAs;
EAdjointEpetraOp epetraFwdOpAdjointSupport;
eFwdOp->getEpetraOpView(outArg(epetraFwdOp), outArg(epetraFwdOpTransp),
outArg(epetraFwdOpApplyAs), outArg(epetraFwdOpAdjointSupport) );
if( !dynamic_cast<const Epetra_RowMatrix*>(&*epetraFwdOp) )
return false;
return true;
}
示例14: computeGlobalDim
Ordinal SpmdVectorSpaceUtilities::computeGlobalDim(
const Teuchos::Comm<Ordinal> &comm, const Ordinal localSubDim
)
{
using Teuchos::outArg;
using Teuchos::REDUCE_SUM;
using Teuchos::reduceAll;
Ordinal globalDim = -1;
reduceAll<Ordinal, Ordinal> (comm, REDUCE_SUM, localSubDim, outArg (globalDim));
return globalDim;
}
示例15: computeLocalOffset
Ordinal SpmdVectorSpaceUtilities::computeLocalOffset(
const Teuchos::Comm<Ordinal> &comm, const Ordinal localSubDim
)
{
using Teuchos::outArg;
using Teuchos::REDUCE_SUM;
using Teuchos::scan;
Ordinal localOffset;
const Ordinal _localOffset = localSubDim;
scan<Ordinal, Ordinal> (comm, REDUCE_SUM, _localOffset, outArg (localOffset));
localOffset -= localSubDim;
return localOffset;
}