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   if (A_.is_null () || A_->getRowMap ().is_null ()) {
00218     return Teuchos::OrdinalTraits<size_t>::invalid ();
00219   }
00220   else {
00221     const local_ordinal_type lclRow =
00222       A_->getRowMap ()->getLocalElement (globalRow);
00223     if (lclRow == Teuchos::OrdinalTraits<local_ordinal_type>::invalid ()) {
00224       // The calling process doesn't own any entries in this row.
00225       return static_cast<size_t> (0);
00226     } else {
00227       const local_ordinal_type origLclRow = reverseperm_[lclRow];
00228       return A_->getNumEntriesInLocalRow (origLclRow);
00229     }
00230   }
00231 }
00232 
00233 
00234 template<class MatrixType>
00235 size_t ReorderFilter<MatrixType>::
00236 getNumEntriesInLocalRow (local_ordinal_type localRow) const
00237 {
00238   // Make sure that localRow is in bounds before using it to index
00239   // into the permutation.
00240   if (A_->getRowMap ()->isNodeLocalElement (localRow)) {
00241     // localRow is a valid index into reverseperm_.
00242     const local_ordinal_type localReorderedRow = reverseperm_[localRow];
00243     return A_->getNumEntriesInLocalRow (localReorderedRow);
00244   } else {
00245     // The calling process doesn't own any entries in this row.
00246     return static_cast<size_t> (0);
00247   }
00248 }
00249 
00250 
00251 template<class MatrixType>
00252 global_size_t ReorderFilter<MatrixType>::getGlobalNumDiags() const
00253 {
00254   return A_->getGlobalNumDiags();
00255 }
00256 
00257 
00258 template<class MatrixType>
00259 size_t ReorderFilter<MatrixType>::getNodeNumDiags() const
00260 {
00261   return A_->getNodeNumDiags();
00262 }
00263 
00264 
00265 template<class MatrixType>
00266 size_t ReorderFilter<MatrixType>::getGlobalMaxNumRowEntries() const
00267 {
00268   return A_->getGlobalMaxNumRowEntries();
00269 }
00270 
00271 
00272 template<class MatrixType>
00273 size_t ReorderFilter<MatrixType>::getNodeMaxNumRowEntries() const
00274 {
00275   return A_->getNodeMaxNumRowEntries();
00276 }
00277 
00278 
00279 template<class MatrixType>
00280 bool ReorderFilter<MatrixType>::hasColMap() const
00281 {
00282   return true;
00283 }
00284 
00285 
00286 template<class MatrixType>
00287 bool ReorderFilter<MatrixType>::isLowerTriangular() const
00288 {
00289   return A_->isLowerTriangular();
00290 }
00291 
00292 
00293 template<class MatrixType>
00294 bool ReorderFilter<MatrixType>::isUpperTriangular() const
00295 {
00296   return A_->isUpperTriangular();
00297 }
00298 
00299 
00300 template<class MatrixType>
00301 bool ReorderFilter<MatrixType>::isLocallyIndexed() const
00302 {
00303   return A_->isLocallyIndexed();
00304 }
00305 
00306 
00307 template<class MatrixType>
00308 bool ReorderFilter<MatrixType>::isGloballyIndexed() const
00309 {
00310   return A_->isGloballyIndexed();
00311 }
00312 
00313 
00314 template<class MatrixType>
00315 bool ReorderFilter<MatrixType>::isFillComplete() const
00316 {
00317   return A_->isFillComplete();
00318 }
00319 
00320 
00321 template<class MatrixType>
00322 void ReorderFilter<MatrixType>::
00323 getGlobalRowCopy (global_ordinal_type globalRow,
00324                   const Teuchos::ArrayView<global_ordinal_type>& globalInd,
00325                   const Teuchos::ArrayView<scalar_type>& val,
00326                   size_t& numEntries) const
00327 {
00328   using Teuchos::Array;
00329   using Teuchos::ArrayView;
00330   using Teuchos::av_reinterpret_cast;
00331   typedef local_ordinal_type LO;
00332   typedef global_ordinal_type GO;
00333   typedef Teuchos::OrdinalTraits<LO> OTLO;
00334 
00335   const map_type& rowMap = * (A_->getRowMap ());
00336   const local_ordinal_type localRow = rowMap.getLocalElement (globalRow);
00337   TEUCHOS_TEST_FOR_EXCEPTION(
00338     localRow == OTLO::invalid (), std::invalid_argument, "Ifpack2::Reorder"
00339     "Filter::getGlobalRowCopy: The given global row index " << globalRow
00340     << " is not owned by the calling process with rank "
00341     << rowMap.getComm ()->getRank () << ".");
00342 
00343   if (sizeof (GO) == sizeof (LO)) {
00344     // This means we can convert local to global in place.
00345     ArrayView<LO> localInd = av_reinterpret_cast<LO> (globalInd);
00346     this->getLocalRowCopy (localRow, localInd, val, numEntries);
00347 
00348     // Convert local indices back to global indices.
00349     for (size_t k = 0; k < numEntries; ++k) {
00350       globalInd[k] = rowMap.getGlobalElement (localInd[k]);
00351     }
00352   }
00353   else {
00354     // LO and GO have different sizes, so we need a temp array
00355     // for converting local to global.
00356     numEntries = this->getNumEntriesInLocalRow (localRow);
00357     Array<LO> localInd (numEntries);
00358     this->getLocalRowCopy (localRow, localInd, val, numEntries);
00359 
00360     // Convert local indices back to global indices.
00361     for (size_t k = 0; k < numEntries; ++k) {
00362       globalInd[k] = rowMap.getGlobalElement (localInd[k]);
00363     }
00364   }
00365 }
00366 
00367 
00368 template<class MatrixType>
00369 void ReorderFilter<MatrixType>::
00370 getLocalRowCopy (local_ordinal_type LocalRow,
00371                  const Teuchos::ArrayView<local_ordinal_type> &Indices,
00372                  const Teuchos::ArrayView<scalar_type> &Values,
00373                  size_t &NumEntries) const
00374 {
00375   TEUCHOS_TEST_FOR_EXCEPTION(
00376     ! A_->getRowMap ()->isNodeLocalElement (LocalRow),
00377     std::invalid_argument,
00378     "Ifpack2::ReorderFilter::getLocalRowCopy: The given local row index "
00379     << LocalRow << " is not a valid local row index on the calling process "
00380     "with rank " << A_->getRowMap ()->getComm ()->getRank () << ".");
00381 
00382   // This duplicates code in getNumEntriesInGlobalRow, but avoids an
00383   // extra array lookup and some extra tests.
00384   const local_ordinal_type origLclRow = reverseperm_[LocalRow];
00385   const size_t numEntries = A_->getNumEntriesInLocalRow (origLclRow);
00386 
00387   TEUCHOS_TEST_FOR_EXCEPTION(
00388     static_cast<size_t> (Indices.size ()) < numEntries ||
00389     static_cast<size_t> (Values.size ()) < numEntries,
00390     std::invalid_argument,
00391     "Ifpack2::ReorderFilter::getLocalRowCopy: The given array views are not "
00392     "long enough to store all the data in the given row " << LocalRow
00393     << ".  Indices.size() = " << Indices.size () << ", Values.size() = "
00394     << Values.size () << ", but the (original) row has " << numEntries
00395     << " entry/ies.");
00396 
00397   A_->getLocalRowCopy (origLclRow, Indices, Values, NumEntries);
00398   // Do a col reindex via perm
00399   //
00400   // FIXME (mfh 30 Jan 2014) This assumes that the row and column
00401   // indices are the same.
00402   for (size_t i = 0; i < NumEntries; ++i) {
00403     Indices[i] = perm_[Indices[i]];
00404   }
00405 }
00406 
00407 
00408 template<class MatrixType>
00409 void ReorderFilter<MatrixType>::
00410 getGlobalRowView (global_ordinal_type GlobalRow,
00411                   Teuchos::ArrayView<const global_ordinal_type> &indices,
00412                   Teuchos::ArrayView<const scalar_type> &values) const
00413 {
00414   throw std::runtime_error("Ifpack2::ReorderFilter: does not support getGlobalRowView.");
00415 }
00416 
00417 
00418 template<class MatrixType>
00419 void ReorderFilter<MatrixType>::
00420 getLocalRowView (local_ordinal_type LocalRow,
00421                  Teuchos::ArrayView<const local_ordinal_type> &indices,
00422                  Teuchos::ArrayView<const scalar_type> &values) const
00423 {
00424   throw std::runtime_error("Ifpack2::ReorderFilter: does not support getLocalRowView.");
00425 }
00426 
00427 
00428 template<class MatrixType>
00429 void ReorderFilter<MatrixType>::
00430 getLocalDiagCopy (Tpetra::Vector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &diag) const
00431 {
00432   // This is somewhat dubious as to how the maps match.
00433   return A_->getLocalDiagCopy(diag);
00434 }
00435 
00436 
00437 template<class MatrixType>
00438 void ReorderFilter<MatrixType>::leftScale(const Tpetra::Vector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& x)
00439 {
00440   throw std::runtime_error("Ifpack2::ReorderFilter does not support leftScale.");
00441 }
00442 
00443 
00444 template<class MatrixType>
00445 void ReorderFilter<MatrixType>::rightScale(const Tpetra::Vector<scalar_type, local_ordinal_type, global_ordinal_type, node_type>& x)
00446 {
00447   throw std::runtime_error("Ifpack2::ReorderFilter does not support rightScale.");
00448 }
00449 
00450 
00451 template<class MatrixType>
00452 void ReorderFilter<MatrixType>::
00453 apply (const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &X,
00454        Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &Y,
00455        Teuchos::ETransp mode,
00456        scalar_type alpha,
00457        scalar_type beta) const
00458 {
00459   typedef Teuchos::ScalarTraits<scalar_type> STS;
00460 
00461   // Note: This isn't AztecOO compliant.  But neither was Ifpack's version.
00462   // Note: The localized maps mean the matvec is trivial (and has no import)
00463   TEUCHOS_TEST_FOR_EXCEPTION(
00464     X.getNumVectors() != Y.getNumVectors(), std::runtime_error,
00465     "Ifpack2::ReorderFilter::apply: X.getNumVectors() != Y.getNumVectors().");
00466 
00467   const scalar_type zero = STS::zero ();
00468   Teuchos::ArrayRCP<Teuchos::ArrayRCP<const scalar_type> > x_ptr = X.get2dView();
00469   Teuchos::ArrayRCP<Teuchos::ArrayRCP<scalar_type> > y_ptr = Y.get2dViewNonConst();
00470 
00471   Y.putScalar (zero);
00472   const size_t NumVectors = Y.getNumVectors ();
00473 
00474   for (size_t i = 0; i < A_->getNodeNumRows (); ++i) {
00475     size_t Nnz;
00476     // Use this class's getrow to make the below code simpler
00477     getLocalRowCopy (i, Indices_ (), Values_ (), Nnz);
00478     if (mode == Teuchos::NO_TRANS) {
00479       for (size_t j = 0; j < Nnz; ++j) {
00480         for (size_t k = 0; k < NumVectors; ++k) {
00481           y_ptr[k][i] += Values_[j] * x_ptr[k][Indices_[j]];
00482         }
00483       }
00484     }
00485     else if (mode == Teuchos::TRANS) {
00486       for (size_t j = 0; j < Nnz; ++j) {
00487         for (size_t k = 0; k < NumVectors; ++k) {
00488           y_ptr[k][Indices_[j]] += Values_[j] * x_ptr[k][i];
00489         }
00490       }
00491     }
00492     else { //mode==Teuchos::CONJ_TRANS
00493       for (size_t j = 0; j < Nnz; ++j) {
00494         for (size_t k = 0; k < NumVectors; ++k) {
00495           y_ptr[k][Indices_[j]] += STS::conjugate(Values_[j]) * x_ptr[k][i];
00496         }
00497       }
00498     }
00499   }
00500 }
00501 
00502 
00503 template<class MatrixType>
00504 bool ReorderFilter<MatrixType>::hasTransposeApply() const
00505 {
00506   return true;
00507 }
00508 
00509 
00510 template<class MatrixType>
00511 bool ReorderFilter<MatrixType>::supportsRowViews() const
00512 {
00513   return false;
00514 }
00515 
00516 
00517 template<class MatrixType>
00518 typename Teuchos::ScalarTraits<typename MatrixType::scalar_type>::magnitudeType ReorderFilter<MatrixType>::getFrobeniusNorm() const
00519 {
00520   // Reordering doesn't change the Frobenius norm.
00521   return A_->getFrobeniusNorm ();
00522 }
00523 
00524 
00525 template<class MatrixType>
00526 void ReorderFilter<MatrixType>::
00527 permuteOriginalToReordered (const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &originalX,
00528                             Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &reorderedY) const
00529 {
00530   this->template permuteOriginalToReorderedTempl<scalar_type,scalar_type>(originalX, reorderedY);
00531 }
00532 
00533 
00534 template<class MatrixType>
00535 template<class DomainScalar, class RangeScalar>
00536 void ReorderFilter<MatrixType>::permuteOriginalToReorderedTempl(const Tpetra::MultiVector<DomainScalar,local_ordinal_type,global_ordinal_type,node_type> &originalX,
00537                                                                 Tpetra::MultiVector<RangeScalar,local_ordinal_type,global_ordinal_type,node_type> &reorderedY) const
00538 {
00539   TEUCHOS_TEST_FOR_EXCEPTION(originalX.getNumVectors() != reorderedY.getNumVectors(), std::runtime_error,
00540                              "Ifpack2::ReorderFilter::permuteOriginalToReordered ERROR: X.getNumVectors() != Y.getNumVectors().");
00541 
00542   Teuchos::ArrayRCP<Teuchos::ArrayRCP<const DomainScalar> > x_ptr = originalX.get2dView();
00543   Teuchos::ArrayRCP<Teuchos::ArrayRCP<RangeScalar> >        y_ptr = reorderedY.get2dViewNonConst();
00544 
00545   for(size_t k=0; k < originalX.getNumVectors(); k++)
00546     for(local_ordinal_type i=0; (size_t)i< originalX.getLocalLength(); i++)
00547       y_ptr[k][perm_[i]] = (RangeScalar)x_ptr[k][i];
00548 }
00549 
00550 
00551 template<class MatrixType>
00552 void ReorderFilter<MatrixType>::permuteReorderedToOriginal(const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &reorderedX,
00553                                                            Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type> &originalY) const
00554 {
00555   this->template permuteReorderedToOriginalTempl<scalar_type,scalar_type>(reorderedX, originalY);
00556 }
00557 
00558 
00559 template<class MatrixType>
00560 template<class DomainScalar, class RangeScalar>
00561 void ReorderFilter<MatrixType>::
00562 permuteReorderedToOriginalTempl (const Tpetra::MultiVector<DomainScalar,local_ordinal_type,global_ordinal_type,node_type> &reorderedX,
00563                                  Tpetra::MultiVector<RangeScalar,local_ordinal_type,global_ordinal_type,node_type> &originalY) const
00564 {
00565   TEUCHOS_TEST_FOR_EXCEPTION(
00566     reorderedX.getNumVectors() != originalY.getNumVectors(),
00567     std::runtime_error,
00568     "Ifpack2::ReorderFilter::permuteReorderedToOriginal: "
00569     "X.getNumVectors() != Y.getNumVectors().");
00570 
00571   Teuchos::ArrayRCP<Teuchos::ArrayRCP<const DomainScalar> > x_ptr = reorderedX.get2dView();
00572   Teuchos::ArrayRCP<Teuchos::ArrayRCP<RangeScalar> >        y_ptr = originalY.get2dViewNonConst();
00573 
00574   for (size_t k = 0; k < reorderedX.getNumVectors (); ++k) {
00575     for (local_ordinal_type i = 0; (size_t)i < reorderedX.getLocalLength (); ++i) {
00576       y_ptr[k][reverseperm_[i]] = (RangeScalar) x_ptr[k][i];
00577     }
00578   }
00579 }
00580 
00581 
00582 template<class MatrixType>
00583 TPETRA_DEPRECATED void
00584 ReorderFilter<MatrixType>::
00585 getGlobalRowView (global_ordinal_type GlobalRow,
00586                   Teuchos::ArrayRCP<const global_ordinal_type> &indices,
00587                   Teuchos::ArrayRCP<const scalar_type> &values) const
00588 {
00589   throw std::runtime_error("Ifpack2::ReorderFilter does not implement getGlobalRowView.");
00590 }
00591 
00592 
00593 template<class MatrixType>
00594 TPETRA_DEPRECATED void
00595 ReorderFilter<MatrixType>::
00596 getLocalRowView (local_ordinal_type LocalRow,
00597                  Teuchos::ArrayRCP<const local_ordinal_type> &indices,
00598                  Teuchos::ArrayRCP<const scalar_type> &values) const
00599 {
00600   throw std::runtime_error("Ifpack2::ReorderFilter does not implement getLocalRowView.");
00601 }
00602 
00603 } // namespace Ifpack2
00604 
00605 #define IFPACK2_REORDERFILTER_INSTANT(S,LO,GO,N)                        \
00606   template class Ifpack2::ReorderFilter< Tpetra::CrsMatrix<S, LO, GO, N> >;
00607 
00608 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends