43 #ifndef IFPACK2_DETAILS_MULTIVECTORLOCALGATHERSCATTER_HPP
44 #define IFPACK2_DETAILS_MULTIVECTORLOCALGATHERSCATTER_HPP
50 #include "Tpetra_MultiVector.hpp"
51 #include "Tpetra_Map.hpp"
84 template<
class MV_in,
class MV_out>
87 typedef typename MV_in::scalar_type InScalar;
88 typedef typename MV_out::scalar_type OutScalar;
89 typedef typename MV_in::local_ordinal_type LO;
90 typedef typename MV_in::global_ordinal_type GO;
91 typedef typename MV_in::node_type NO;
97 gather (MV_out& X_out,
102 const size_t numRows = X_out.getLocalLength ();
103 const size_t numVecs = X_in.getNumVectors ();
104 for (
size_t j = 0; j < numVecs; ++j) {
105 ArrayRCP<const InScalar> X_in_j = X_in.getData(j);
106 ArrayRCP<OutScalar> X_out_j = X_out.getDataNonConst(j);
107 for (
size_t i = 0; i < numRows; ++i) {
108 const size_t i_perm = perm[i];
109 X_out_j[i] = X_in_j[i_perm];
115 scatter (MV_in& X_in,
120 const size_t numRows = X_out.getLocalLength();
121 const size_t numVecs = X_in.getNumVectors();
122 for (
size_t j = 0; j < numVecs; ++j) {
123 ArrayRCP<InScalar> X_in_j = X_in.getDataNonConst(j);
124 ArrayRCP<const OutScalar> X_out_j = X_out.getData(j);
125 for (
size_t i = 0; i < numRows; ++i) {
126 const size_t i_perm = perm[i];
127 X_in_j[i_perm] = X_out_j[i];
135 template<
typename InView,
typename OutView>
136 void gatherViewToView(OutView& X_out,
141 for(
size_t j = 0; j < X_out.extent(1); ++j) {
142 for(
size_t i = 0; i < X_out.extent(0); ++i) {
143 const LO i_perm = perm[i];
144 X_out(i, j) = X_in(i_perm, j);
149 template<
typename InView,
typename OutView>
150 void scatterViewToView(InView& X_in,
154 for(
size_t j = 0; j < X_out.extent(1); ++j) {
155 for(
size_t i = 0; i < X_out.extent(0); ++i) {
156 const LO i_perm = perm[i];
157 X_in(i_perm, j) = X_out(i, j);
165 template<
typename InView>
166 void gatherMVtoView(MV_out& X_out,
171 for(
size_t j = 0; j < X_out.getNumVectors(); ++j) {
173 for(
size_t i = 0; i < X_out.getLocalLength(); ++i) {
174 const LO i_perm = perm[i];
175 X_out_j[i] = X_in(i_perm, j);
180 template<
typename InView>
181 void scatterMVtoView(InView& X_in,
185 for(
size_t j = 0; j < X_in.extent(1); ++j) {
187 for(
size_t i = 0; i < X_out.getLocalLength(); ++i) {
188 const LO i_perm = perm[i];
189 X_in(i_perm, j) = X_out_j[i];
198 #endif // IFPACK2_DETAILS_MULTIVECTORLOCALGATHERSCATTER_HPP
Implementation detail of Ifpack2::Container subclasses.
Definition: Ifpack2_Details_MultiVectorLocalGatherScatter.hpp:85