本文整理汇总了C++中ArrayRCP::getRawPtr方法的典型用法代码示例。如果您正苦于以下问题:C++ ArrayRCP::getRawPtr方法的具体用法?C++ ArrayRCP::getRawPtr怎么用?C++ ArrayRCP::getRawPtr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArrayRCP
的用法示例。
在下文中一共展示了ArrayRCP::getRawPtr方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getNodeNumRows
void EpetraCrsMatrixT<EpetraGlobalOrdinal>::setAllValues(const ArrayRCP<size_t>& rowptr, const ArrayRCP<LocalOrdinal>& colind, const ArrayRCP<Scalar>& values) {
XPETRA_MONITOR("EpetraCrsMatrixT::setAllValues");
// Check sizes
TEUCHOS_TEST_FOR_EXCEPTION(Teuchos::as<size_t>(rowptr.size()) != getNodeNumRows()+1, Xpetra::Exceptions::RuntimeError,
"An exception is thrown to let you know that the size of your rowptr array is incorrect.");
TEUCHOS_TEST_FOR_EXCEPTION(values.size() != colind.size(), Xpetra::Exceptions::RuntimeError,
"An exception is thrown to let you know that you mismatched your pointers.");
// Check pointers
if (values.size() > 0) {
TEUCHOS_TEST_FOR_EXCEPTION(colind.getRawPtr() != mtx_->ExpertExtractIndices().Values(), Xpetra::Exceptions::RuntimeError,
"An exception is thrown to let you know that you mismatched your pointers.");
TEUCHOS_TEST_FOR_EXCEPTION(values.getRawPtr() != mtx_->ExpertExtractValues(), Xpetra::Exceptions::RuntimeError,
"An exception is thrown to let you know that you mismatched your pointers.");
}
// We have to make a copy here, it is unavoidable
// See comments in allocateAllValues
const size_t N = getNodeNumRows();
Epetra_IntSerialDenseVector& myRowptr = mtx_->ExpertExtractIndexOffset();
myRowptr.Resize(N+1);
for (size_t i = 0; i < N+1; i++)
myRowptr[i] = Teuchos::as<int>(rowptr[i]);
}
示例2: if
void
gathervPrint (std::ostream& out,
const std::string& s,
const Teuchos::Comm<int>& comm)
{
using Teuchos::ArrayRCP;
using Teuchos::CommRequest;
using Teuchos::ireceive;
using Teuchos::isend;
using Teuchos::outArg;
using Teuchos::RCP;
using Teuchos::wait;
const int myRank = comm.getRank ();
const int rootRank = 0;
if (myRank == rootRank) {
out << s; // Proc 0 prints its buffer first
}
const int numProcs = comm.getSize ();
const int sizeTag = 42;
const int msgTag = 43;
ArrayRCP<size_t> sizeBuf (1);
ArrayRCP<char> msgBuf; // to be resized later
RCP<CommRequest<int> > req;
for (int p = 1; p < numProcs; ++p) {
if (myRank == p) {
sizeBuf[0] = s.size ();
req = isend<int, size_t> (sizeBuf, rootRank, sizeTag, comm);
(void) wait<int> (comm, outArg (req));
const size_t msgSize = s.size ();
msgBuf.resize (msgSize + 1); // for the '\0'
std::copy (s.begin (), s.end (), msgBuf.begin ());
msgBuf[msgSize] = '\0';
req = isend<int, char> (msgBuf, rootRank, msgTag, comm);
(void) wait<int> (comm, outArg (req));
}
else if (myRank == rootRank) {
sizeBuf[0] = 0; // just a precaution
req = ireceive<int, size_t> (sizeBuf, p, sizeTag, comm);
(void) wait<int> (comm, outArg (req));
const size_t msgSize = sizeBuf[0];
msgBuf.resize (msgSize + 1); // for the '\0'
req = ireceive<int, char> (msgBuf, p, msgTag, comm);
(void) wait<int> (comm, outArg (req));
std::string msg (msgBuf.getRawPtr ());
out << msg;
}
}
}
示例3: main
int main(int argc, char *argv[])
{
Teuchos::GlobalMPISession session(&argc, &argv);
RCP<const Comm<int> > comm = Teuchos::DefaultComm<int>::getComm();
int rank = comm->getRank();
Teuchos::RCP<Teuchos::FancyOStream> outStream =
Teuchos::VerboseObjectBase::getDefaultOStream();
Teuchos::EVerbosityLevel v=Teuchos::VERB_EXTREME;
typedef Tpetra::CrsMatrix<zscalar_t,zlno_t,zgno_t,znode_t> tmatrix_t;
typedef Tpetra::CrsGraph<zlno_t,zgno_t,znode_t> tgraph_t;
typedef Tpetra::Vector<zscalar_t,zlno_t,zgno_t,znode_t> tvector_t;
typedef Tpetra::MultiVector<zscalar_t,zlno_t,zgno_t,znode_t> tmvector_t;
typedef Xpetra::CrsMatrix<zscalar_t,zlno_t,zgno_t,znode_t> xmatrix_t;
typedef Xpetra::CrsGraph<zlno_t,zgno_t,znode_t> xgraph_t;
typedef Xpetra::Vector<zscalar_t,zlno_t,zgno_t,znode_t> xvector_t;
typedef Xpetra::MultiVector<zscalar_t,zlno_t,zgno_t,znode_t> xmvector_t;
typedef Xpetra::TpetraMap<zlno_t,zgno_t,znode_t> xtmap_t;
// Create object that can give us test Tpetra and Xpetra input.
RCP<UserInputForTests> uinput;
try{
uinput =
rcp(new UserInputForTests(testDataFilePath,std::string("simple"), comm, true));
}
catch(std::exception &e){
TEST_FAIL_AND_EXIT(*comm, 0, string("input ")+e.what(), 1);
}
/////////////////////////////////////////////////////////////////
// Tpetra::CrsMatrix
// Tpetra::CrsGraph
// Tpetra::Vector
// Tpetra::MultiVector
/////////////////////////////////////////////////////////////////
// XpetraTraits<Tpetra::CrsMatrix<zscalar_t, zlno_t, zgno_t, znode_t> >
{
RCP<tmatrix_t> M;
try{
M = uinput->getUITpetraCrsMatrix();
}
catch(std::exception &e){
TEST_FAIL_AND_EXIT(*comm, 0,
string("getTpetraCrsMatrix ")+e.what(), 1);
}
if (rank== 0)
std::cout << "Original Tpetra matrix " << M->getGlobalNumRows()
<< " x " << M->getGlobalNumCols() << std::endl;
M->describe(*outStream,v);
RCP<const xtmap_t> xmap(new xtmap_t(M->getRowMap()));
ArrayRCP<zgno_t> newRowIds = roundRobinMap(xmap);
zgno_t localNumRows = newRowIds.size();
RCP<const tmatrix_t> newM;
try{
newM = Zoltan2::XpetraTraits<tmatrix_t>::doMigration(*M,
localNumRows, newRowIds.getRawPtr());
}
catch(std::exception &e){
TEST_FAIL_AND_EXIT(*comm, 0,
string(" Zoltan2::XpetraTraits<tmatrix_t>::doMigration ")+e.what(), 1);
}
if (rank== 0)
std::cout << "Migrated Tpetra matrix" << std::endl;
newM->describe(*outStream,v);
}
// XpetraTraits<Tpetra::CrsGraph<zscalar_t, zlno_t, zgno_t, znode_t> >
{
RCP<tgraph_t> G;
try{
G = uinput->getUITpetraCrsGraph();
}
catch(std::exception &e){
TEST_FAIL_AND_EXIT(*comm, 0,
string("getTpetraCrsGraph ")+e.what(), 1);
}
if (rank== 0)
std::cout << "Original Tpetra graph" << std::endl;
G->describe(*outStream,v);
RCP<const xtmap_t> xmap(new xtmap_t(G->getRowMap()));
ArrayRCP<zgno_t> newRowIds = roundRobinMap(xmap);
zgno_t localNumRows = newRowIds.size();
//.........这里部分代码省略.........
示例4:
ArrayView<const T>::ArrayView( const ArrayRCP<const T> &arcp )
: ptr_(arcp.getRawPtr()), size_(arcp.size()), arcp_(arcp)
{}