Ifpack2 Templated Preconditioning Package Version 1.0
Ifpack2_ReorderFilter_def.hpp
00001 /*@HEADER
00002 // ***********************************************************************
00003 //
00004 //       Ifpack2: Tempated Object-Oriented Algebraic Preconditioner Package
00005 //                 Copyright (2009) Sandia Corporation
00006 //
00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00008 // license for use of this work by or on behalf of the U.S. Government.
00009 //
00010 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions are
00012 // met:
00013 //
00014 // 1. Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 //
00017 // 2. Redistributions in binary form must reproduce the above copyright
00018 // notice, this list of conditions and the following disclaimer in the
00019 // documentation and/or other materials provided with the distribution.
00020 //
00021 // 3. Neither the name of the Corporation nor the names of the
00022 // contributors may be used to endorse or promote products derived from
00023 // this software without specific prior written permission.
00024 //
00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 //
00037 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
00038 //
00039 // ***********************************************************************
00040 //@HEADER
00041 */
00042 
00043 #ifndef IFPACK2_REORDERFILTER_DEF_HPP
00044 #define IFPACK2_REORDERFILTER_DEF_HPP
00045 #include "Ifpack2_ReorderFilter_decl.hpp"
00046 #include <vector>
00047 
00048 #include "Tpetra_ConfigDefs.hpp"
00049 #include "Tpetra_RowMatrix.hpp"
00050 #include "Tpetra_Map.hpp"
00051 #include "Tpetra_MultiVector.hpp"
00052 #include "Tpetra_Vector.hpp"
00053 
00054 namespace Ifpack2 {
00055 
00056 template<class MatrixType>
00057 ReorderFilter<MatrixType>::
00058 ReorderFilter (const Teuchos::RCP<const row_matrix_type>& A,
00059                const Teuchos::ArrayRCP<local_ordinal_type>& perm,
00060                const Teuchos::ArrayRCP<local_ordinal_type>& reverseperm)
00061   : A_ (A),
00062     perm_ (perm),
00063     reverseperm_ (reverseperm)
00064 {
00065   TEUCHOS_TEST_FOR_EXCEPTION(
00066     A_.is_null (), std::invalid_argument,
00067     "Ifpack2::ReorderFilter: The input matrix is null.");
00068 
00069   // use this filter only on serial matrices
00070   TEUCHOS_TEST_FOR_EXCEPTION(
00071     A_->getComm()->getSize() != 1, std::invalid_argument,
00072     "Ifpack2::ReorderFilter: This class may only be used if the input matrix's "
00073     "communicator has one process.  This class is an implementation detail of "
00074     "Ifpack2::AdditiveSchwarz, and it is not meant to be used otherwise.");
00075 
00076   TEUCHOS_TEST_FOR_EXCEPTION(
00077     A_->getNodeNumRows () != A_->getGlobalNumRows (),
00078     std::invalid_argument,
00079     "Ifpack2::ReorderFilter: The input matrix is not square.");
00080 
00081   // Temp arrays for apply
00082   Indices_.resize (A_->getNodeMaxNumRowEntries ());
00083   Values_.resize (A_->getNodeMaxNumRowEntries ());
00084 }
00085 
00086 
00087 template<class MatrixType>
00088 ReorderFilter<MatrixType>::~ReorderFilter() {}
00089 
00090 
00091 template<class MatrixType>
00092 Teuchos::RCP<const Teuchos::Comm<int> > ReorderFilter<MatrixType>::getComm() const
00093 {
00094   return A_->getComm();
00095 }
00096 
00097 
00098 template<class MatrixType>
00099 Teuchos::RCP<typename ReorderFilter<MatrixType>::node_type>
00100 ReorderFilter<MatrixType>::getNode () const
00101 {
00102   return A_->getNode ();
00103 }
00104 
00105 
00106 template<class MatrixType>
00107 Teuchos::RCP<const typename ReorderFilter<MatrixType>::map_type>
00108 ReorderFilter<MatrixType>::getRowMap() const
00109 {
00110   TEUCHOS_TEST_FOR_EXCEPTION(
00111     A_.is_null (), std::runtime_error, "Ifpack2::ReorderFilter::"
00112     "getRowMap: The matrix A is null, so there is no row Map.");
00113 
00114   return A_->getRowMap ();
00115 }
00116 
00117 
00118 template<class MatrixType>
00119 Teuchos::RCP<const typename ReorderFilter<MatrixType>::map_type>
00120 ReorderFilter<MatrixType>::getColMap() const
00121 {
00122   TEUCHOS_TEST_FOR_EXCEPTION(
00123     A_.is_null (), std::runtime_error, "Ifpack2::ReorderFilter::"
00124     "getColMap: The matrix A is null, so there is no column Map.");
00125 
00126   return A_->getColMap();
00127 }
00128 
00129 
00130 template<class MatrixType>
00131 Teuchos::RCP<const typename ReorderFilter<MatrixType>::map_type>
00132 ReorderFilter<MatrixType>::getDomainMap() const
00133 {
00134   TEUCHOS_TEST_FOR_EXCEPTION(
00135     A_.is_null (), std::runtime_error, "Ifpack2::ReorderFilter::"
00136     "getDomainMap: The matrix A is null, so there is no domain Map.");
00137 
00138   return A_->getDomainMap();
00139 }
00140 
00141 
00142 template<class MatrixType>
00143 Teuchos::RCP<const typename ReorderFilter<MatrixType>::map_type>
00144 ReorderFilter<MatrixType>::getRangeMap() const
00145 {
00146   TEUCHOS_TEST_FOR_EXCEPTION(
00147     A_.is_null (), std::runtime_error, "Ifpack2::ReorderFilter::"
00148     "getRangeMap: The matrix A is null, so there is no range Map.");
00149 
00150   return A_->getRangeMap();
00151 }
00152 
00153 
00154 template<class MatrixType>
00155 Teuchos::RCP<const Tpetra::RowGraph<typename MatrixType::local_ordinal_type,
00156                                     typename MatrixType::global_ordinal_type,
00157                                     typename MatrixType::node_type> >
00158 ReorderFilter<MatrixType>::getGraph() const
00159 {
00160   throw std::runtime_error("Ifpack2::ReorderFilter: does not support getGraph.");
00161 }
00162 
00163 
00164 template<class MatrixType>
00165 global_size_t ReorderFilter<MatrixType>::getGlobalNumRows() const
00166 {
00167   return A_->getGlobalNumRows();
00168 }
00169 
00170 
00171 template<class MatrixType>
00172 global_size_t ReorderFilter<MatrixType>::getGlobalNumCols() const
00173 {
00174   return A_->getGlobalNumCols();
00175 }
00176 
00177 
00178 template<class MatrixType>
00179 size_t ReorderFilter<MatrixType>::getNodeNumRows() const
00180 {
00181   return A_->getNodeNumRows();
00182 }
00183 
00184 
00185 template<class MatrixType>
00186 size_t ReorderFilter<MatrixType>::getNodeNumCols() const
00187 {
00188   return A_->getNodeNumCols();
00189 }
00190 
00191 
00192 template<class MatrixType>
00193 typename MatrixType::global_ordinal_type ReorderFilter<MatrixType>::getIndexBase() const
00194 {
00195   return A_->getIndexBase();
00196 }
00197 
00198 
00199 template<class MatrixType>
00200 global_size_t ReorderFilter<MatrixType>::getGlobalNumEntries() const
00201 {
00202   return A_->getGlobalNumEntries();
00203 }
00204 
00205 
00206 template<class MatrixType>
00207 size_t ReorderFilter<MatrixType>::getNodeNumEntries() const
00208 {
00209   return A_->getNodeNumEntries();
00210 }
00211 
00212 
00213 template<class MatrixType>
00214 size_t ReorderFilter<MatrixType>::
00215 getNumEntriesInGlobalRow (global_ordinal_type globalRow) const
00216 {
00217   typedef Teuchos::OrdinalTraits<local_ordinal_type> OTLO;
00218   typedef Teuchos::OrdinalTraits<size_t> OTS;
00219 
00220   const local_ordinal_type localRow = A_->getRowMap ()->getLocalElement (globalRow);
00221   if (localRow == OTLO::invalid ()) {
00222     return OTS::invalid ();
00223   } else {
00224     return this->getNumEntriesInLocalRow (localRow);
00225   }
00226 }
00227 
00228 
00229 template<class MatrixType>
00230 size_t ReorderFilter<MatrixType>::
00231 getNumEntriesInLocalRow (local_ordinal_type localRow) const
00232 {
00233   // Make sure that localRow is in bounds before using it to index
00234   // into the permutation.
00235   if (A_->getRowMap ()->isNodeLocalElement (localRow)) {
00236     // localRow is a valid index into reverseperm_.
00237     const local_ordinal_type localReorderedRow = reverseperm_[localRow];
00238     return A_->getNumEntriesInLocalRow (localReorderedRow);
00239   } else {
00240     return Teuchos::OrdinalTraits<size_t>::invalid ();
00241   }
00242 }
00243 
00244 
00245 template<class MatrixType>
00246 global_size_t ReorderFilter<MatrixType>::getGlobalNumDiags() const
00247 {
00248   return A_->getGlobalNumDiags();
00249 }
00250 
00251 
00252 template<class MatrixType>
00253 size_t ReorderFilter<MatrixType>::getNodeNumDiags() const
00254 {
00255   return A_->getNodeNumDiags();
00256 }
00257 
00258 
00259 template<class MatrixType>
00260 size_t ReorderFilter<MatrixType>::getGlobalMaxNumRowEntries() const
00261 {
00262   return A_->getGlobalMaxNumRowEntries();
00263 }
00264 
00265 
00266 template<class MatrixType>
00267 size_t ReorderFilter<MatrixType>::getNodeMaxNumRowEntries() const
00268 {
00269   return A_->getNodeMaxNumRowEntries();
00270 }
00271 
00272 
00273 template<class MatrixType>
00274 bool ReorderFilter<MatrixType>::hasColMap() const
00275 {
00276   return true;
00277 }
00278 
00279 
00280 template<class MatrixType>
00281 bool ReorderFilter<MatrixType>::isLowerTriangular() const
00282 {
00283   return A_->isLowerTriangular();
00284 }
00285 
00286 
00287 template<class MatrixType>
00288 bool ReorderFilter<MatrixType>::isUpperTriangular() const
00289 {
00290   return A_->isUpperTriangular();
00291 }
00292 
00293 
00294 template<class MatrixType>
00295 bool ReorderFilter<MatrixType>::isLocallyIndexed() const
00296 {
00297   return A_->isLocallyIndexed();
00298 }
00299 
00300 
00301 template<class MatrixType>
00302 bool ReorderFilter<MatrixType>::isGloballyIndexed() const
00303 {
00304   return A_->isGloballyIndexed();
00305 }
00306 
00307 
00308 template<class MatrixType>
00309 bool ReorderFilter<MatrixType>::isFillComplete() const
00310 {
00311   return A_->isFillComplete();
00312 }
00313 
00314 
00315 template<class MatrixType>
00316 void ReorderFilter<MatrixType>::
00317 getGlobalRowCopy (global_ordinal_type globalRow,
00318                   const Teuchos::ArrayView<global_ordinal_type>& globalInd,
00319                   const Teuchos::ArrayView<scalar_type>& val,
00320                   size_t& numEntries) const
00321 {
00322   using Teuchos::Array;
00323   using Teuchos::ArrayView;
00324   using Teuchos::av_reinterpret_cast;
00325   typedef local_ordinal_type LO;
00326   typedef global_ordinal_type GO;
00327   typedef Teuchos::OrdinalTraits<LO> OTLO;
00328 
00329   const map_type& rowMap = * (A_->getRowMap ());
00330   const local_ordinal_type localRow = rowMap.getLocalElement (globalRow);
00331   TEUCHOS_TEST_FOR_EXCEPTION(
00332     localRow == OTLO::invalid (), std::invalid_argument, "Ifpack2::Reorder"
00333     "Filter::getGlobalRowCopy: The given global row index " << globalRow
00334     << " is not owned by the calling process with rank "
00335     << rowMap.getComm ()->getRank () << ".");
00336 
00337   if (sizeof (GO) == sizeof (LO)) {
00338     // This means we can convert local to global in place.
00339     ArrayView<LO> localInd = av_reinterpret_cast<LO> (globalInd);
00340     this->getLocalRowCopy (localRow, localInd, val, numEntries);
00341 
00342     // Convert local indices back to global indices.
00343     for (size_t k = 0; k < numEntries; ++k) {
00344       globalInd[k] = rowMap.getGlobalElement (localInd[k]);
00345     }
00346   }
00347   else {
00348     // LO and GO have different sizes, so we need a temp array
00349     // for converting local to global.
00350     numEntries = this->getNumEntriesInLocalRow (localRow);
00351     Array<LO> localInd (numEntries);
00352     this->getLocalRowCopy (localRow, localInd, val, numEntries);
00353 
00354     // Convert local indices back to global indices.
00355     for (size_t k = 0; k < numEntries; ++k) {
00356       globalInd[k] = rowMap.getGlobalElement (localInd[k]);
00357     }
00358   }
00359 }
00360 
00361 
00362 template<class MatrixType>
00363 void ReorderFilter<MatrixType>::
00364 getLocalRowCopy (local_ordinal_type LocalRow,
00365                  const Teuchos::ArrayView<local_ordinal_type> &Indices,
00366                  const Teuchos::ArrayView<scalar_type> &Values,
00367                  size_t &NumEntries) const
00368 {
00369   TEUCHOS_TEST_FOR_EXCEPTION(
00370     ! A_->getRowMap ()->isNodeLocalElement (LocalRow),
00371     std::invalid_argument,
00372     "Ifpack2::ReorderFilter::getLocalRowCopy: The given local row index "
00373     << LocalRow << " is not a valid local row index on the calling process "
00374     "with rank " << A_->getRowMap ()->getComm ()->getRank () << ".");
00375 
00376   const size_t numEntries = A_->getNumEntriesInLocalRow (LocalRow);
00377 
00378   TEUCHOS_TEST_FOR_EXCEPTION(
00379     static_cast<size_t> (Indices.size ()) < numEntries ||
00380     static_cast<size_t> (Values.size ()) < numEntries,
00381     std::invalid_argument,
00382     "Ifpack2::ReorderFilter::getLocalRowCopy: The given array views are not "
00383     "long enough to store all the data in the given row " << LocalRow
00384     << ".  Indices.size() = " << Indices.size () << ", Values.size() = "
00385     << Values.size () << ", but the row has " << numEntries << " entry/ies.");
00386 
00387   local_ordinal_type MyOriginalRow = reverseperm_[LocalRow];
00388   A_->getLocalRowCopy (MyOriginalRow,Indices,Values,NumEntries);
00389   // Do a col reindex via perm
00390   //
00391   // FIXME (mfh 30 Jan 2014) This assumes that the row and column
00392   // indices are the same.
00393   for (size_t i = 0; i < NumEntries; ++i) {
00394     Indices[i] = perm_[Indices[i]];
00395   }
00396 }
00397 
00398 
00399 template<class MatrixType>
00400 void ReorderFilter<MatrixType>::
00401 getGlobalRowView (global_ordinal_type GlobalRow,
00402                   Teuchos::ArrayView<const global_ordinal_type> &indices,
00403                   Teuchos::ArrayView<const scalar_type> &values) const
00404 {
00405   throw std::runtime_error("Ifpack2::ReorderFilter: does not support getGlobalRowView.");
00406 }
00407 
00408 
00409 template<class MatrixType>
00410 void ReorderFilter<MatrixType>::
00411 getLocalRowView (local_ordinal_type LocalRow,
00412                  Teuchos::ArrayView<const local_ordinal_type> &indices,
00413                  Teuchos::ArrayView<const scalar_type> &values) const
00414 {
00415   throw std::runtime_error("Ifpack2::ReorderFilter: does not support getLocalRowView.");
00416 }
00417 
00418 
00419 template<class MatrixType>
00420 void ReorderFilter<MatrixType>::
00421 getLocalDiagCopy (Tpetra::Vector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &diag) const
00422 {
00423   // This is somewhat dubious as to how the maps match.
00424   return A_->getLocalDiagCopy(diag);
00425 }
00426 
00427 
00428 template<class MatrixType>
00429 void ReorderFilter<MatrixType>::leftScale(const Tpetra::Vector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& x)
00430 {
00431   throw std::runtime_error("Ifpack2::ReorderFilter does not support leftScale.");
00432 }
00433 
00434 
00435 template<class MatrixType>
00436 void ReorderFilter<MatrixType>::rightScale(const Tpetra::Vector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& x)
00437 {
00438   throw std::runtime_error("Ifpack2::ReorderFilter does not support rightScale.");
00439 }
00440 
00441 
00442 template<class MatrixType>
00443 void ReorderFilter<MatrixType>::
00444 apply (const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &X,
00445        Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &Y,
00446        Teuchos::ETransp mode,
00447        scalar_type alpha,
00448        scalar_type beta) const
00449 {
00450   typedef Teuchos::ScalarTraits<scalar_type> STS;
00451 
00452   // Note: This isn't AztecOO compliant.  But neither was Ifpack's version.
00453   // Note: The localized maps mean the matvec is trivial (and has no import)
00454   TEUCHOS_TEST_FOR_EXCEPTION(
00455     X.getNumVectors() != Y.getNumVectors(), std::runtime_error,
00456     "Ifpack2::ReorderFilter::apply: X.getNumVectors() != Y.getNumVectors().");
00457 
00458   const scalar_type zero = STS::zero ();
00459   Teuchos::ArrayRCP<Teuchos::ArrayRCP<const scalar_type> > x_ptr = X.get2dView();
00460   Teuchos::ArrayRCP<Teuchos::ArrayRCP<scalar_type> > y_ptr = Y.get2dViewNonConst();
00461 
00462   Y.putScalar (zero);
00463   const size_t NumVectors = Y.getNumVectors ();
00464 
00465   for (size_t i = 0; i < A_->getNodeNumRows (); ++i) {
00466     size_t Nnz;
00467     // Use this class's getrow to make the below code simpler
00468     getLocalRowCopy (i, Indices_ (), Values_ (), Nnz);
00469     if (mode == Teuchos::NO_TRANS) {
00470       for (size_t j = 0; j < Nnz; ++j) {
00471         for (size_t k = 0; k < NumVectors; ++k) {
00472           y_ptr[k][i] += Values_[j] * x_ptr[k][Indices_[j]];
00473         }
00474       }
00475     }
00476     else if (mode == Teuchos::TRANS) {
00477       for (size_t j = 0; j < Nnz; ++j) {
00478         for (size_t k = 0; k < NumVectors; ++k) {
00479           y_ptr[k][Indices_[j]] += Values_[j] * x_ptr[k][i];
00480         }
00481       }
00482     }
00483     else { //mode==Teuchos::CONJ_TRANS
00484       for (size_t j = 0; j < Nnz; ++j) {
00485         for (size_t k = 0; k < NumVectors; ++k) {
00486           y_ptr[k][Indices_[j]] += STS::conjugate(Values_[j]) * x_ptr[k][i];
00487         }
00488       }
00489     }
00490   }
00491 }
00492 
00493 
00494 template<class MatrixType>
00495 bool ReorderFilter<MatrixType>::hasTransposeApply() const
00496 {
00497   return true;
00498 }
00499 
00500 
00501 template<class MatrixType>
00502 bool ReorderFilter<MatrixType>::supportsRowViews() const
00503 {
00504   return false;
00505 }
00506 
00507 
00508 template<class MatrixType>
00509 typename Teuchos::ScalarTraits<typename MatrixType::scalar_type>::magnitudeType ReorderFilter<MatrixType>::getFrobeniusNorm() const
00510 {
00511   // Reordering doesn't change the Frobenius norm.
00512   return A_->getFrobeniusNorm ();
00513 }
00514 
00515 
00516 template<class MatrixType>
00517 void ReorderFilter<MatrixType>::
00518 permuteOriginalToReordered (const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &originalX,
00519                             Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &reorderedY) const
00520 {
00521   this->template permuteOriginalToReorderedTempl<scalar_type,scalar_type>(originalX, reorderedY);
00522 }
00523 
00524 
00525 template<class MatrixType>
00526 template<class DomainScalar, class RangeScalar>
00527 void ReorderFilter<MatrixType>::permuteOriginalToReorderedTempl(const Tpetra::MultiVector<DomainScalar,local_ordinal_type,global_ordinal_type,node_type> &originalX,
00528                                                                 Tpetra::MultiVector<RangeScalar,local_ordinal_type,global_ordinal_type,node_type> &reorderedY) const
00529 {
00530   TEUCHOS_TEST_FOR_EXCEPTION(originalX.getNumVectors() != reorderedY.getNumVectors(), std::runtime_error,
00531                              "Ifpack2::ReorderFilter::permuteOriginalToReordered ERROR: X.getNumVectors() != Y.getNumVectors().");
00532 
00533   Teuchos::ArrayRCP<Teuchos::ArrayRCP<const DomainScalar> > x_ptr = originalX.get2dView();
00534   Teuchos::ArrayRCP<Teuchos::ArrayRCP<RangeScalar> >        y_ptr = reorderedY.get2dViewNonConst();
00535 
00536   for(size_t k=0; k < originalX.getNumVectors(); k++)
00537     for(local_ordinal_type i=0; (size_t)i< originalX.getLocalLength(); i++)
00538       y_ptr[k][perm_[i]] = (RangeScalar)x_ptr[k][i];
00539 }
00540 
00541 
00542 template<class MatrixType>
00543 void ReorderFilter<MatrixType>::permuteReorderedToOriginal(const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &reorderedX,
00544                                                            Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &originalY) const
00545 {
00546   this->template permuteReorderedToOriginalTempl<scalar_type,scalar_type>(reorderedX, originalY);
00547 }
00548 
00549 
00550 template<class MatrixType>
00551 template<class DomainScalar, class RangeScalar>
00552 void ReorderFilter<MatrixType>::
00553 permuteReorderedToOriginalTempl (const Tpetra::MultiVector<DomainScalar,local_ordinal_type,global_ordinal_type,node_type> &reorderedX,
00554                                  Tpetra::MultiVector<RangeScalar,local_ordinal_type,global_ordinal_type,node_type> &originalY) const
00555 {
00556   TEUCHOS_TEST_FOR_EXCEPTION(
00557     reorderedX.getNumVectors() != originalY.getNumVectors(),
00558     std::runtime_error,
00559     "Ifpack2::ReorderFilter::permuteReorderedToOriginal: "
00560     "X.getNumVectors() != Y.getNumVectors().");
00561 
00562   Teuchos::ArrayRCP<Teuchos::ArrayRCP<const DomainScalar> > x_ptr = reorderedX.get2dView();
00563   Teuchos::ArrayRCP<Teuchos::ArrayRCP<RangeScalar> >        y_ptr = originalY.get2dViewNonConst();
00564 
00565   for (size_t k = 0; k < reorderedX.getNumVectors (); ++k) {
00566     for (local_ordinal_type i = 0; (size_t)i < reorderedX.getLocalLength (); ++i) {
00567       y_ptr[k][reverseperm_[i]] = (RangeScalar) x_ptr[k][i];
00568     }
00569   }
00570 }
00571 
00572 
00573 template<class MatrixType>
00574 TPETRA_DEPRECATED void
00575 ReorderFilter<MatrixType>::
00576 getGlobalRowView (global_ordinal_type GlobalRow,
00577                   Teuchos::ArrayRCP<const global_ordinal_type> &indices,
00578                   Teuchos::ArrayRCP<const scalar_type> &values) const
00579 {
00580   throw std::runtime_error("Ifpack2::ReorderFilter does not implement getGlobalRowView.");
00581 }
00582 
00583 
00584 template<class MatrixType>
00585 TPETRA_DEPRECATED void
00586 ReorderFilter<MatrixType>::
00587 getLocalRowView (local_ordinal_type LocalRow,
00588                  Teuchos::ArrayRCP<const local_ordinal_type> &indices,
00589                  Teuchos::ArrayRCP<const scalar_type> &values) const
00590 {
00591   throw std::runtime_error("Ifpack2::ReorderFilter does not implement getLocalRowView.");
00592 }
00593 
00594 } // namespace Ifpack2
00595 
00596 #define IFPACK2_REORDERFILTER_INSTANT(S,LO,GO,N)                        \
00597   template class Ifpack2::ReorderFilter< Tpetra::CrsMatrix<S, LO, GO, N> >;
00598 
00599 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends