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


C++ ArrayXd类代码示例

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


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

示例1: compute_grad

Vector4d compute_grad(Vector4d beta, VectorXd x, VectorXd y){
  Vector4d grad;
  ArrayXd tmp;
  ArrayXd pred = model_fun(beta, x);

  assert(x.size()==y.size());

  // beta(0)
  tmp = 1 / (1 + exp(-(x.array()-beta(2))/abs(beta(3))));
  tmp *= pred - y.array();
  grad(0) = tmp.sum() / x.size();

  // beta(1)
  tmp = 1 / (1 + exp(-(x.array()-beta(2))/abs(beta(3))));
  tmp = 1 - tmp;
  tmp *= pred - y.array();
  grad(1) = tmp.sum() / x.size();

  // beta(2)
  tmp = -(beta(0)- beta(1)) * (exp((beta(2)-x.array())/abs(beta(3)))/abs(beta(3))) \
        / (1+exp((beta(2)-x.array())/abs(beta(3)))).pow(2);
  tmp *= pred - y.array();
  grad(2) = tmp.sum() / x.size();

  // beta(3)
  tmp = (beta(0) - beta(1)) * (beta(2)-x.array()).pow(2) * sgn(beta(3)) \
        / (abs(beta(3))*pow(beta(3), 2)*(1+exp((beta(2)-x.array())/abs(beta(3)))).pow(2));
  tmp *= pred - y.array();
  grad(3) = tmp.sum() / x.size();

  return grad;
}
开发者ID:caomw,项目名称:CPBD-sharpness,代码行数:32,代码来源:nlinfit.cpp

示例2: di

    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

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

示例4: 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

示例5: logsumexp

VectorXd probutils::logsumexp (const MatrixXd& X)
{
  const VectorXd mx = X.rowwise().maxCoeff(); // Get max of each row

  // Perform the sum(exp(x - mx)) part
  ArrayXd se = ((X.colwise() - mx).array().exp()).rowwise().sum();

  // return total log(sum(exp(x))) - hoping for return value optimisation
  return (se.log()).matrix() + mx;
}
开发者ID:pkmital,项目名称:pkmDPGMM,代码行数:10,代码来源:probutils.cpp

示例6: 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

示例7: modeProfileSinc

void Functions::modeProfileSinc(RefArrayXd predictions, const RefArrayXd covariates, 
                               const double centroid, const double height, const double resolution)
{
    ArrayXd sincFunctionArgument = Functions::PI*(covariates - centroid)/resolution;
    ArrayXd sincFunction = sincFunctionArgument.sin() / sincFunctionArgument;


    // Multiply the profile by the height in the PSD

    predictions = height*sincFunction.square();
}
开发者ID:JorisDeRidder,项目名称:DIAMONDS,代码行数:11,代码来源:Functions.cpp

示例8: 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

示例9: SteadyState

AFI::AFI(const bool prompt) : SteadyState() {
	if (prompt) cout << "Enter flip-angle (degrees): " << flush;
	double inFlip;
	QI::Read(cin, inFlip);
	m_flip = ArrayXd::Ones(1) * inFlip * M_PI / 180.;
	if (prompt) cout << "Enter TR1 & TR2 (seconds): " << flush;
	ArrayXd temp;
	QI::ReadArray(cin, temp);
	if (temp.rows() != 2)
        QI_EXCEPTION("Must enter 2 TR values.");
	m_TR1 = temp[0]; m_TR2 = temp[1];
}
开发者ID:jamespooley,项目名称:QUIT,代码行数:12,代码来源:Sequence.cpp

示例10: 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";
}
开发者ID:davor-,项目名称:GoSum,代码行数:13,代码来源:MatlabLibrary.cpp

示例11: 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

示例12: 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

示例13:

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

示例14: lgamma

    //@{
    double        negativeBinomialDist::aic     (const ArrayXd& y, const ArrayXd& n, const ArrayXd& mu,
						 const ArrayXd& wt, double dev) const {
	return 2. * (wt * (y + d_theta) * (mu + d_theta).log() -
		     y * mu.log() + (y + 1).unaryExpr(Lgamma<double>()) -
		     d_theta * std::log(d_theta) + lgamma(d_theta) -
		     (d_theta + y).unaryExpr(Lgamma<double>())).sum();
    }
开发者ID:L4R,项目名称:lme4,代码行数:8,代码来源:glmFamily.cpp

示例15: 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


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