本文整理汇总了C++中tpetra::MultiVector::get2dViewNonConst方法的典型用法代码示例。如果您正苦于以下问题:C++ MultiVector::get2dViewNonConst方法的具体用法?C++ MultiVector::get2dViewNonConst怎么用?C++ MultiVector::get2dViewNonConst使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tpetra::MultiVector
的用法示例。
在下文中一共展示了MultiVector::get2dViewNonConst方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void SingletonFilter<MatrixType>::CreateReducedRHSTempl(const Tpetra::MultiVector<DomainScalar,LocalOrdinal,GlobalOrdinal,Node>& LHS,
const Tpetra::MultiVector<RangeScalar,LocalOrdinal,GlobalOrdinal,Node>& RHS,
Tpetra::MultiVector<RangeScalar,LocalOrdinal,GlobalOrdinal,Node>& ReducedRHS)
{
Teuchos::ArrayRCP<Teuchos::ArrayRCP<const RangeScalar > > RHS_ptr = RHS.get2dView();
Teuchos::ArrayRCP<Teuchos::ArrayRCP<const DomainScalar> > LHS_ptr = LHS.get2dView();
Teuchos::ArrayRCP<Teuchos::ArrayRCP<RangeScalar> > ReducedRHS_ptr = ReducedRHS.get2dViewNonConst();
size_t NumVectors = LHS.getNumVectors();
for (size_t i = 0 ; i < NumRows_ ; ++i)
for (size_t k = 0 ; k < NumVectors ; ++k)
ReducedRHS_ptr[k][i] = RHS_ptr[k][InvReorder_[i]];
for (size_t i = 0 ; i < NumRows_ ; ++i) {
LocalOrdinal ii = InvReorder_[i];
size_t Nnz;
A_->getLocalRowCopy(ii,Indices_(),Values_(),Nnz);
for (size_t j = 0 ; j < Nnz ; ++j) {
if (Reorder_[Indices_[j]] == -1) {
for (size_t k = 0 ; k < NumVectors ; ++k)
ReducedRHS_ptr[k][i] -= (RangeScalar)Values_[j] * (RangeScalar)LHS_ptr[k][Indices_[j]];
}
}
}
}
示例2:
void ReorderFilter<MatrixType>::permuteOriginalToReorderedTempl(const Tpetra::MultiVector<DomainScalar,local_ordinal_type,global_ordinal_type,node_type> &originalX,
Tpetra::MultiVector<RangeScalar,local_ordinal_type,global_ordinal_type,node_type> &reorderedY) const
{
TEUCHOS_TEST_FOR_EXCEPTION(originalX.getNumVectors() != reorderedY.getNumVectors(), std::runtime_error,
"Ifpack2::ReorderFilter::permuteOriginalToReordered ERROR: X.getNumVectors() != Y.getNumVectors().");
Teuchos::ArrayRCP<Teuchos::ArrayRCP<const DomainScalar> > x_ptr = originalX.get2dView();
Teuchos::ArrayRCP<Teuchos::ArrayRCP<RangeScalar> > y_ptr = reorderedY.get2dViewNonConst();
for(size_t k=0; k < originalX.getNumVectors(); k++)
for(local_ordinal_type i=0; (size_t)i< originalX.getLocalLength(); i++)
y_ptr[k][perm_[i]] = (RangeScalar)x_ptr[k][i];
}
示例3: if
void ReorderFilter<MatrixType>::
apply (const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &X,
Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &Y,
Teuchos::ETransp mode,
scalar_type alpha,
scalar_type beta) const
{
typedef Teuchos::ScalarTraits<scalar_type> STS;
// Note: This isn't AztecOO compliant. But neither was Ifpack's version.
// Note: The localized maps mean the matvec is trivial (and has no import)
TEUCHOS_TEST_FOR_EXCEPTION(
X.getNumVectors() != Y.getNumVectors(), std::runtime_error,
"Ifpack2::ReorderFilter::apply: X.getNumVectors() != Y.getNumVectors().");
const scalar_type zero = STS::zero ();
Teuchos::ArrayRCP<Teuchos::ArrayRCP<const scalar_type> > x_ptr = X.get2dView();
Teuchos::ArrayRCP<Teuchos::ArrayRCP<scalar_type> > y_ptr = Y.get2dViewNonConst();
Y.putScalar (zero);
const size_t NumVectors = Y.getNumVectors ();
for (size_t i = 0; i < A_->getNodeNumRows (); ++i) {
size_t Nnz;
// Use this class's getrow to make the below code simpler
getLocalRowCopy (i, Indices_ (), Values_ (), Nnz);
if (mode == Teuchos::NO_TRANS) {
for (size_t j = 0; j < Nnz; ++j) {
for (size_t k = 0; k < NumVectors; ++k) {
y_ptr[k][i] += Values_[j] * x_ptr[k][Indices_[j]];
}
}
}
else if (mode == Teuchos::TRANS) {
for (size_t j = 0; j < Nnz; ++j) {
for (size_t k = 0; k < NumVectors; ++k) {
y_ptr[k][Indices_[j]] += Values_[j] * x_ptr[k][i];
}
}
}
else { //mode==Teuchos::CONJ_TRANS
for (size_t j = 0; j < Nnz; ++j) {
for (size_t k = 0; k < NumVectors; ++k) {
y_ptr[k][Indices_[j]] += STS::conjugate(Values_[j]) * x_ptr[k][i];
}
}
}
}
}
示例4: if
void SingletonFilter<MatrixType>::apply(const Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> &X,
Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> &Y,
Teuchos::ETransp mode,
Scalar alpha,
Scalar beta) const
{
// Note: This isn't AztecOO compliant. But neither was Ifpack's version.
TEUCHOS_TEST_FOR_EXCEPTION(X.getNumVectors() != Y.getNumVectors(), std::runtime_error,
"Ifpack2::SingletonFilter::apply ERROR: X.getNumVectors() != Y.getNumVectors().");
Scalar zero = Teuchos::ScalarTraits<Scalar>::zero();
Teuchos::ArrayRCP<Teuchos::ArrayRCP<const Scalar> > x_ptr = X.get2dView();
Teuchos::ArrayRCP<Teuchos::ArrayRCP<Scalar> > y_ptr = Y.get2dViewNonConst();
Y.putScalar(zero);
size_t NumVectors = Y.getNumVectors();
for (size_t i = 0 ; i < NumRows_ ; ++i) {
size_t Nnz;
// Use this class's getrow to make the below code simpler
getLocalRowCopy(i,Indices_(),Values_(),Nnz);
if (mode==Teuchos::NO_TRANS){
for (size_t j = 0 ; j < Nnz ; ++j)
for (size_t k = 0 ; k < NumVectors ; ++k)
y_ptr[k][i] += Values_[j] * x_ptr[k][Indices_[j]];
}
else if (mode==Teuchos::TRANS){
for (size_t j = 0 ; j < Nnz ; ++j)
for (size_t k = 0 ; k < NumVectors ; ++k)
y_ptr[k][Indices_[j]] += Values_[j] * x_ptr[k][i];
}
else { //mode==Teuchos::CONJ_TRANS
for (size_t j = 0 ; j < Nnz ; ++j)
for (size_t k = 0 ; k < NumVectors ; ++k)
y_ptr[k][Indices_[j]] += Teuchos::ScalarTraits<Scalar>::conjugate(Values_[j]) * x_ptr[k][i];
}
}
}
示例5: if
void
OverlappingRowMatrix<MatrixType>::
apply (const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &X,
Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &Y,
Teuchos::ETransp mode,
scalar_type alpha,
scalar_type beta) const
{
using Teuchos::ArrayRCP;
using Teuchos::as;
typedef scalar_type RangeScalar;
typedef scalar_type DomainScalar;
typedef Teuchos::ScalarTraits<RangeScalar> STRS;
TEUCHOS_TEST_FOR_EXCEPTION(
X.getNumVectors() != Y.getNumVectors(), std::runtime_error,
"Ifpack2::OverlappingRowMatrix::apply: The input X and the output Y must "
"have the same number of columns. X.getNumVectors() = "
<< X.getNumVectors() << " != Y.getNumVectors() = " << Y.getNumVectors()
<< ".");
// FIXME (mfh 13 July 2013) This would be a good candidate for a
// Kokkos local parallel operator implementation. That would
// obviate the need for getting views of the data and make the code
// below a lot simpler.
const RangeScalar zero = STRS::zero ();
ArrayRCP<ArrayRCP<const DomainScalar> > x_ptr = X.get2dView();
ArrayRCP<ArrayRCP<RangeScalar> > y_ptr = Y.get2dViewNonConst();
Y.putScalar(zero);
size_t NumVectors = Y.getNumVectors();
const size_t numMyRowsA = A_->getNodeNumRows ();
for (size_t i = 0; i < numMyRowsA; ++i) {
size_t Nnz;
// Use this class's getrow to make the below code simpler
A_->getLocalRowCopy (i, Indices_ (),Values_ (), Nnz);
if (mode == Teuchos::NO_TRANS) {
for (size_t j = 0; j < Nnz; ++j)
for (size_t k = 0; k < NumVectors; ++k)
y_ptr[k][i] += as<RangeScalar> (Values_[j]) *
as<RangeScalar> (x_ptr[k][Indices_[j]]);
}
else if (mode == Teuchos::TRANS){
for (size_t j = 0; j < Nnz; ++j)
for (size_t k = 0; k < NumVectors; ++k)
y_ptr[k][Indices_[j]] += as<RangeScalar> (Values_[j]) *
as<RangeScalar> (x_ptr[k][i]);
}
else { // mode == Teuchos::CONJ_TRANS
for (size_t j = 0; j < Nnz; ++j)
for (size_t k = 0; k < NumVectors; ++k)
y_ptr[k][Indices_[j]] +=
STRS::conjugate (as<RangeScalar> (Values_[j])) *
as<RangeScalar> (x_ptr[k][i]);
}
}
const size_t numMyRowsB = ExtMatrix_->getNodeNumRows ();
for (size_t i = 0 ; i < numMyRowsB ; ++i) {
size_t Nnz;
// Use this class's getrow to make the below code simpler
ExtMatrix_->getLocalRowCopy (i, Indices_ (), Values_ (), Nnz);
if (mode == Teuchos::NO_TRANS) {
for (size_t j = 0; j < Nnz; ++j)
for (size_t k = 0; k < NumVectors; ++k)
y_ptr[k][numMyRowsA+i] += as<RangeScalar> (Values_[j]) *
as<RangeScalar> (x_ptr[k][Indices_[j]]);
}
else if (mode == Teuchos::TRANS) {
for (size_t j = 0; j < Nnz; ++j)
for (size_t k = 0; k < NumVectors; ++k)
y_ptr[k][numMyRowsA+Indices_[j]] += as<RangeScalar> (Values_[j]) *
as<RangeScalar> (x_ptr[k][i]);
}
else { // mode == Teuchos::CONJ_TRANS
for (size_t j = 0; j < Nnz; ++j)
for (size_t k = 0; k < NumVectors; ++k)
y_ptr[k][numMyRowsA+Indices_[j]] +=
STRS::conjugate (as<RangeScalar> (Values_[j])) *
as<RangeScalar> (x_ptr[k][i]);
}
}
}