本文整理汇总了C++中teuchos::ArrayView::view方法的典型用法代码示例。如果您正苦于以下问题:C++ ArrayView::view方法的具体用法?C++ ArrayView::view怎么用?C++ ArrayView::view使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类teuchos::ArrayView
的用法示例。
在下文中一共展示了ArrayView::view方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rcp
void
MatrixAdapter<Matrix>::do_getCcs(const Teuchos::ArrayView<scalar_t> nzval,
const Teuchos::ArrayView<global_ordinal_t> rowind,
const Teuchos::ArrayView<typename MatrixAdapter<Matrix>::global_size_t> colptr,
typename MatrixAdapter<Matrix>::global_size_t& nnz,
const Teuchos::Ptr<const Tpetra::Map<local_ordinal_t,global_ordinal_t,node_t> > colmap,
EDistribution distribution,
EStorage_Ordering ordering,
col_access ca) const
{
using Teuchos::RCP;
using Teuchos::ArrayView;
using Teuchos::OrdinalTraits;
RCP<const type> get_mat;
if( *colmap == *this->col_map_ ){
// No need to redistribute
get_mat = rcp(this,false); // non-owning
} else {
get_mat = get(colmap, distribution);
}
// If all is well and good, then colmap == cmap
RCP<const Tpetra::Map<scalar_t,local_ordinal_t,global_ordinal_t> > cmap = get_mat->getColMap();
TEUCHOS_ASSERT( *colmap == *cmap );
ArrayView<global_ordinal_t> node_elements = cmap->getNodeElementList();
if( node_elements.size() == 0 ) return; // no more contribution
typename ArrayView<global_ordinal_t>::iterator col_it, col_end;
col_end = node_elements.end();
size_t colptr_ind = OrdinalTraits<size_t>::zero();
global_ordinal_t colInd = OrdinalTraits<global_ordinal_t>::zero();
for( col_it = node_elements.begin(); col_it != col_end; ++col_it ){
colptr[colptr_ind++] = colInd;
size_t colNNZ = getGlobalColNNZ(*col_it);
size_t nnzRet = 0;
ArrayView<global_ordinal_t> rowind_view = rowind.view(colInd,colNNZ);
ArrayView<scalar_t> nzval_view = nzval.view(colInd,colNNZ);
getGlobalColCopy(*col_it, rowind_view, nzval_view, nnzRet);
// It was suggested that instead of sorting each row's indices
// individually, that we instead do a double-transpose at the
// end, which would also lead to the indices being sorted.
if( ordering == SORTED_INDICES ){
Tpetra::sort2(rowind_view.begin(), rowind_view.end(), nzval_view.begin());
}
TEUCHOS_TEST_FOR_EXCEPTION( colNNZ != nnzRet,
std::runtime_error,
"Number of values returned different from "
"number of values reported");
colInd += colNNZ;
}
colptr[colptr_ind] = nnz = colInd;
}