45 #ifndef AMESOS2_MATRIXADAPTER_DEF_HPP
46 #define AMESOS2_MATRIXADAPTER_DEF_HPP
47 #include <Tpetra_Util.hpp>
48 #include "Amesos2_MatrixAdapter_decl.hpp"
49 #include "Amesos2_ConcreteMatrixAdapter_def.hpp"
56 template <
class Matrix >
57 MatrixAdapter<Matrix>::MatrixAdapter(
const Teuchos::RCP<Matrix> m)
60 comm_ =
static_cast<const adapter_t*
>(
this)->getComm_impl();
61 col_map_ =
static_cast<const adapter_t*
>(
this)->getColMap_impl();
62 row_map_ =
static_cast<const adapter_t*
>(
this)->getRowMap_impl();
65 template <
class Matrix >
67 MatrixAdapter<Matrix>::getCrs(
const Teuchos::ArrayView<scalar_t> nzval,
68 const Teuchos::ArrayView<global_ordinal_t> colind,
69 const Teuchos::ArrayView<
typename MatrixAdapter<Matrix>::global_size_t> rowptr,
70 typename MatrixAdapter<Matrix>::global_size_t& nnz,
71 const Teuchos::Ptr<
const Tpetra::Map<local_ordinal_t, global_ordinal_t, node_t> > rowmap,
75 help_getCrs(nzval, colind, rowptr,
76 nnz, rowmap, distribution, ordering,
77 typename adapter_t::get_crs_spec());
80 template <
class Matrix >
81 template<
typename KV_S,
typename KV_GO,
typename KV_GS>
83 MatrixAdapter<Matrix>::getCrs_kokkos_view(KV_S & nzval,
86 typename MatrixAdapter<Matrix>::global_size_t& nnz,
87 const Teuchos::Ptr<
const Tpetra::Map<local_ordinal_t, global_ordinal_t, node_t> > rowmap,
91 help_getCrs_kokkos_view(nzval, colind, rowptr,
92 nnz, rowmap, distribution, ordering,
93 typename adapter_t::get_crs_spec());
96 template <
class Matrix >
98 MatrixAdapter<Matrix>::getCrs(
const Teuchos::ArrayView<scalar_t> nzval,
99 const Teuchos::ArrayView<global_ordinal_t> colind,
100 const Teuchos::ArrayView<
typename MatrixAdapter<Matrix>::global_size_t> rowptr,
101 typename MatrixAdapter<Matrix>::global_size_t& nnz,
105 const Teuchos::RCP<const Tpetra::Map<local_ordinal_t,global_ordinal_t,node_t> > rowmap
106 = Util::getDistributionMap<local_ordinal_t,global_ordinal_t,global_size_t,node_t>(distribution,
107 this->getGlobalNumRows(),
109 this->getCrs(nzval, colind, rowptr, nnz, Teuchos::ptrInArg(*rowmap), ordering, distribution);
112 template <
class Matrix >
114 MatrixAdapter<Matrix>::getCcs(
const Teuchos::ArrayView<scalar_t> nzval,
115 const Teuchos::ArrayView<global_ordinal_t> rowind,
116 const Teuchos::ArrayView<
typename MatrixAdapter<Matrix>::global_size_t> colptr,
117 typename MatrixAdapter<Matrix>::global_size_t& nnz,
118 const Teuchos::Ptr<
const Tpetra::Map<local_ordinal_t, global_ordinal_t, node_t> > colmap,
122 help_getCcs(nzval, rowind, colptr,
123 nnz, colmap, distribution, ordering,
124 typename adapter_t::get_ccs_spec());
127 template <
class Matrix >
128 template<
typename KV_S,
typename KV_GO,
typename KV_GS>
130 MatrixAdapter<Matrix>::getCcs_kokkos_view(KV_S & nzval,
133 typename MatrixAdapter<Matrix>::global_size_t& nnz,
134 const Teuchos::Ptr<
const Tpetra::Map<local_ordinal_t, global_ordinal_t, node_t> > rowmap,
138 help_getCcs_kokkos_view(nzval, colind, rowptr,
139 nnz, rowmap, distribution, ordering,
140 typename adapter_t::get_ccs_spec());
143 template <
class Matrix >
145 MatrixAdapter<Matrix>::getCcs(
const Teuchos::ArrayView<scalar_t> nzval,
146 const Teuchos::ArrayView<global_ordinal_t> rowind,
147 const Teuchos::ArrayView<
typename MatrixAdapter<Matrix>::global_size_t> colptr,
148 typename MatrixAdapter<Matrix>::global_size_t& nnz,
152 const Teuchos::RCP<const Tpetra::Map<local_ordinal_t,global_ordinal_t,node_t> > colmap
153 = Util::getDistributionMap<local_ordinal_t,global_ordinal_t,global_size_t,node_t>(distribution,
154 this->getGlobalNumCols(),
156 this->getCcs(nzval, rowind, colptr, nnz, Teuchos::ptrInArg(*colmap), ordering, distribution);
159 template <
class Matrix >
160 typename MatrixAdapter<Matrix>::global_size_t
163 return static_cast<const adapter_t*
>(
this)->getGlobalNumRows_impl();
166 template <
class Matrix >
167 typename MatrixAdapter<Matrix>::global_size_t
170 return static_cast<const adapter_t*
>(
this)->getGlobalNumCols_impl();
173 template <
class Matrix >
174 typename MatrixAdapter<Matrix>::global_size_t
179 return (row_map_ != Teuchos::null) ? row_map_->getIndexBase() : 0;
182 template <
class Matrix >
183 typename MatrixAdapter<Matrix>::global_size_t
188 return (col_map_ != Teuchos::null) ? col_map_->getIndexBase() : 0;
191 template <
class Matrix >
192 typename MatrixAdapter<Matrix>::global_size_t
195 return static_cast<const adapter_t*
>(
this)->getGlobalNNZ_impl();
198 template <
class Matrix >
202 return row_map_->getNodeNumElements();
205 template <
class Matrix >
209 return col_map_->getNodeNumElements();
212 template <
class Matrix >
216 return static_cast<const adapter_t*
>(
this)->getLocalNNZ_impl();
220 template <
class Matrix >
224 std::ostringstream oss;
225 oss <<
"Amesos2::MatrixAdapter wrapping: ";
230 template <
class Matrix >
233 const Teuchos::EVerbosityLevel verbLevel)
const
236 template <
class Matrix >
237 typename MatrixAdapter<Matrix>::spmtx_ptr_t
240 return static_cast<const adapter_t*
>(
this)->getSparseRowPtr();
243 template <
class Matrix >
244 typename MatrixAdapter<Matrix>::spmtx_idx_t
247 return static_cast<const adapter_t*
>(
this)->getSparseColInd();
250 template <
class Matrix >
251 typename MatrixAdapter<Matrix>::spmtx_vals_t
254 return static_cast<const adapter_t*
>(
this)->getSparseValues();
257 template <
class Matrix >
258 template <
class KV >
261 return static_cast<const adapter_t*
>(
this)->getSparseRowPtr_kokkos_view(view);
264 template <
class Matrix >
265 template <
class KV >
268 return static_cast<const adapter_t*
>(
this)->getSparseColInd_kokkos_view(view);
271 template <
class Matrix >
272 template <
class KV >
275 return static_cast<const adapter_t*
>(
this)->getSparseValues_kokkos_view(view);
282 template <
class Matrix >
285 const Teuchos::ArrayView<global_ordinal_t> colind,
286 const Teuchos::ArrayView<
typename MatrixAdapter<Matrix>::global_size_t> rowptr,
287 typename MatrixAdapter<Matrix>::global_size_t& nnz,
288 const Teuchos::Ptr<
const Tpetra::Map<local_ordinal_t,global_ordinal_t,node_t> > rowmap,
293 static_cast<const adapter_t*
>(
this)->getCrs_spec(nzval, colind, rowptr,
294 nnz, rowmap, ordering);
297 template <
class Matrix >
299 MatrixAdapter<Matrix>::help_getCrs(
const Teuchos::ArrayView<scalar_t> nzval,
300 const Teuchos::ArrayView<global_ordinal_t> colind,
301 const Teuchos::ArrayView<
typename MatrixAdapter<Matrix>::global_size_t> rowptr,
302 typename MatrixAdapter<Matrix>::global_size_t& nnz,
303 const Teuchos::Ptr<
const Tpetra::Map<local_ordinal_t,global_ordinal_t,node_t> > rowmap,
306 no_special_impl nsi)
const
311 do_getCrs(nzval, colind, rowptr,
312 nnz, rowmap, distribution, ordering,
313 typename adapter_t::major_access());
316 template <
class Matrix >
317 template<
typename KV_S,
typename KV_GO,
typename KV_GS>
319 MatrixAdapter<Matrix>::help_getCrs_kokkos_view(KV_S & nzval,
322 typename MatrixAdapter<Matrix>::global_size_t& nnz,
323 const Teuchos::Ptr<
const Tpetra::Map<local_ordinal_t,global_ordinal_t,node_t> > rowmap,
326 no_special_impl nsi)
const
331 do_getCrs_kokkos_view(nzval, colind, rowptr,
332 nnz, rowmap, distribution, ordering,
333 typename adapter_t::major_access());
336 template <
class Matrix >
338 MatrixAdapter<Matrix>::do_getCrs(
const Teuchos::ArrayView<scalar_t> nzval,
339 const Teuchos::ArrayView<global_ordinal_t> colind,
340 const Teuchos::ArrayView<
typename MatrixAdapter<Matrix>::global_size_t> rowptr,
341 typename MatrixAdapter<Matrix>::global_size_t& nnz,
342 const Teuchos::Ptr<
const Tpetra::Map<local_ordinal_t,global_ordinal_t,node_t> > rowmap,
349 using Teuchos::ArrayView;
350 using Teuchos::OrdinalTraits;
355 RCP<const type> get_mat;
356 if( *rowmap == *this->row_map_ && distribution != CONTIGUOUS_AND_ROOTED ){
358 get_mat = rcp(
this,
false);
360 get_mat =
get(rowmap, distribution);
371 RCP<const Tpetra::Map<local_ordinal_t,global_ordinal_t,node_t> > rmap = get_mat->getRowMap();
372 ArrayView<const global_ordinal_t> node_elements = rmap->getNodeElementList();
373 if( node_elements.size() == 0 )
return;
375 typename ArrayView<const global_ordinal_t>::iterator row_it, row_end;
376 row_end = node_elements.end();
378 size_t rowptr_ind = OrdinalTraits<size_t>::zero();
379 global_ordinal_t rowInd = OrdinalTraits<global_ordinal_t>::zero();
380 for( row_it = node_elements.begin(); row_it != row_end; ++row_it ){
381 rowptr[rowptr_ind++] = rowInd;
382 size_t rowNNZ = get_mat->getGlobalRowNNZ(*row_it);
383 size_t nnzRet = OrdinalTraits<size_t>::zero();
384 ArrayView<global_ordinal_t> colind_view = colind.view(rowInd,rowNNZ);
385 ArrayView<scalar_t> nzval_view = nzval.view(rowInd,rowNNZ);
387 get_mat->getGlobalRowCopy(*row_it, colind_view, nzval_view, nnzRet);
388 for (
size_t rr = 0; rr < nnzRet ; rr++)
390 colind_view[rr] = colind_view[rr] - rmap->getIndexBase();
396 if( ordering == SORTED_INDICES ){
397 Tpetra::sort2(colind_view.begin(), colind_view.end(), nzval_view.begin());
400 TEUCHOS_TEST_FOR_EXCEPTION( rowNNZ != nnzRet,
402 "Number of values returned different from "
403 "number of values reported");
406 rowptr[rowptr_ind] = nnz = rowInd;
409 template <
class Matrix >
410 template<
typename KV_S,
typename KV_GO,
typename KV_GS>
412 MatrixAdapter<Matrix>::do_getCrs_kokkos_view(KV_S & nzval,
415 typename MatrixAdapter<Matrix>::global_size_t& nnz,
416 const Teuchos::Ptr<
const Tpetra::Map<local_ordinal_t,global_ordinal_t,node_t> > rowmap,
426 if(this->row_map_ == Teuchos::null) {
427 this->returnValues_kokkos_view(nzval);
428 this->returnRowPtr_kokkos_view(rowptr);
429 this->returnColInd_kokkos_view(colind);
436 using Teuchos::ArrayView;
437 using Teuchos::OrdinalTraits;
442 Kokkos::View<scalar_t*, Kokkos::HostSpace>
443 mat_nzval(Kokkos::ViewAllocateWithoutInitializing(
"mat_nzval"), nzval.size());
444 ArrayView<scalar_t> nzval_arrayview(mat_nzval.data(), nzval.size());
446 Kokkos::View<global_ordinal_t*, Kokkos::HostSpace>
447 mat_colind(Kokkos::ViewAllocateWithoutInitializing(
"mat_colind"), colind.size());
448 ArrayView<global_ordinal_t> colind_arrayview(mat_colind.data(), colind.size());
451 typename KV_GS::HostMirror host_rowptr = Kokkos::create_mirror_view(rowptr);
455 RCP<const type> get_mat;
456 if( *rowmap == *this->row_map_ && distribution != CONTIGUOUS_AND_ROOTED ){
458 get_mat = rcp(
this,
false);
460 get_mat =
get(rowmap, distribution);
471 RCP<const Tpetra::Map<local_ordinal_t,global_ordinal_t,node_t> > rmap = get_mat->getRowMap();
472 ArrayView<const global_ordinal_t> node_elements = rmap->getNodeElementList();
473 if( node_elements.size() == 0 )
return;
475 typename ArrayView<const global_ordinal_t>::iterator row_it, row_end;
476 row_end = node_elements.end();
478 size_t rowptr_ind = OrdinalTraits<size_t>::zero();
479 global_ordinal_t rowInd = OrdinalTraits<global_ordinal_t>::zero();
481 for( row_it = node_elements.begin(); row_it != row_end; ++row_it ){
482 host_rowptr(rowptr_ind++) = rowInd;
483 size_t rowNNZ = get_mat->getGlobalRowNNZ(*row_it);
484 size_t nnzRet = OrdinalTraits<size_t>::zero();
485 ArrayView<global_ordinal_t> colind_view = colind_arrayview.view(rowInd,rowNNZ);
486 ArrayView<scalar_t> nzval_view = nzval_arrayview.view(rowInd,rowNNZ);
488 get_mat->getGlobalRowCopy(*row_it, colind_view, nzval_view, nnzRet);
489 for (
size_t rr = 0; rr < nnzRet ; rr++) {
490 colind_view[rr] -= rmap->getIndexBase();
496 if( ordering == SORTED_INDICES ) {
497 Tpetra::sort2(colind_view.begin(), colind_view.end(), nzval_view.begin());
500 TEUCHOS_TEST_FOR_EXCEPTION( rowNNZ != nnzRet,
502 "Number of values returned different from "
503 "number of values reported");
506 host_rowptr(rowptr_ind) = nnz = rowInd;
508 deep_copy_or_assign_view(nzval, mat_nzval);
509 deep_copy_or_assign_view(colind, mat_colind);
510 deep_copy_or_assign_view(rowptr, host_rowptr);
514 template <
class Matrix >
516 MatrixAdapter<Matrix>::do_getCrs(
const Teuchos::ArrayView<scalar_t> nzval,
517 const Teuchos::ArrayView<global_ordinal_t> colind,
518 const Teuchos::ArrayView<
typename MatrixAdapter<Matrix>::global_size_t> rowptr,
519 typename MatrixAdapter<Matrix>::global_size_t& nnz,
520 const Teuchos::Ptr<
const Tpetra::Map<local_ordinal_t,global_ordinal_t,node_t> > rowmap,
525 using Teuchos::Array;
528 Array<scalar_t> nzval_tmp(nzval.size(), 0);
529 Array<global_ordinal_t> rowind(colind.size(), 0);
530 Array<global_size_t> colptr(this->getGlobalNumCols() + 1);
531 this->getCcs(nzval_tmp(), rowind(), colptr(), nnz, rowmap, ordering, distribution);
533 if( !nzval.is_null() && !colind.is_null() && !rowptr.is_null() )
534 Util::transpose(nzval_tmp(), rowind(), colptr(), nzval, colind, rowptr);
537 template <
class Matrix >
539 MatrixAdapter<Matrix>::help_getCcs(
const Teuchos::ArrayView<scalar_t> nzval,
540 const Teuchos::ArrayView<global_ordinal_t> rowind,
541 const Teuchos::ArrayView<
typename MatrixAdapter<Matrix>::global_size_t> colptr,
542 typename MatrixAdapter<Matrix>::global_size_t& nnz,
543 const Teuchos::Ptr<
const Tpetra::Map<local_ordinal_t,global_ordinal_t,node_t> > colmap,
546 has_special_impl)
const
548 static_cast<const adapter_t*
>(
this)->getCcs_spec(nzval, rowind, colptr,
549 nnz, colmap, ordering);
552 template <
class Matrix >
554 MatrixAdapter<Matrix>::help_getCcs(
const Teuchos::ArrayView<scalar_t> nzval,
555 const Teuchos::ArrayView<global_ordinal_t> rowind,
556 const Teuchos::ArrayView<
typename MatrixAdapter<Matrix>::global_size_t> colptr,
557 typename MatrixAdapter<Matrix>::global_size_t& nnz,
558 const Teuchos::Ptr<
const Tpetra::Map<local_ordinal_t,global_ordinal_t,node_t> > colmap,
561 no_special_impl nsi)
const
565 do_getCcs(nzval, rowind, colptr,
566 nnz, colmap, distribution, ordering,
567 typename adapter_t::major_access());
570 template <
class Matrix >
571 template<
typename KV_S,
typename KV_GO,
typename KV_GS>
573 MatrixAdapter<Matrix>::help_getCcs_kokkos_view(KV_S & nzval,
576 typename MatrixAdapter<Matrix>::global_size_t& nnz,
577 const Teuchos::Ptr<
const Tpetra::Map<local_ordinal_t,global_ordinal_t,node_t> > rowmap,
580 no_special_impl nsi)
const
585 do_getCcs_kokkos_view(nzval, colind, rowptr,
586 nnz, rowmap, distribution, ordering,
587 typename adapter_t::major_access());
590 template <
class Matrix >
592 MatrixAdapter<Matrix>::do_getCcs(
const Teuchos::ArrayView<scalar_t> nzval,
593 const Teuchos::ArrayView<global_ordinal_t> rowind,
594 const Teuchos::ArrayView<
typename MatrixAdapter<Matrix>::global_size_t> colptr,
595 typename MatrixAdapter<Matrix>::global_size_t& nnz,
596 const Teuchos::Ptr<
const Tpetra::Map<local_ordinal_t,global_ordinal_t,node_t> > colmap,
601 using Teuchos::Array;
606 Array<scalar_t> nzval_tmp(nzval.size(), 0);
607 Array<global_ordinal_t> colind(rowind.size(), 0);
608 Array<global_size_t> rowptr(this->getGlobalNumRows() + 1);
609 this->getCrs(nzval_tmp(), colind(), rowptr(), nnz, colmap, ordering, distribution);
611 if( !nzval.is_null() && !rowind.is_null() && !colptr.is_null() )
612 Util::transpose(nzval_tmp(), colind(), rowptr(), nzval, rowind, colptr);
615 template <
class Matrix >
616 template<
typename KV_S,
typename KV_GO,
typename KV_GS>
618 MatrixAdapter<Matrix>::do_getCcs_kokkos_view(KV_S & nzval,
621 typename MatrixAdapter<Matrix>::global_size_t& nnz,
622 const Teuchos::Ptr<
const Tpetra::Map<local_ordinal_t,global_ordinal_t,node_t> > colmap,
627 using Teuchos::Array;
632 KV_S nzval_tmp(Kokkos::ViewAllocateWithoutInitializing(
"nzval_tmp"), nzval.size());
633 KV_GO colind(Kokkos::ViewAllocateWithoutInitializing(
"colind"), rowind.size());
634 KV_GS rowptr(Kokkos::ViewAllocateWithoutInitializing(
"rowptr"), this->getGlobalNumRows() + 1);
636 this->getCrs_kokkos_view(nzval_tmp, colind, rowptr, nnz, colmap, ordering, distribution);
638 if(nzval_tmp.size() && colind.size() && rowptr.size()) {
642 ArrayView<typename KV_S::value_type> av_nzval_tmp(nzval_tmp.data(), nzval_tmp.size());
643 ArrayView<typename KV_GO::value_type> av_colind(colind.data(), colind.size());
644 ArrayView<typename KV_GS::value_type> av_rowptr(rowptr.data(), rowptr.size());
645 ArrayView<typename KV_S::value_type> av_nzval(nzval.data(), nzval.size());
646 ArrayView<typename KV_GO::value_type> av_rowind(rowind.data(), rowind.size());
647 ArrayView<typename KV_GS::value_type> av_colptr(colptr.data(), colptr.size());
648 Util::transpose(av_nzval_tmp, av_colind, av_rowptr, av_nzval, av_rowind, av_colptr);
652 template <
class Matrix >
654 MatrixAdapter<Matrix>::do_getCcs(
const Teuchos::ArrayView<scalar_t> nzval,
655 const Teuchos::ArrayView<global_ordinal_t> rowind,
656 const Teuchos::ArrayView<
typename MatrixAdapter<Matrix>::global_size_t> colptr,
657 typename MatrixAdapter<Matrix>::global_size_t& nnz,
658 const Teuchos::Ptr<
const Tpetra::Map<local_ordinal_t,global_ordinal_t,node_t> > colmap,
664 using Teuchos::ArrayView;
665 using Teuchos::OrdinalTraits;
667 RCP<const type> get_mat;
668 if( *colmap == *this->col_map_ && distribution != CONTIGUOUS_AND_ROOTED ){
670 get_mat = rcp(
this,
false);
672 get_mat =
get(colmap, distribution);
676 RCP<const Tpetra::Map<scalar_t,local_ordinal_t,global_ordinal_t> > cmap = get_mat->getColMap();
677 TEUCHOS_ASSERT( *colmap == *cmap );
679 ArrayView<global_ordinal_t> node_elements = cmap->getNodeElementList();
680 if( node_elements.size() == 0 )
return;
682 typename ArrayView<global_ordinal_t>::iterator col_it, col_end;
683 col_end = node_elements.end();
685 size_t colptr_ind = OrdinalTraits<size_t>::zero();
686 global_ordinal_t colInd = OrdinalTraits<global_ordinal_t>::zero();
687 for( col_it = node_elements.begin(); col_it != col_end; ++col_it ){
688 colptr[colptr_ind++] = colInd;
689 size_t colNNZ = getGlobalColNNZ(*col_it);
691 ArrayView<global_ordinal_t> rowind_view = rowind.view(colInd,colNNZ);
692 ArrayView<scalar_t> nzval_view = nzval.view(colInd,colNNZ);
693 getGlobalColCopy(*col_it, rowind_view, nzval_view, nnzRet);
698 if( ordering == SORTED_INDICES ){
699 Tpetra::sort2(rowind_view.begin(), rowind_view.end(), nzval_view.begin());
702 TEUCHOS_TEST_FOR_EXCEPTION( colNNZ != nnzRet,
704 "Number of values returned different from "
705 "number of values reported");
708 colptr[colptr_ind] = nnz = colInd;
713 template <
class Matrix >
716 const Teuchos::ArrayView<global_ordinal_t>& indices,
717 const Teuchos::ArrayView<scalar_t>& vals,
720 static_cast<const adapter_t*
>(
this)->getGlobalRowCopy_impl(row, indices, vals, nnz);
723 template <
class Matrix >
726 const Teuchos::ArrayView<global_ordinal_t>& indices,
727 const Teuchos::ArrayView<scalar_t>& vals,
730 static_cast<const adapter_t*
>(
this)->getGlobalColCopy_impl(col, indices, vals, nnz);
733 template <
class Matrix >
737 return static_cast<const adapter_t*
>(
this)->getMaxRowNNZ_impl();
740 template <
class Matrix >
742 MatrixAdapter<Matrix>::getMaxColNNZ()
const
744 return static_cast<const adapter_t*
>(
this)->getMaxColNNZ_impl();
747 template <
class Matrix >
749 MatrixAdapter<Matrix>::getGlobalRowNNZ(global_ordinal_t row)
const
751 return static_cast<const adapter_t*
>(
this)->getGlobalRowNNZ_impl(row);
754 template <
class Matrix >
756 MatrixAdapter<Matrix>::getLocalRowNNZ(local_ordinal_t row)
const
758 return static_cast<const adapter_t*
>(
this)->getLocalRowNNZ_impl(row);
761 template <
class Matrix >
763 MatrixAdapter<Matrix>::getGlobalColNNZ(global_ordinal_t col)
const
765 return static_cast<const adapter_t*
>(
this)->getGlobalColNNZ_impl(col);
768 template <
class Matrix >
770 MatrixAdapter<Matrix>::getLocalColNNZ(local_ordinal_t col)
const
772 return static_cast<const adapter_t*
>(
this)->getLocalColNNZ_impl(col);
775 template <
class Matrix >
777 MatrixAdapter<Matrix>::isLocallyIndexed()
const
779 return static_cast<const adapter_t*
>(
this)->isLocallyIndexed_impl();
782 template <
class Matrix >
784 MatrixAdapter<Matrix>::isGloballyIndexed()
const
786 return static_cast<const adapter_t*
>(
this)->isGloballyIndexed_impl();
790 template <
class Matrix >
791 Teuchos::RCP<const MatrixAdapter<Matrix> >
792 MatrixAdapter<Matrix>::get(
const Teuchos::Ptr<
const Tpetra::Map<local_ordinal_t,global_ordinal_t,node_t> > map,
EDistribution distribution)
const
794 return static_cast<const adapter_t*
>(
this)->get_impl(map, distribution);
798 template <
class Matrix>
799 Teuchos::RCP<MatrixAdapter<Matrix> >
800 createMatrixAdapter(Teuchos::RCP<Matrix> m){
802 using Teuchos::rcp_const_cast;
804 if(m.is_null())
return Teuchos::null;
805 return( rcp(
new ConcreteMatrixAdapter<Matrix>(m)) );
808 template <
class Matrix>
809 Teuchos::RCP<const MatrixAdapter<Matrix> >
810 createConstMatrixAdapter(Teuchos::RCP<const Matrix> m){
812 using Teuchos::rcp_const_cast;
814 if(m.is_null())
return Teuchos::null;
815 return( rcp(
new ConcreteMatrixAdapter<Matrix>(rcp_const_cast<Matrix,const Matrix>(m))).getConst() );
820 #endif // AMESOS2_MATRIXADAPTER_DEF_HPP
EStorage_Ordering
Definition: Amesos2_TypeDecl.hpp:141
Indicates that the concrete class has a special implementation that should be called.
Definition: Amesos2_TypeDecl.hpp:82
void transpose(ArrayView< Scalar > vals, ArrayView< GlobalOrdinal > indices, ArrayView< GlobalSizeT > ptr, ArrayView< Scalar > trans_vals, ArrayView< GlobalOrdinal > trans_indices, ArrayView< GlobalSizeT > trans_ptr)
std::string description() const
Returns a short description of this Solver.
Definition: Amesos2_MatrixAdapter_def.hpp:222
A Matrix adapter interface for Amesos2.
Definition: Amesos2_MatrixAdapter_decl.hpp:76
EDistribution
Definition: Amesos2_TypeDecl.hpp:123