|
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_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, typename LocalOrdinal, typename GlobalOrdinal, typename Node, class DerivedMat> 00146 typename AbstractConcreteMatrixAdapter< 00147 Tpetra::RowMatrix<Scalar, 00148 LocalOrdinal, 00149 GlobalOrdinal, 00150 Node>, 00151 DerivedMat>::global_size_t 00152 AbstractConcreteMatrixAdapter< 00153 Tpetra::RowMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>, 00154 DerivedMat>::getGlobalNumRows_impl() const 00155 { 00156 return this->mat_->getGlobalNumRows(); 00157 } 00158 00159 template <typename Scalar, typename LocalOrdinal, typename GlobalOrdinal, typename Node, class DerivedMat> 00160 typename AbstractConcreteMatrixAdapter< 00161 Tpetra::RowMatrix<Scalar, 00162 LocalOrdinal, 00163 GlobalOrdinal, 00164 Node>, 00165 DerivedMat>::global_size_t 00166 AbstractConcreteMatrixAdapter< 00167 Tpetra::RowMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>, 00168 DerivedMat>::getGlobalNumCols_impl() const 00169 { 00170 return this->mat_->getGlobalNumCols(); 00171 } 00172 00173 template <typename Scalar, 00174 typename LocalOrdinal, 00175 typename GlobalOrdinal, 00176 typename Node, 00177 class DerivedMat> 00178 size_t 00179 AbstractConcreteMatrixAdapter< 00180 Tpetra::RowMatrix<Scalar, 00181 LocalOrdinal, 00182 GlobalOrdinal, 00183 Node>, 00184 DerivedMat>::getMaxRowNNZ_impl() const 00185 { 00186 return this->mat_->getGlobalMaxNumRowEntries(); 00187 } 00188 00189 template <typename Scalar, 00190 typename LocalOrdinal, 00191 typename GlobalOrdinal, 00192 typename Node, 00193 class DerivedMat> 00194 size_t 00195 AbstractConcreteMatrixAdapter< 00196 Tpetra::RowMatrix<Scalar, 00197 LocalOrdinal, 00198 GlobalOrdinal, 00199 Node>, 00200 DerivedMat>::getMaxColNNZ_impl() const 00201 { 00202 TEUCHOS_TEST_FOR_EXCEPTION( true, 00203 std::runtime_error, 00204 "Column access to row-based object not yet supported. " 00205 "Please contact the Amesos2 developers." ); 00206 return 0; 00207 } 00208 00209 template <typename Scalar, 00210 typename LocalOrdinal, 00211 typename GlobalOrdinal, 00212 typename Node, 00213 class DerivedMat> 00214 size_t 00215 AbstractConcreteMatrixAdapter< 00216 Tpetra::RowMatrix<Scalar, 00217 LocalOrdinal, 00218 GlobalOrdinal, 00219 Node>, 00220 DerivedMat>::getGlobalRowNNZ_impl(global_ordinal_t row) const 00221 { 00222 return this->mat_->getNumEntriesInGlobalRow(row); 00223 } 00224 00225 template <typename Scalar, 00226 typename LocalOrdinal, 00227 typename GlobalOrdinal, 00228 typename Node, 00229 class DerivedMat> 00230 size_t 00231 AbstractConcreteMatrixAdapter< 00232 Tpetra::RowMatrix<Scalar, 00233 LocalOrdinal, 00234 GlobalOrdinal, 00235 Node>, 00236 DerivedMat>::getLocalRowNNZ_impl(local_ordinal_t row) const 00237 { 00238 return this->mat_->getNumEntriesInLocalRow(row); 00239 } 00240 00241 template <typename Scalar, 00242 typename LocalOrdinal, 00243 typename GlobalOrdinal, 00244 typename Node, 00245 class DerivedMat> 00246 size_t 00247 AbstractConcreteMatrixAdapter< 00248 Tpetra::RowMatrix<Scalar, 00249 LocalOrdinal, 00250 GlobalOrdinal, 00251 Node>, 00252 DerivedMat>::getGlobalColNNZ_impl(global_ordinal_t col) const 00253 { 00254 TEUCHOS_TEST_FOR_EXCEPTION( true, 00255 std::runtime_error, 00256 "Column access to row-based object not yet supported. " 00257 "Please contact the Amesos2 developers." ); 00258 return 0; 00259 } 00260 00261 template <typename Scalar, 00262 typename LocalOrdinal, 00263 typename GlobalOrdinal, 00264 typename Node, 00265 class DerivedMat> 00266 size_t 00267 AbstractConcreteMatrixAdapter< 00268 Tpetra::RowMatrix<Scalar, 00269 LocalOrdinal, 00270 GlobalOrdinal, 00271 Node>, 00272 DerivedMat>::getLocalColNNZ_impl(local_ordinal_t col) const 00273 { 00274 TEUCHOS_TEST_FOR_EXCEPTION( true, 00275 std::runtime_error, 00276 "Column access to row-based object not yet supported. " 00277 "Please contact the Amesos2 developers." ); 00278 return 0; 00279 } 00280 00281 template <typename Scalar, 00282 typename LocalOrdinal, 00283 typename GlobalOrdinal, 00284 typename Node, 00285 class DerivedMat> 00286 const RCP<const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> > 00287 AbstractConcreteMatrixAdapter< 00288 Tpetra::RowMatrix<Scalar, 00289 LocalOrdinal, 00290 GlobalOrdinal, 00291 Node>, 00292 DerivedMat>:: getRowMap_impl() const 00293 { 00294 return this->mat_->getRowMap(); 00295 } 00296 00297 template <typename Scalar, 00298 typename LocalOrdinal, 00299 typename GlobalOrdinal, 00300 typename Node, 00301 class DerivedMat> 00302 const RCP<const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> > 00303 AbstractConcreteMatrixAdapter< 00304 Tpetra::RowMatrix<Scalar, 00305 LocalOrdinal, 00306 GlobalOrdinal, 00307 Node>, 00308 DerivedMat>::getColMap_impl() const 00309 { 00310 return this->mat_->getColMap(); 00311 } 00312 00313 template <typename Scalar, 00314 typename LocalOrdinal, 00315 typename GlobalOrdinal, 00316 typename Node, 00317 class DerivedMat> 00318 const RCP<const Teuchos::Comm<int> > 00319 AbstractConcreteMatrixAdapter< 00320 Tpetra::RowMatrix<Scalar, 00321 LocalOrdinal, 00322 GlobalOrdinal, 00323 Node>, 00324 DerivedMat>::getComm_impl() const 00325 { 00326 return this->mat_->getComm(); 00327 } 00328 00329 template <typename Scalar, 00330 typename LocalOrdinal, 00331 typename GlobalOrdinal, 00332 typename Node, 00333 class DerivedMat> 00334 bool 00335 AbstractConcreteMatrixAdapter< 00336 Tpetra::RowMatrix<Scalar, 00337 LocalOrdinal, 00338 GlobalOrdinal, 00339 Node>, 00340 DerivedMat>::isLocallyIndexed_impl() const 00341 { 00342 return this->mat_->isLocallyIndexed(); 00343 } 00344 00345 template <typename Scalar, 00346 typename LocalOrdinal, 00347 typename GlobalOrdinal, 00348 typename Node, 00349 class DerivedMat> 00350 bool 00351 AbstractConcreteMatrixAdapter< 00352 Tpetra::RowMatrix<Scalar, 00353 LocalOrdinal, 00354 GlobalOrdinal, 00355 Node>, 00356 DerivedMat>::isGloballyIndexed_impl() const 00357 { 00358 return this->mat_->isGloballyIndexed(); 00359 } 00360 00361 template <typename Scalar, typename LocalOrdinal, typename GlobalOrdinal, typename Node, class DerivedMat> 00362 RCP<const MatrixAdapter<DerivedMat> > 00363 AbstractConcreteMatrixAdapter< 00364 Tpetra::RowMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>, DerivedMat 00365 >::get_impl(const Teuchos::Ptr<const Tpetra::Map<local_ordinal_t,global_ordinal_t,node_t> > map) const 00366 { 00367 #ifdef __CUDACC__ 00368 // NVCC doesn't seem to like the static_cast, even though it is valid 00369 return dynamic_cast<ConcreteMatrixAdapter<DerivedMat>*>(this)->get_impl(map); 00370 #else 00371 return static_cast<ConcreteMatrixAdapter<DerivedMat>*>(this)->get_impl(map); 00372 #endif 00373 } 00374 00375 } // end namespace Amesos2 00376 00377 #endif // AMESOS2_TPETRAROWMATRIX_ABSTRACTMATRIXADAPTER_DEF_HPP
1.7.6.1