当前位置: 首页>>代码示例>>C++>>正文


C++ ArrayXd::size方法代码示例

本文整理汇总了C++中ArrayXd::size方法的典型用法代码示例。如果您正苦于以下问题:C++ ArrayXd::size方法的具体用法?C++ ArrayXd::size怎么用?C++ ArrayXd::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ArrayXd的用法示例。


在下文中一共展示了ArrayXd::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Dplus

    inline ArrayXd lm::Dplus(const ArrayXd& d) {
	ArrayXd   di(d.size());
	double  comp(d.maxCoeff() * threshold());
	for (int j = 0; j < d.size(); ++j) di[j] = (d[j] < comp) ? 0. : 1./d[j];
	m_r          = (di != 0.).count();
	return di;
    }
开发者ID:Estoque86,项目名称:ndnSIM_MicTort,代码行数:7,代码来源:fastLm.cpp

示例2: X

ArrayXd GoSUM::CModelVariables::hcPoint2ModelPoint(const ArrayXd &x)
{
    if ( x.size()!=mvs.size() )   throw "GoSUM::CModelVariables::hcPoint2ModelPoint error: wrong dimension";
    int j,dim=int(x.size());
    ArrayXd X(dim);

    for ( j=0; j<dim; j++ )
    {   X(j)=mvs[j].generateSampleValue(x(j));  }

    return X;
}
开发者ID:davor-,项目名称:GoSum,代码行数:11,代码来源:Model.cpp

示例3: 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";

}
开发者ID:davor-,项目名称:GoSum,代码行数:12,代码来源:MatlabLibrary.cpp

示例4: SteadyState

SSFPSimple::SSFPSimple(const ArrayXd &flip, const double TR, const ArrayXd &phi) :
    SteadyState()
{
    m_TR = TR;
    m_flip = (flip * M_PI / 180.).replicate(phi.rows(), 1);
    m_nphi = phi.size();
    m_phi = ArrayXd::Zero(m_flip.size());
    int start = 0;
    for (int i = 0; i < phi.size(); i++) {
        m_phi.segment(start, flip.size()).setConstant(phi[i] * M_PI / 180.);
        start += flip.size();
    }
}
开发者ID:jamespooley,项目名称:QUIT,代码行数:13,代码来源:Sequence.cpp

示例5: p

NOMAD::Point CMADS::ArrayXd2NOMADPoint(const ArrayXd &x)
{
    int i,n=int(x.size());
    NOMAD::Point p(n);
    for ( i=0; i<n; i++ ) p[i]=x(i);
    return p;
}
开发者ID:davor-,项目名称:GoSum,代码行数:7,代码来源:MADSOptimization.cpp

示例6:

void GoSUM::CModelVariables::setNTuple(const ArrayXd &X,int _at)
{
    if ( X.size()!=mvs.size() ) throw "GoSUM::CModelVariables::setNTuple error: bad nTupe size";

    int i,N=int(mvs.size());
    for ( i=0; i<N; i++ ) mvs[i].setSampleValue(X(i),_at);
}
开发者ID:davor-,项目名称:GoSum,代码行数:7,代码来源:Model.cpp

示例7: Exception

void CMT::HistogramNonlinearity::setParameters(const ArrayXd& parameters) {
	if(parameters.size() != mHistogram.size())
		throw Exception("Wrong number of parameters.");

	for(int i = 0; i < mHistogram.size(); ++i)
		mHistogram[i] = parameters[i];
}
开发者ID:cajal,项目名称:cmt,代码行数:7,代码来源:nonlinearities.cpp

示例8: 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));
    }
开发者ID:L4R,项目名称:lme4,代码行数:8,代码来源:glmFamily.cpp

示例9: disp

    //@{
    double                   gammaDist::aic     (const ArrayXd& y, const ArrayXd& n, const ArrayXd& mu,
						 const ArrayXd& wt, double dev) const {
	double   nn(wt.sum());
	double disp(dev/nn);
	double   ans(0), invdisp(1./disp);
	for (int i = 0; i < mu.size(); ++i)
	    ans += wt[i] * ::Rf_dgamma(y[i], invdisp, mu[i] * disp, true);
	return -2. * ans + 2.;
    }
开发者ID:L4R,项目名称:lme4,代码行数:10,代码来源:glmFamily.cpp

示例10: computeBinWidth

double computeBinWidth(const MatrixXd& positions) {
	// assumes first col of positions corresponds to dominant eigenvect
	ArrayXd firstCol = positions.col(0).array();
	firstCol -= firstCol.mean();
	double SSE = firstCol.matrix().squaredNorm();
	double variance = SSE / firstCol.size();
	double std = sqrt(variance);
	double targetBinsPerStd = (MAX_HASH_VALUE - HASH_VALUE_OFFSET) / TARGET_HASH_SPREAD_STDS;
	return std / targetBinsPerStd;
}
开发者ID:dblalock,项目名称:dig,代码行数:10,代码来源:tree.cpp

示例11: ans

    //@{
    double                binomialDist::aic     (const ArrayXd& y, const ArrayXd& n, const ArrayXd& mu,
						 const ArrayXd& wt, double dev) const {
	ArrayXd    m((n > 1).any() ? n : wt);
	ArrayXd   yy((m * y).unaryExpr(Round<double>()));
	m = m.unaryExpr(Round<double>());
	double ans(0.);
	for (int i=0; i < mu.size(); ++i)
	    ans += (m[i] <= 0. ? 0. : wt[i]/m[i]) * ::Rf_dbinom(yy[i], m[i], mu[i], true);
	return (-2. * ans);
    }
开发者ID:L4R,项目名称:lme4,代码行数:11,代码来源:glmFamily.cpp

示例12: for

ArrayXd GoSUM::CModelVariables::expandNTuple(const ArrayXd &X) const
{
    if ( X.size()!=mvs.size() )  throw "GoSUM::CModelVariables::expand error: wrong X size";
    int i,j,k,N=int(mvs.size()),eN=expandedSize(),exsize;
    ArrayXd eX=ArrayXd::Zero(eN);
    for ( i=j=0; i<N; i++,j+=exsize )
    {   exsize=mvs[i].expandedSize();
        if ( exsize==1 )  {  eX(j)=X(i);  }
        else              {  for ( k=0; k<exsize; k++ )  if (k==X(i)) { eX(j+k) = 1.; break; } } }
    return eX;
}
开发者ID:davor-,项目名称:GoSum,代码行数:11,代码来源:Model.cpp

示例13: 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();
    }
开发者ID:SvenDowideit,项目名称:clearlinux,代码行数:40,代码来源:predModule.cpp

示例14: 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;
    }
开发者ID:L4R,项目名称:lme4,代码行数:13,代码来源:glmFamily.cpp

示例15: 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;
    }
开发者ID:Estoque86,项目名称:ndnSIM_MicTort,代码行数:14,代码来源:fastLm.cpp


注:本文中的ArrayXd::size方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。