|
Amesos2 - Direct Sparse Solver Interfaces
Version of the Day
|
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_MATRIXADAPTER_DECL_HPP 00046 #define AMESOS2_MATRIXADAPTER_DECL_HPP 00047 00048 #include "Amesos2_config.h" 00049 00050 #include <Teuchos_Comm.hpp> 00051 #include <Teuchos_ArrayView.hpp> 00052 #include <Teuchos_VerbosityLevel.hpp> 00053 #include <Teuchos_FancyOStream.hpp> 00054 00055 #include <Tpetra_ConfigDefs.hpp> // for global_size_t 00056 00057 // #include "Amesos2_ConcreteMatrixAdapter_decl.hpp" 00058 #include "Amesos2_Util.hpp" 00059 #include "Amesos2_MatrixTraits.hpp" 00060 00061 namespace Amesos2 { 00062 00063 template <class M> class ConcreteMatrixAdapter; 00064 00075 template < class Matrix > 00076 class MatrixAdapter { 00077 00078 public: 00079 00080 typedef typename MatrixTraits<Matrix>::scalar_t scalar_t; 00081 typedef typename MatrixTraits<Matrix>::local_ordinal_t local_ordinal_t; 00082 typedef typename MatrixTraits<Matrix>::global_ordinal_t global_ordinal_t; 00083 typedef typename MatrixTraits<Matrix>::node_t node_t; 00084 typedef Tpetra::global_size_t global_size_t; 00085 00086 typedef Matrix matrix_t; 00087 typedef MatrixAdapter<Matrix> type; 00088 typedef ConcreteMatrixAdapter<Matrix> adapter_t; 00089 00090 // template<typename S, typename GO, typename GS, typename Op> 00091 // friend class Util::get_cxs_helper<MatrixAdapter<Matrix>,S,GO,GS,Op>; 00092 // template<class M, typename S, typename GO, typename GS, typename Op> 00093 // friend class Util::get_cxs_helper; 00094 00095 MatrixAdapter(Teuchos::RCP<Matrix> m); 00096 00097 00127 void getCrs(const Teuchos::ArrayView<scalar_t> nzval, 00128 const Teuchos::ArrayView<global_ordinal_t> colind, 00129 const Teuchos::ArrayView<global_size_t> rowptr, 00130 global_size_t& nnz, 00131 const Teuchos::Ptr<const Tpetra::Map<local_ordinal_t,global_ordinal_t,node_t> > rowmap, 00132 EStorage_Ordering ordering=ARBITRARY) const; 00133 00139 void getCrs(const Teuchos::ArrayView<scalar_t> nzval, 00140 const Teuchos::ArrayView<global_ordinal_t> colind, 00141 const Teuchos::ArrayView<global_size_t> rowptr, 00142 global_size_t& nnz, 00143 EDistribution distribution, 00144 EStorage_Ordering ordering=ARBITRARY) const; 00145 00172 void getCcs(const Teuchos::ArrayView<scalar_t> nzval, 00173 const Teuchos::ArrayView<global_ordinal_t> rowind, 00174 const Teuchos::ArrayView<global_size_t> colptr, 00175 global_size_t& nnz, 00176 const Teuchos::Ptr<const Tpetra::Map<local_ordinal_t,global_ordinal_t,node_t> > colmap, 00177 EStorage_Ordering ordering=ARBITRARY) const; 00178 00184 void getCcs(const Teuchos::ArrayView<scalar_t> nzval, 00185 const Teuchos::ArrayView<global_ordinal_t> rowind, 00186 const Teuchos::ArrayView<global_size_t> colptr, 00187 global_size_t& nnz, 00188 EDistribution distribution, 00189 EStorage_Ordering ordering=ARBITRARY) const; 00190 00191 00193 const Teuchos::RCP<const Teuchos::Comm<int> > getComm() const 00194 { 00195 return comm_; 00196 } 00197 00199 global_size_t getGlobalNumRows() const; 00200 00202 global_size_t getGlobalNumCols() const; 00203 00205 global_size_t getGlobalNNZ() const; 00206 00208 size_t getLocalNumRows() const; 00209 00211 size_t getLocalNumCols() const; 00212 00214 size_t getLocalNNZ() const; 00215 00216 Teuchos::RCP<const Tpetra::Map<local_ordinal_t,global_ordinal_t> > 00217 getRowMap() const { 00218 return row_map_; 00219 } 00220 00221 Teuchos::RCP<const Tpetra::Map<local_ordinal_t,global_ordinal_t> > 00222 getColMap() const { 00223 return col_map_; 00224 } 00225 00226 Teuchos::RCP<const type> get(const Teuchos::Ptr<const Tpetra::Map<local_ordinal_t,global_ordinal_t,node_t> > map) const; 00227 00229 std::string description() const; 00230 00232 void describe(Teuchos::FancyOStream &out, 00233 const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const; 00234 00235 00236 private: 00237 00238 void help_getCrs(const Teuchos::ArrayView<scalar_t> nzval, 00239 const Teuchos::ArrayView<global_ordinal_t> colind, 00240 const Teuchos::ArrayView<global_size_t> rowptr, 00241 global_size_t& nnz, 00242 const Teuchos::Ptr<const Tpetra::Map<local_ordinal_t,global_ordinal_t,node_t> > rowmap, 00243 EStorage_Ordering ordering, 00244 has_special_impl hsi) const; 00245 00246 void help_getCrs(const Teuchos::ArrayView<scalar_t> nzval, 00247 const Teuchos::ArrayView<global_ordinal_t> colind, 00248 const Teuchos::ArrayView<global_size_t> rowptr, 00249 global_size_t& nnz, 00250 const Teuchos::Ptr<const Tpetra::Map<local_ordinal_t,global_ordinal_t,node_t> > rowmap, 00251 EStorage_Ordering ordering, 00252 no_special_impl nsi) const; 00253 00254 void do_getCrs(const Teuchos::ArrayView<scalar_t> nzval, 00255 const Teuchos::ArrayView<global_ordinal_t> colind, 00256 const Teuchos::ArrayView<global_size_t> rowptr, 00257 global_size_t& nnz, 00258 const Teuchos::Ptr<const Tpetra::Map<local_ordinal_t,global_ordinal_t,node_t> > rowmap, 00259 EStorage_Ordering ordering, 00260 row_access ra) const; 00261 00262 void do_getCrs(const Teuchos::ArrayView<scalar_t> nzval, 00263 const Teuchos::ArrayView<global_ordinal_t> colind, 00264 const Teuchos::ArrayView<global_size_t> rowptr, 00265 global_size_t& nnz, 00266 const Teuchos::Ptr<const Tpetra::Map<local_ordinal_t,global_ordinal_t,node_t> > rowmap, 00267 EStorage_Ordering ordering, 00268 col_access ca) const; 00269 00270 void help_getCcs(const Teuchos::ArrayView<scalar_t> nzval, 00271 const Teuchos::ArrayView<global_ordinal_t> rowind, 00272 const Teuchos::ArrayView<global_size_t> colptr, 00273 global_size_t& nnz, 00274 const Teuchos::Ptr<const Tpetra::Map<local_ordinal_t,global_ordinal_t,node_t> > colmap, 00275 EStorage_Ordering ordering, 00276 has_special_impl hsi) const; 00277 00278 void help_getCcs(const Teuchos::ArrayView<scalar_t> nzval, 00279 const Teuchos::ArrayView<global_ordinal_t> rowind, 00280 const Teuchos::ArrayView<global_size_t> colptr, 00281 global_size_t& nnz, 00282 const Teuchos::Ptr<const Tpetra::Map<local_ordinal_t,global_ordinal_t,node_t> > colmap, 00283 EStorage_Ordering ordering, 00284 no_special_impl nsi) const; 00285 00286 void do_getCcs(const Teuchos::ArrayView<scalar_t> nzval, 00287 const Teuchos::ArrayView<global_ordinal_t> rowind, 00288 const Teuchos::ArrayView<global_size_t> colptr, 00289 global_size_t& nnz, 00290 const Teuchos::Ptr<const Tpetra::Map<local_ordinal_t,global_ordinal_t,node_t> > colmap, 00291 EStorage_Ordering ordering, 00292 row_access ra) const; 00293 00294 void do_getCcs(const Teuchos::ArrayView<scalar_t> nzval, 00295 const Teuchos::ArrayView<global_ordinal_t> rowind, 00296 const Teuchos::ArrayView<global_size_t> colptr, 00297 global_size_t& nnz, 00298 const Teuchos::Ptr<const Tpetra::Map<local_ordinal_t,global_ordinal_t,node_t> > colmap, 00299 EStorage_Ordering ordering, 00300 col_access ca) const; 00301 00302 protected: 00303 // These methods will link to concrete implementations, and may 00304 // also be used by them 00305 00312 void getGlobalRowCopy(global_ordinal_t row, 00313 const Teuchos::ArrayView<global_ordinal_t>& indices, 00314 const Teuchos::ArrayView<scalar_t>& vals, 00315 size_t& nnz) const; 00316 00323 void getGlobalColCopy(global_ordinal_t col, 00324 const Teuchos::ArrayView<global_ordinal_t>& indices, 00325 const Teuchos::ArrayView<scalar_t>& vals, 00326 size_t& nnz) const; 00327 00328 size_t getMaxRowNNZ() const; 00329 00330 size_t getMaxColNNZ() const; 00331 00332 size_t getGlobalRowNNZ(global_ordinal_t row) const; 00333 00334 size_t getLocalRowNNZ(local_ordinal_t row) const; 00335 00336 size_t getGlobalColNNZ(global_ordinal_t col) const; 00337 00338 size_t getLocalColNNZ(local_ordinal_t col) const; 00339 00340 bool isLocallyIndexed() const; 00341 00342 bool isGloballyIndexed() const; 00343 00344 protected: 00345 const Teuchos::RCP<const Matrix> mat_; 00346 00347 // only need to be mutable for the initial assignment, is there 00348 // another way to do this? 00349 mutable Teuchos::RCP<const Tpetra::Map<local_ordinal_t,global_ordinal_t,node_t> > row_map_; 00350 00351 mutable Teuchos::RCP<const Tpetra::Map<local_ordinal_t,global_ordinal_t,node_t> > col_map_; 00352 00353 mutable Teuchos::RCP<const Teuchos::Comm<int> > comm_; 00354 00355 }; // end class MatrixAdapter 00356 00357 00358 // Factory creation method 00359 template <class Matrix> 00360 Teuchos::RCP<MatrixAdapter<Matrix> > 00361 createMatrixAdapter(Teuchos::RCP<Matrix> m); 00362 00363 template <class Matrix> 00364 Teuchos::RCP<const MatrixAdapter<Matrix> > 00365 createConstMatrixAdapter(Teuchos::RCP<const Matrix> m); 00366 00367 } // end namespace Amesos2 00368 00369 #endif // AMESOS2_MATRIXADAPTER_DECL_HPP
1.7.6.1