本文整理汇总了C++中ArrayXd::data方法的典型用法代码示例。如果您正苦于以下问题:C++ ArrayXd::data方法的具体用法?C++ ArrayXd::data怎么用?C++ ArrayXd::data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArrayXd
的用法示例。
在下文中一共展示了ArrayXd::data方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: matGet
void CMATLAB::matGet(string filename,ArrayXd &X,string Xname)
{
MATFile *pmat=matOpen(filename,string("r"));
if (!pmat) throw "CMATLAB::importFrom error: matlab.matOpen failed";
mxArray *pa=matGetVariable(pmat,Xname);
if (!pa) throw "CMATLAB::importFrom error: matlab.matGetVariable failed";
int N=mxGetNumberOfElements(pa);
if (N<=0) throw "CMATLAB::importFrom error: matlab.mxGetNumberOfElements failed";
X.resize(N);
memcpy((void *)(mxGetPr(pa)), (void *)X.data(), sizeof((double *)X.data()));
mxDestroyArray(pa);
if (!matClose(pmat)) throw "CMATLAB::importFrom error: matlab.matClose failed";
}
示例2: gesdd
int gesdd(MatrixXd& A, ArrayXd& S, MatrixXd& Vt) {
int info, mone = -1, m = A.rows(), n = A.cols();
std::vector<int> iwork(8 * n);
double wrk;
if (m < n || S.size() != n || Vt.rows() != n || Vt.cols() != n)
throw std::invalid_argument("dimension mismatch in gesvd");
F77_CALL(dgesdd)("O", &m, &n, A.data(), &m, S.data(), A.data(),
&m, Vt.data(), &n, &wrk, &mone, &iwork[0], &info);
int lwork(wrk);
std::vector<double> work(lwork);
F77_CALL(dgesdd)("O", &m, &n, A.data(), &m, S.data(), A.data(),
&m, Vt.data(), &n, &work[0], &lwork, &iwork[0], &info);
return info;
}
示例3: aic
double glmDist::aic(const ArrayXd& y, const ArrayXd& n, const ArrayXd& mu,
const ArrayXd& wt, double dev) const {
int nn = mu.size();
double ans =
::Rf_asReal(::Rf_eval(::Rf_lang6(as<SEXP>(d_aic),
as<SEXP>(NumericVector(y.data(), y.data() + nn)),
as<SEXP>(NumericVector(n.data(), n.data() + nn)),
as<SEXP>(NumericVector(mu.data(), mu.data() + nn)),
as<SEXP>(NumericVector(wt.data(), wt.data() + nn)),
PROTECT(::Rf_ScalarReal(dev))), d_rho));
UNPROTECT(1);
return ans;
}
示例4: matPut
void CMATLAB::matPut(string filename,const ArrayXd &X,string Xname)
{
MATFile *pmat=matOpen(filename,string("w"));
if (!pmat) throw "CMATLAB::exportTo error: matOpen failed";
mxArray *pa=mxCreateDoubleMatrix((int)X.size(),1);
if (!pa) throw "CMATLAB::exportTo error: mxCreateDoubleMatrix failed";
memcpy((void *)(mxGetPr(pa)), (void *)X.data(), X.size()*sizeof(double));
if (!matPutVariable(pmat,string("X"),pa)) throw "CMATLAB::exportTo error: matlab.matPutVariable failed";
mxDestroyArray(pa);
if (!matClose(pmat)) throw "CMATLAB::exportTo error: matlab.matClose failed";
}
示例5: updateXwts
void merPredD::updateXwts(const ArrayXd& sqrtXwt) {
if (d_Xwts.size() != sqrtXwt.size())
throw invalid_argument("updateXwts: dimension mismatch");
std::copy(sqrtXwt.data(), sqrtXwt.data() + sqrtXwt.size(), d_Xwts.data());
if (sqrtXwt.size() == d_V.rows()) { // W is diagonal
d_V = d_Xwts.asDiagonal() * d_X;
for (int j = 0; j < d_N; ++j)
for (MSpMatrixd::InnerIterator Utj(d_Ut, j), Ztj(d_Zt, j);
Utj && Ztj; ++Utj, ++Ztj)
Utj.valueRef() = Ztj.value() * d_Xwts.data()[j];
} else {
SpMatrixd W(d_V.rows(), sqrtXwt.size());
const double *pt = sqrtXwt.data();
W.reserve(sqrtXwt.size());
for (Index j = 0; j < W.cols(); ++j, ++pt) {
W.startVec(j);
W.insertBack(j % d_V.rows(), j) = *pt;
}
W.finalize();
d_V = W * d_X;
SpMatrixd Ut(d_Zt * W.adjoint());
if (Ut.cols() != d_Ut.cols())
throw std::runtime_error("Size mismatch in updateXwts");
// More complex code to handle the pruning of zeros
MVec(d_Ut.valuePtr(), d_Ut.nonZeros()).setZero();
for (int j = 0; j < d_Ut.outerSize(); ++j) {
MSpMatrixd::InnerIterator lhsIt(d_Ut, j);
for (SpMatrixd::InnerIterator rhsIt(Ut, j); rhsIt; ++rhsIt, ++lhsIt) {
Index k(rhsIt.index());
while (lhsIt && lhsIt.index() != k) ++lhsIt;
if (lhsIt.index() != k)
throw std::runtime_error("Pattern mismatch in updateXwts");
lhsIt.valueRef() = rhsIt.value();
}
}
}
d_VtV.setZero().selfadjointView<Eigen::Upper>().rankUpdate(d_V.adjoint());
updateL();
}
示例6: devResid
const ArrayXd glmDist::devResid(const ArrayXd &y, const ArrayXd &mu, const ArrayXd &wt) const {
int n = mu.size();
return as<ArrayXd>(::Rf_eval(::Rf_lang4(as<SEXP>(d_devRes),
as<SEXP>(NumericVector(y.data(), y.data() + n)),
as<SEXP>(NumericVector(mu.data(), mu.data() + n)),
as<SEXP>(NumericVector(wt.data(), wt.data() + n))
), d_rho));
}
示例7: variance
const ArrayXd glmDist::variance(const ArrayXd &mu) const {
return as<ArrayXd>(::Rf_eval(::Rf_lang2(as<SEXP>(d_variance),
as<SEXP>(Rcpp::NumericVector(mu.data(),
mu.data() + mu.size()))
), d_rho));
}
示例8: muEta
const ArrayXd glmLink::muEta(const ArrayXd &eta) const {
return as<ArrayXd>(::Rf_eval(::Rf_lang2(as<SEXP>(d_muEta),
as<SEXP>(Rcpp::NumericVector(eta.data(),
eta.data() + eta.size()))
), d_rho));
}
示例9: linkFun
const ArrayXd glmLink::linkFun(const ArrayXd& mu) const {
return as<ArrayXd>(::Rf_eval(::Rf_lang2(as<SEXP>(d_linkFun),
as<SEXP>(Rcpp::NumericVector(mu.data(),
mu.data() + mu.size()))
), d_rho));
}