Amesos2 - Direct Sparse Solver Interfaces Version of the Day
Amesos2_TpetraRowMatrix_AbstractMatrixAdapter_def.hpp
00001 // @HEADER
00002 //
00003 // ***********************************************************************
00004 //
00005 //           Amesos2: Templated Direct Sparse Solver Package 
00006 //                  Copyright 2011 Sandia Corporation
00007 //
00008 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00009 // the U.S. Government retains certain rights in this software.
00010 //
00011 // Redistribution and use in source and binary forms, with or without
00012 // modification, are permitted provided that the following conditions are
00013 // met:
00014 //
00015 // 1. Redistributions of source code must retain the above copyright
00016 // notice, this list of conditions and the following disclaimer.
00017 //
00018 // 2. Redistributions in binary form must reproduce the above copyright
00019 // notice, this list of conditions and the following disclaimer in the
00020 // documentation and/or other materials provided with the distribution.
00021 //
00022 // 3. Neither the name of the Corporation nor the names of the
00023 // contributors may be used to endorse or promote products derived from
00024 // this software without specific prior written permission.
00025 //
00026 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00027 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00028 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00029 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00030 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00031 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00032 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00033 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00034 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00035 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00036 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00037 //
00038 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
00039 //
00040 // ***********************************************************************
00041 //
00042 // @HEADER
00043 
00044 
00045 #ifndef AMESOS2_TPETRAROWMATRIX_ABSTRACTMATRIXADAPTER_DEF_HPP
00046 #define AMESOS2_TPETRAROWMATRIX_ABSTRACTMATRIXADAPTER_DEF_HPP
00047 
00048 #include "Amesos2_ConcreteMatrixAdapter_decl.hpp"
00049 #include "Amesos2_TpetraRowMatrix_AbstractMatrixAdapter_decl.hpp"
00050 
00051 namespace Amesos2 {
00052 
00053   using Teuchos::RCP;
00054   using Teuchos::ArrayView;
00055 
00056   template <typename Scalar,
00057       typename LocalOrdinal,
00058       typename GlobalOrdinal,
00059       typename Node,
00060       class DerivedMat>
00061   AbstractConcreteMatrixAdapter<
00062     Tpetra::RowMatrix<Scalar,
00063           LocalOrdinal,
00064           GlobalOrdinal,
00065           Node>,
00066     DerivedMat>::AbstractConcreteMatrixAdapter(RCP<Tpetra::RowMatrix<Scalar,LocalOrdinal,GlobalOrdinal,Node> > m)
00067       : MatrixAdapter<DerivedMat>(Teuchos::rcp_static_cast<DerivedMat>(m)) 
00068   {
00069     // anything else? probs not
00070   }
00071 
00072   // implementation functions
00073   template <typename Scalar,
00074       typename LocalOrdinal,
00075       typename GlobalOrdinal,
00076       typename Node,
00077       class DerivedMat>
00078   void
00079   AbstractConcreteMatrixAdapter<
00080     Tpetra::RowMatrix<Scalar,
00081           LocalOrdinal,
00082           GlobalOrdinal,
00083           Node>,
00084     DerivedMat>::getGlobalRowCopy_impl(global_ordinal_t row,
00085                const ArrayView<global_ordinal_t>& indices,
00086                const ArrayView<scalar_t>& vals,
00087                size_t& nnz) const
00088     {
00089       this->mat_->getGlobalRowCopy(row, indices, vals, nnz);
00090     }
00091 
00092   template <typename Scalar,
00093       typename LocalOrdinal,
00094       typename GlobalOrdinal,
00095       typename Node,
00096       class DerivedMat>
00097   void
00098   AbstractConcreteMatrixAdapter<
00099     Tpetra::RowMatrix<Scalar,
00100           LocalOrdinal,
00101           GlobalOrdinal,
00102           Node>,
00103     DerivedMat>::getGlobalColCopy_impl(global_ordinal_t col,
00104            const ArrayView<global_ordinal_t>& indices,
00105            const ArrayView<scalar_t>& vals,
00106            size_t& nnz) const
00107   {
00108     TEUCHOS_TEST_FOR_EXCEPTION( true,
00109       std::runtime_error,
00110       "Column access to row-based object not yet supported.  "
00111       "Please contact the Amesos2 developers." );
00112   }
00113 
00114 
00115   template <typename Scalar,
00116       typename LocalOrdinal,
00117       typename GlobalOrdinal,
00118       typename Node,
00119       class DerivedMat>
00120   typename AbstractConcreteMatrixAdapter<
00121     Tpetra::RowMatrix<Scalar,
00122           LocalOrdinal,
00123           GlobalOrdinal,
00124           Node>,
00125     DerivedMat>::global_size_t
00126   AbstractConcreteMatrixAdapter<
00127     Tpetra::RowMatrix<Scalar,
00128           LocalOrdinal,
00129           GlobalOrdinal,
00130           Node>,
00131     DerivedMat>::getGlobalNNZ_impl() const
00132   {
00133     return this->mat_->getGlobalNumEntries();
00134   }
00135 
00136   template <typename Scalar, typename LocalOrdinal, typename GlobalOrdinal, typename Node, class DerivedMat>
00137   size_t
00138   AbstractConcreteMatrixAdapter<
00139     Tpetra::RowMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>,
00140     DerivedMat>::getLocalNNZ_impl() const
00141   {
00142     return this->mat_->getNodeNumEntries();
00143   }
00144 
00145   template <typename Scalar,
00146       typename LocalOrdinal,
00147       typename GlobalOrdinal,
00148       typename Node,
00149       class DerivedMat>
00150   size_t
00151   AbstractConcreteMatrixAdapter<
00152     Tpetra::RowMatrix<Scalar,
00153           LocalOrdinal,
00154           GlobalOrdinal,
00155           Node>,
00156     DerivedMat>::getMaxRowNNZ_impl() const
00157   {
00158     return this->mat_->getGlobalMaxNumRowEntries();
00159   }
00160 
00161   template <typename Scalar,
00162       typename LocalOrdinal,
00163       typename GlobalOrdinal,
00164       typename Node,
00165       class DerivedMat>
00166   size_t
00167   AbstractConcreteMatrixAdapter<
00168     Tpetra::RowMatrix<Scalar,
00169           LocalOrdinal,
00170           GlobalOrdinal,
00171           Node>,
00172     DerivedMat>::getMaxColNNZ_impl() const
00173   {
00174     TEUCHOS_TEST_FOR_EXCEPTION( true,
00175       std::runtime_error,
00176       "Column access to row-based object not yet supported.  "
00177       "Please contact the Amesos2 developers." );
00178     return 0;
00179   }
00180 
00181   template <typename Scalar,
00182       typename LocalOrdinal,
00183       typename GlobalOrdinal,
00184       typename Node,
00185       class DerivedMat>
00186   size_t
00187   AbstractConcreteMatrixAdapter<
00188     Tpetra::RowMatrix<Scalar,
00189           LocalOrdinal,
00190           GlobalOrdinal,
00191           Node>,
00192     DerivedMat>::getGlobalRowNNZ_impl(global_ordinal_t row) const
00193   {
00194     return this->mat_->getNumEntriesInGlobalRow(row);
00195   }
00196 
00197   template <typename Scalar,
00198       typename LocalOrdinal,
00199       typename GlobalOrdinal,
00200       typename Node,
00201       class DerivedMat>
00202   size_t
00203   AbstractConcreteMatrixAdapter<
00204     Tpetra::RowMatrix<Scalar,
00205           LocalOrdinal,
00206           GlobalOrdinal,
00207           Node>,
00208     DerivedMat>::getLocalRowNNZ_impl(local_ordinal_t row) const
00209   {
00210     return this->mat_->getNumEntriesInLocalRow(row);
00211   }
00212 
00213   template <typename Scalar,
00214       typename LocalOrdinal,
00215       typename GlobalOrdinal,
00216       typename Node,
00217       class DerivedMat>
00218   size_t
00219   AbstractConcreteMatrixAdapter<
00220     Tpetra::RowMatrix<Scalar,
00221           LocalOrdinal,
00222           GlobalOrdinal,
00223           Node>,
00224     DerivedMat>::getGlobalColNNZ_impl(global_ordinal_t col) const
00225   {
00226     TEUCHOS_TEST_FOR_EXCEPTION( true,
00227       std::runtime_error,
00228       "Column access to row-based object not yet supported.  "
00229       "Please contact the Amesos2 developers." );
00230     return 0;
00231   }
00232 
00233   template <typename Scalar,
00234       typename LocalOrdinal,
00235       typename GlobalOrdinal,
00236       typename Node,
00237       class DerivedMat>
00238   size_t
00239   AbstractConcreteMatrixAdapter<
00240     Tpetra::RowMatrix<Scalar,
00241           LocalOrdinal,
00242           GlobalOrdinal,
00243           Node>,
00244     DerivedMat>::getLocalColNNZ_impl(local_ordinal_t col) const
00245   {
00246     TEUCHOS_TEST_FOR_EXCEPTION( true,
00247       std::runtime_error,
00248       "Column access to row-based object not yet supported.  "
00249       "Please contact the Amesos2 developers." );
00250     return 0;
00251   }
00252 
00253   template <typename Scalar,
00254       typename LocalOrdinal,
00255       typename GlobalOrdinal,
00256       typename Node,
00257       class DerivedMat>
00258   const RCP<const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> >
00259   AbstractConcreteMatrixAdapter<
00260     Tpetra::RowMatrix<Scalar,
00261           LocalOrdinal,
00262           GlobalOrdinal,
00263           Node>,
00264     DerivedMat>:: getRowMap_impl() const
00265   {
00266     return this->mat_->getRowMap();
00267   }
00268   
00269   template <typename Scalar,
00270       typename LocalOrdinal,
00271       typename GlobalOrdinal,
00272       typename Node,
00273       class DerivedMat>
00274   const RCP<const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> >
00275   AbstractConcreteMatrixAdapter<
00276     Tpetra::RowMatrix<Scalar,
00277           LocalOrdinal,
00278           GlobalOrdinal,
00279           Node>,
00280     DerivedMat>::getColMap_impl() const
00281   {
00282     return this->mat_->getColMap();
00283   }
00284 
00285   template <typename Scalar,
00286       typename LocalOrdinal,
00287       typename GlobalOrdinal,
00288       typename Node,
00289       class DerivedMat>
00290   const RCP<const Teuchos::Comm<int> >
00291   AbstractConcreteMatrixAdapter<
00292     Tpetra::RowMatrix<Scalar,
00293           LocalOrdinal,
00294           GlobalOrdinal,
00295           Node>,
00296     DerivedMat>::getComm_impl() const
00297   {
00298     return this->mat_->getComm();
00299   }
00300 
00301   template <typename Scalar,
00302       typename LocalOrdinal,
00303       typename GlobalOrdinal,
00304       typename Node,
00305       class DerivedMat>
00306   bool
00307   AbstractConcreteMatrixAdapter<
00308     Tpetra::RowMatrix<Scalar,
00309           LocalOrdinal,
00310           GlobalOrdinal,
00311           Node>,
00312     DerivedMat>::isLocallyIndexed_impl() const
00313   {
00314     return this->mat_->isLocallyIndexed();
00315   }
00316   
00317   template <typename Scalar,
00318       typename LocalOrdinal,
00319       typename GlobalOrdinal,
00320       typename Node,
00321       class DerivedMat>
00322   bool
00323   AbstractConcreteMatrixAdapter<
00324     Tpetra::RowMatrix<Scalar,
00325           LocalOrdinal,
00326           GlobalOrdinal,
00327           Node>,
00328     DerivedMat>::isGloballyIndexed_impl() const
00329   {
00330     return this->mat_->isGloballyIndexed();
00331   }
00332 
00333   template <typename Scalar, typename LocalOrdinal, typename GlobalOrdinal, typename Node, class DerivedMat>
00334   RCP<const MatrixAdapter<DerivedMat> >
00335   AbstractConcreteMatrixAdapter<
00336     Tpetra::RowMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>, DerivedMat
00337     >::get_impl(const Teuchos::Ptr<const Tpetra::Map<local_ordinal_t,global_ordinal_t,node_t> > map) const
00338   {
00339     return static_cast<ConcreteMatrixAdapter<DerivedMat>*>(this)->get_impl(map);
00340   }
00341 
00342 } // end namespace Amesos2
00343 
00344 #endif  // AMESOS2_TPETRAROWMATRIX_ABSTRACTMATRIXADAPTER_DEF_HPP