本文整理汇总了C++中teuchos::ArrayRCP::getRawPtr方法的典型用法代码示例。如果您正苦于以下问题:C++ ArrayRCP::getRawPtr方法的具体用法?C++ ArrayRCP::getRawPtr怎么用?C++ ArrayRCP::getRawPtr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类teuchos::ArrayRCP
的用法示例。
在下文中一共展示了ArrayRCP::getRawPtr方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: int
bool Tpetra::Utils::parseRfmt(Teuchos::ArrayRCP<char> fmt, int &perline, int &width, int &prec, char &valformat) {
TEUCHOS_TEST_FOR_EXCEPT(fmt.size() != 0 && fmt[fmt.size()-1] != '\0');
std::transform(fmt.begin(), fmt.end(), fmt, static_cast < int(*)(int) > (std::toupper));
// find the first left paren '(' and the last right paren ')'
Teuchos::ArrayRCP<char>::iterator firstLeftParen = std::find( fmt.begin(), fmt.end(), '(');
Teuchos::ArrayRCP<char>::iterator lastRightParen = std::find(std::reverse_iterator<Teuchos::ArrayRCP<char>::iterator>(fmt.end()),
std::reverse_iterator<Teuchos::ArrayRCP<char>::iterator>(fmt.begin()),
')').base()-1;
// select the substring between the parens, including them
// if neither was found, set the string to empty
if (firstLeftParen == fmt.end() || lastRightParen == fmt.begin()) {
fmt.resize(0 + 1);
fmt[0] = '\0';
}
else {
fmt += (firstLeftParen - fmt.begin());
size_t newLen = lastRightParen - firstLeftParen + 1;
fmt.resize(newLen + 1);
fmt[newLen] = '\0';
}
if (std::find(fmt.begin(),fmt.end(),'P') != fmt.end()) {
// not supported
return true;
}
bool error = true;
if (std::sscanf(fmt.getRawPtr(),"(%d%c%d.%d)",&perline,&valformat,&width,&prec) == 4) {
if (valformat == 'E' || valformat == 'D' || valformat == 'F') {
error = false;
}
}
return error;
}
示例2: rcp
// =============================================================================
Teuchos::RCP<Epetra_Map>
VIO::EpetraMesh::Reader::
createComplexValuesMap_ ( const Epetra_Map & nodesMap
) const
{
// get view for the global indices of the global elements
int numMyElements = nodesMap.NumMyElements();
Teuchos::ArrayRCP<int> myGlobalElements( numMyElements );
nodesMap.MyGlobalElements( myGlobalElements.getRawPtr() );
// Construct the map in such a way that all complex entries on processor K
// are split up into real and imaginary part, which will both reside on
// processor K again.
int numMyComplexElements = 2*numMyElements;
Teuchos::ArrayRCP<int> myComplexGlobalElements ( numMyComplexElements );
for ( int k = 0; k < numMyElements; k++ )
{
myComplexGlobalElements[2*k ] = 2 * myGlobalElements[k];
myComplexGlobalElements[2*k+1] = 2 * myGlobalElements[k] + 1;
}
return Teuchos::rcp ( new Epetra_Map ( -1,
myComplexGlobalElements.size(),
myComplexGlobalElements.getRawPtr(),
nodesMap.IndexBase(),
nodesMap.Comm()
)
);
}
示例3: errStr
void Tpetra::Utils::readHBHeader(std::ifstream &fin, Teuchos::ArrayRCP<char> &Title, Teuchos::ArrayRCP<char> &Key, Teuchos::ArrayRCP<char> &Type,
int &Nrow, int &Ncol, int &Nnzero, int &Nrhs,
Teuchos::ArrayRCP<char> &Ptrfmt, Teuchos::ArrayRCP<char> &Indfmt, Teuchos::ArrayRCP<char> &Valfmt, Teuchos::ArrayRCP<char> &Rhsfmt,
int &Ptrcrd, int &Indcrd, int &Valcrd, int &Rhscrd, Teuchos::ArrayRCP<char> &Rhstype) {
int Totcrd, Neltvl, Nrhsix;
const int MAXLINE = 81;
char line[MAXLINE];
//
Title.resize(72 + 1); std::fill(Title.begin(), Title.end(), '\0');
Key.resize(8 + 1); std::fill(Key.begin(), Key.end(), '\0');
Type.resize(3 + 1); std::fill(Type.begin(), Type.end(), '\0');
Ptrfmt.resize(16 + 1); std::fill(Ptrfmt.begin(), Ptrfmt.end(), '\0');
Indfmt.resize(16 + 1); std::fill(Indfmt.begin(), Indfmt.end(), '\0');
Valfmt.resize(20 + 1); std::fill(Valfmt.begin(), Valfmt.end(), '\0');
Rhsfmt.resize(20 + 1); std::fill(Rhsfmt.begin(), Rhsfmt.end(), '\0');
//
const std::string errStr("Tpetra::Utils::readHBHeader(): Improperly formatted H/B file: ");
/* First line: (A72,A8) */
fin.getline(line,MAXLINE);
TEUCHOS_TEST_FOR_EXCEPTION( std::sscanf(line,"%*s") < 0, std::runtime_error, errStr << "error buffering line.");
(void)std::sscanf(line, "%72c%8[^\n]", Title.getRawPtr(), Key.getRawPtr());
/* Second line: (5I14) or (4I14) */
fin.getline(line,MAXLINE);
TEUCHOS_TEST_FOR_EXCEPTION(std::sscanf(line,"%*s") < 0, std::runtime_error, errStr << "error buffering line.");
if ( std::sscanf(line,"%14d%14d%14d%14d%14d",&Totcrd,&Ptrcrd,&Indcrd,&Valcrd,&Rhscrd) != 5 ) {
Rhscrd = 0;
TEUCHOS_TEST_FOR_EXCEPTION(std::sscanf(line,"%14d%14d%14d%14d",&Totcrd,&Ptrcrd,&Indcrd,&Valcrd) != 4, std::runtime_error, errStr << "error reading pointers (line 2)");
}
/* Third line: (A3, 11X, 4I14) */
fin.getline(line,MAXLINE);
TEUCHOS_TEST_FOR_EXCEPTION(std::sscanf(line,"%*s") < 0, std::runtime_error, errStr << "error buffering line.");
TEUCHOS_TEST_FOR_EXCEPTION(std::sscanf(line, "%3c%14i%14i%14i%14i", Type.getRawPtr(),&Nrow,&Ncol,&Nnzero,&Neltvl) != 5 , std::runtime_error, errStr << "error reading matrix meta-data (line 3)");
std::transform(Type.begin(), Type.end(), Type.begin(), static_cast < int(*)(int) > (std::toupper));
/* Fourth line: */
fin.getline(line,MAXLINE);
TEUCHOS_TEST_FOR_EXCEPTION(std::sscanf(line,"%*s") < 0, std::runtime_error, errStr << "error buffering line.");
if (Rhscrd != 0) {
TEUCHOS_TEST_FOR_EXCEPTION(std::sscanf(line,"%16c%16c%20c%20c",Ptrfmt.getRawPtr(),Indfmt.getRawPtr(),Valfmt.getRawPtr(),Rhsfmt.getRawPtr()) != 4, std::runtime_error, errStr << "error reading formats (line 4)");
}
else {
TEUCHOS_TEST_FOR_EXCEPTION(std::sscanf(line,"%16c%16c%20c",Ptrfmt.getRawPtr(),Indfmt.getRawPtr(),Valfmt.getRawPtr()) != 3, std::runtime_error, errStr << "error reading formats (line 4)");
}
/* (Optional) Fifth line: */
if (Rhscrd != 0 ) {
Rhstype.resize(3 + 1,'\0');
fin.getline(line,MAXLINE);
TEUCHOS_TEST_FOR_EXCEPTION(std::sscanf(line,"%*s") < 0, std::runtime_error, errStr << "error buffering line.");
TEUCHOS_TEST_FOR_EXCEPTION(std::sscanf(line,"%3c%14d%14d", Rhstype.getRawPtr(), &Nrhs, &Nrhsix) != 3, std::runtime_error, errStr << "error reading right-hand-side meta-data (line 5)");
}
}
示例4: testNormalizeMat
int testNormalizeMat(RCP<MatOrthoManager<ST,MV,OP> > OM, RCP<const MV> S)
{
typedef MultiVecTraits<double,MV> MVT;
typedef OperatorTraits<double,MV,OP> OPT;
typedef ScalarTraits<double> SCT;
typedef SCT::magnitudeType MT;
const ST ONE = SCT::one();
const MT ZERO = SCT::magnitude(SCT::zero());
const int sizeS = MVT::GetNumberVecs(*S);
int numerr = 0;
bool hasM = (OM->getOp() != null);
std::ostringstream sout;
//
// output tests:
// <S_out,S_out> = I
// S_in = S_out B
//
// we will loop over an integer specifying the test combinations
// the bit pattern for the different tests is listed in parenthesis
//
// for each of the following, we should test B
//
// if hasM:
// with and without MS (1)
//
// as hasM controls the upper level bits, we need only run test case 0 if hasM==false
// otherwise, we run test cases 0-1
//
int numtests;
RCP<MV> MS;
if (hasM) {
MS = MVT::Clone(*S,sizeS);
OPT::Apply(*(OM->getOp()),*S ,*MS);
numtests = 2;
}
else {
numtests = 1;
}
for (int t=0; t<numtests; t++) {
// pointers to simplify calls below
RCP<MV> lclMS;
if ( t & 1 ) {
lclMS = MS;
}
Teuchos::ArrayRCP<ST> Bdata = Teuchos::arcp<ST>(sizeS*sizeS);
RCP<SerialDenseMatrix<int,ST> > B = rcp( new SerialDenseMatrix<int,ST>(Teuchos::View,Bdata.getRawPtr(),sizeS,sizeS,sizeS) );
try {
// call routine
// test all outputs for correctness
// here is where the outputs go
RCP<MV> Scopy, MScopy;
int ret;
// copies of S,MS
Scopy = MVT::CloneCopy(*S);
if (lclMS != Teuchos::null) {
MScopy = MVT::CloneCopy(*lclMS);
}
// randomize this data, it should be overwritten
B->random();
// run test
ret = OM->normalizeMat(*Scopy,B,MScopy);
sout << "normalizeMat() returned rank " << ret << endl;
if (ret == 0) {
sout << " Cannot continue." << endl;
numerr++;
break;
}
// normalizeMat() is only required to return a
// basis of rank "ret"
// this is what we will test:
// the first "ret" columns in Scopy, MScopy
// the first "ret" rows in B
// get pointers to the parts that we want
if (ret < sizeS) {
vector<int> ind(ret);
for (int i=0; i<ret; i++) {
ind[i] = i;
}
Scopy = MVT::CloneViewNonConst(*Scopy,ind);
if (MScopy != null) {
MScopy = MVT::CloneViewNonConst(*MScopy,ind);
}
B = rcp( new SerialDenseMatrix<int,ST>(Teuchos::View,Bdata.getRawPtr(),ret,ret,sizeS) );
}
// test all outputs for correctness
// MS == M*S
if (MScopy != null) {
RCP<MV> tmp = MVT::Clone(*Scopy,ret);
OPT::Apply(*(OM->getOp()),*Scopy,*tmp);
MT err = MVDiff(*tmp,*MScopy);
//.........这里部分代码省略.........