本文整理汇总了C++中AbstractMatrix::writeObservationName方法的典型用法代码示例。如果您正苦于以下问题:C++ AbstractMatrix::writeObservationName方法的具体用法?C++ AbstractMatrix::writeObservationName怎么用?C++ AbstractMatrix::writeObservationName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AbstractMatrix
的用法示例。
在下文中一共展示了AbstractMatrix::writeObservationName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: set_all_obsnames_R
SEXP set_all_obsnames_R(SEXP s, SEXP names) {
//testDbg << "set_all_obsnames_R"<<endl;
AbstractMatrix * p = getAbstractMatrixFromSEXP(s);
if (p == NULL) {
error_R("pointer is NULL\n");
return R_NilValue;
}
//R_len_t nobss = (R_len_t) 0;
unsigned long int nobss = 0;
try {
nobss = p->getNumObservations();
} catch (int errcode) {
error_R("can not p->getNumObservations()\n");
return R_NilValue;
}
// check that length of SEXP names is the same!!!
for (unsigned long i = 0; i < nobss; i++) {
string obsname = CHAR(STRING_ELT(names,i));
try {
p->writeObservationName(i,FixedChar(obsname));
} catch (int errcode) {
error_R("can not set observation name for observation %ul\n",i);
return R_NilValue;
}
}
SEXP ret;
PROTECT(ret = allocVector(LGLSXP, 1));
LOGICAL(ret)[0] = TRUE;
UNPROTECT(1);
return ret;
}
示例2: set_all_obsnames_R
// !!!
SEXP set_all_obsnames_R(SEXP s, SEXP names) {
CHECK_PTR(s);
AbstractMatrix * p = (AbstractMatrix*) R_ExternalPtrAddr(s);
if (p == NULL) {
error_R("pointer is NULL\n");
return R_NilValue;
}
R_len_t nobss = (R_len_t) 0;
try {
nobss = p->getNumObservations();
} catch (int errcode) {
error_R("can not p->getNumObservations()\n");
return R_NilValue;
}
// check that length of SEXP names is the same!!!
for (unsigned long int i = 0; i < nobss; i++) {
std::string obsname = CHAR(STRING_ELT(names, i));
try {
p->writeObservationName(i, fixedchar(obsname));
} catch (int errcode) {
error_R("can not set observation name for observation %ul\n", i);
return R_NilValue;
}
}
SEXP ret;
PROTECT(ret = allocVector(LGLSXP, 1));
LOGICAL(ret)[0] = TRUE;
UNPROTECT(1);
return ret;
}