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


C++ arma::colvec类代码示例

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


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

示例1: update

void Force_iid_model::update(arma::colvec& Y,const arma::colvec3& force, const arma::colvec3& torque) {

    features(contact) = gaussian_step_function_positive(arma::norm(force),0.9,1,beta);

    features(up)      = gaussian_step_function_positive(force(0),limits[contact].lower,limits[contact].upper,var[contact]);   //+

    features(down)    = gaussian_step_function_negative(force(0),limits[down].lower,limits[down].upper,var[down]);       //-
    features(left)    = gaussian_step_function_negative(force(1),limits[left].lower,limits[left].upper,var[left]);       // -

    features(right)   = gaussian_step_function_positive(force(1),limits[right].lower,limits[right].upper,var[right]);    // +

    features(push)    = gaussian_step_function_negative(force(2),limits[push].lower,limits[push].upper,var[push]);       //-

    //contact,up,down,left,right,push

    features_simple(0) = features(contact);
    features_simple(1) = arma::max(features(arma::span(1,4)));


    if(type == FULL) {
        Y.resize(6);
        Y(contact)  = features(contact);
        Y(up)       = features(up);
        Y(down)     = features(down);
        Y(left)     = features(left);
        Y(right)    = features(right);
        Y(push)     = features(push);
    } else {
        Y.resize(2);
        Y(0)        = features_simple(0);
        Y(1)        = features_simple(1);
    }
}
开发者ID:gpldecha,项目名称:peg_sensor,代码行数:33,代码来源:force_iid_model.cpp

示例2: ksFastTestStatistic

// [[Rcpp::export]]
double ksFastTestStatistic(arma::colvec y, arma::colvec z){
	uvec trt = find( z == 1 );
	uvec ctrl = find( z == 0 );
	vec yT = y.elem(trt);
	vec	yC = y.elem(ctrl);
	// assuming no missing vals	yT = yT[!is.na(yT)];
	double nX = yT.n_rows; //length(yT);
	double nY = yC.n_rows;
	double n = nX * nY/(nX + nY);
	colvec w = join_cols(yT, yC); // c(yT,yC)
	uvec orderedw = sort_index(w); //order(w)
	int totalN = nX + nY;
	colvec d(totalN);
	d.fill(1/nX);
	d.elem( find( orderedw > nX ) ).fill(-1/nY);
	// d = cumsum(Rcpp::ifelse(orderedw <= nX, 1/nX, -1/nY));
	colvec F = cumsum(d);
	// check for ties
	vec uniqF = unique(w);
	vec out = F;
	if ( uniqF.n_elem < totalN ){
		//uvec nonzerodiffs = find( diff(sort(F)) != 0 );
		vec Fnonzerodiffs = F.elem( find( diff(sort(F)) != 0 ) );
		vec out = Fnonzerodiffs; // I dont know why I cant use join_cols (Fnonzerodiffs,F(totalN-1))
		out.insert_rows(1,F(totalN-1)); // z <- z[c(which(diff(sort(w)) != 0), n.x + n.y)]
		}
	// return(max(abs(out)));
	return(max(abs(out)));
}
开发者ID:jwbowers,项目名称:TestStatRIInterference,代码行数:30,代码来源:fastTestStatistics.cpp

示例3: get_xi_sqr

double get_xi_sqr(arma::colvec &x, arma::mat &post_sigma, arma::colvec &post_mu){
  arma::mat v = x.t()*post_sigma*x;
  arma::mat xmu = x.t()*post_mu;
  std::cout << "x.t()*post_sigma*x = " << std::endl;
  v.print();
  std::cout << "x.t()*post_mu = " << std::endl;
  xmu.print();
  return as_scalar(v) + as_scalar(xmu)*as_scalar(xmu);
}
开发者ID:abhimanu,项目名称:CVPETpgm,代码行数:9,代码来源:variational.cpp

示例4: norm

bool CamAruco2DObservationModel::hasClearLineOfSight(const ompl::base::State *state, const arma::colvec& landmark )
{

    using namespace arma;

    colvec xVec = state->as<SE2BeliefSpace::StateType>()->getArmaData();

    colvec robot_to_landmark_ray =  landmark.subvec(1,2) - xVec.subvec(0,1);

    double distance = norm(robot_to_landmark_ray,2);

    int steps = std::floor(distance/ompl::magic::ONE_STEP_DISTANCE_FOR_VISIBILITY);

    ompl::base::State *tempState = this->si_->allocState();

    for(int i=1 ; i < steps; i++)
    {
        double newX = xVec(0) + i*robot_to_landmark_ray(0)/steps;

        double newY = xVec(1) + i*robot_to_landmark_ray(1)/steps;

        tempState->as<SE2BeliefSpace::StateType>()->setXYYaw(newX, newY,0);

        if(!this->si_->isValid(tempState))
        {
            return false;
        }

    }

    si_->freeState(tempState);

    return true;
}
开发者ID:sauravag,项目名称:edpl-ompl,代码行数:34,代码来源:CamAruco2DObservationModel.cpp

示例5: mllog

// //' 	Self-concordant Taylor approximation logstar function
// //'
// //' 	Minus log and its first \code{der} derivatives, on \code{eps < x < M}, with
// //' 	fourth order Taylor series approximation to the left of \code{eps} and to the right of \code{M}
// //'
// //' 	@param x column vector of observations
// //' 	@param eps lower tolerance
// //' 	@param M maximum value
// //' 	@param der derivative, either 0, 1 or 2.
// //'
// //' 	@return a matrix with \eqn{der+1} columns containing values
arma::mat mllog(arma::colvec x, double eps, double M, int der=0){
  if(!(der==0 || der==1 || der==2)){
    Rcpp::stop("Only first two derivatives and log functions implemented");
  }
  if(eps > M){
    Rcpp::stop("Thresholds out of order");
  }
  //Coefficients for 4th order Taylor approx below eps
  arma::vec coefs(5);
  arma::vec Coefs(5);
  coefs(0) = -log(eps);
  Coefs(0) = -log(M);
  for(int i=1; i<5; i++){
    coefs(i) = R_pow(-eps,-i)/(double)i;
    Coefs(i) = R_pow(-M,-i)/(double)i;
  }

  arma::uvec lo = find(x < eps);
  arma::uvec hi = find(x > M);

  //Function value
  arma::vec f(x.size());
  f = -log(x);
  f(lo) = h(x(lo)-eps, coefs);
  f(hi) = h(x(hi)-M,   Coefs);

  if(der < 1){
    return f;
  }
  //First derivative

  arma::vec fp(x.size());
  fp = -1.0/x;
  fp(lo) = hp(x(lo)-eps, eps);
  fp(hi) = hp(x(hi)-M,   M);

  if(der < 2){
    return join_rows(f, fp);
  }
  //Second derivative
  arma::vec fpp(x.size());
  fpp = pow(x,-2);
  fpp(lo) = hpp(x(lo)-eps, eps);
  fpp(hi) = hpp(x(hi)-M,   M);

  return join_rows(join_rows(f,fp),fpp);
}
开发者ID:lbelzile,项目名称:mev,代码行数:58,代码来源:emplik.cpp

示例6: computeBetaJ_cpp

arma::colvec computeBetaJ_cpp(arma::colvec y, arma::mat X, int j, int m, int adjFinSample) {
  int bigT = X.n_rows;
  int numThrow = ceil((double)m / 2);
  if (adjFinSample == 0) numThrow = m ;
  mat XSparse; colvec ySparse;
  XSparse.zeros(bigT - numThrow, X.n_cols); ySparse.zeros(bigT - numThrow);
  if (j < 2) {
    XSparse.rows(0, bigT - numThrow - 1) = X.rows(numThrow, bigT - 1);
    ySparse.rows(0, bigT - numThrow - 1) = y.rows(numThrow, bigT - 1);
  } else {
    XSparse.rows(0, j - 2) = X.rows(0, j - 2); ySparse.rows(0, j - 2) = y.rows(0, j - 2);
    XSparse.rows(j - 1, bigT - numThrow - 1) = X.rows(j + numThrow - 1, bigT - 1);
    ySparse.rows(j - 1, bigT - numThrow - 1) = y.rows(j + numThrow - 1, bigT - 1);
  }
  colvec beta = runOLSFast_cpp(ySparse, XSparse);
  return(beta);
}
开发者ID:irinapim,项目名称:DFMToolkit,代码行数:17,代码来源:runAndrews.cpp

示例7: expection

void GMM::expection(arma::colvec& x) const{
    x.zeros();
    for(std::size_t k = 0; k < K;k++){
        x += Means[k] * pi(k);
    }


}
开发者ID:gpldecha,项目名称:statistics_ml,代码行数:8,代码来源:gmm.cpp

示例8: CheckActivationCorrect

void CheckActivationCorrect(const arma::colvec input, const arma::colvec target)
{
  // Test the activation function using a single value as input.
  for (size_t i = 0; i < target.n_elem; i++)
  {
    BOOST_REQUIRE_CLOSE(ActivationFunction::fn(input.at(i)),
        target.at(i), 1e-3);
  }

  // Test the activation function using the entire vector as input.
  arma::colvec activations;
  ActivationFunction::fn(input, activations);
  for (size_t i = 0; i < activations.n_elem; i++)
  {
    BOOST_REQUIRE_CLOSE(activations.at(i), target.at(i), 1e-3);
  }
}
开发者ID:PhenixI,项目名称:mlpack,代码行数:17,代码来源:activation_functions_test.cpp

示例9: CheckDerivativeCorrect

void CheckDerivativeCorrect(const arma::colvec input, const arma::colvec target)
{
  // Test the calculation of the derivatives using a single value as input.
  for (size_t i = 0; i < target.n_elem; i++)
  {
    BOOST_REQUIRE_CLOSE(ActivationFunction::deriv(input.at(i)),
        target.at(i), 1e-3);
  }

  // Test the calculation of the derivatives using the entire vector as input.
  arma::colvec derivatives;
  ActivationFunction::deriv(input, derivatives);
  for (size_t i = 0; i < derivatives.n_elem; i++)
  {
    BOOST_REQUIRE_CLOSE(derivatives.at(i), target.at(i), 1e-3);
  }
}
开发者ID:PhenixI,项目名称:mlpack,代码行数:17,代码来源:activation_functions_test.cpp

示例10: computeSStat_cpp

//[[Rcpp::export]]
double computeSStat_cpp(arma::colvec beta, arma::mat invS, arma::colvec y, arma::mat X,
                        int j, int m) {
  mat newX = X.rows(j - 1, j + m - 2); colvec newY = y.rows(j - 1, j + m - 2);
  mat A = trans(newX) * invS * (newY - newX * beta);
  mat V =  trans(newX) * invS * newX;
  mat S = trans(A) * inv(V) * A;
  double s = S(0, 0);
  return(s);
}
开发者ID:irinapim,项目名称:DFMToolkit,代码行数:10,代码来源:runAndrews.cpp

示例11: nLL2

double nLL2(arma::colvec par, arma::colvec Data, int Nf)  {		
double failcomp=0.0,suscomp=0.0;		
arma::colvec F=Data.rows(0,Nf-1);		
for(int i=0; i<Nf; i++)  {		
failcomp=failcomp+R::dlnorm(F(i),par(0),par(1),1);		
}		
failcomp=-failcomp;		
int Nd=Data.n_rows;		
arma::colvec S;		
if(Nd>Nf)  {		
	 S=Data.rows(Nf,Nd-1);	
	for(int i=0; i<(Nd-Nf); i++)  {	
	suscomp=suscomp+R::plnorm(S(i),par(0),par(1),0,1);	
	}	
}		
double negLL=failcomp-suscomp;		
return negLL;		
}		
开发者ID:CarlesCG,项目名称:Install_abrem_shiny,代码行数:18,代码来源:MLEln2p.cpp

示例12: Krigidx

//--------------------------------------------------------------------------------------------------
double Krigidx( const arma::colvec& KF,
                 const arma::colvec& comb,
                 const arma::mat& X,
                 const arma::cube& Gamma ) {
  int k;
  int n = X.n_rows;
  int c = comb.size();
  double S;
  
  arma::mat W = arma::ones( n, n );
    
  for ( k = 0; k < c; k++ ) {
    W = W % Gamma.slice( comb( k ) - 1 );
  }
  S = as_scalar( KF.t() * W * KF );

  return S;
}
开发者ID:ajucode,项目名称:RKHSENS,代码行数:19,代码来源:krig_sensitivity.cpp

示例13: classify

int classify(double xi, arma::mat &sigma, arma::mat &sigma_inv, arma::colvec &x, arma::colvec &mu){
  arma::mat sigma_t_inv = get_post_sigma_inv(xi, x, sigma_inv);
  arma::mat sigma_t = sigma_t_inv.i();
  arma::colvec mu_t; 

  int s = 0;
  mu_t = get_post_mu(x, sigma_inv, sigma_t, mu, s);
  
  double log_0 = log(sigmoid(xi)) - xi/2 - lambda(xi)*xi*xi - 0.5*as_scalar(mu.t()*sigma_inv*mu) + 0.5*as_scalar(mu_t.t()*sigma_t.t()*mu_t) + 0.5*log(det(sigma_t)/det(sigma));

  s = 1;
  mu_t = get_post_mu(x, sigma_inv, sigma_t, mu, s);
  
  double log_1 = log(sigmoid(xi)) - xi/2 - lambda(xi)*xi*xi - 0.5*as_scalar(mu.t()*sigma_inv*mu) + 0.5*as_scalar(mu_t.t()*sigma_t.t()*mu_t) + 0.5*log(det(sigma_t)/det(sigma));

  if(log_1 > log_0) return 1;
  else return 0;

}
开发者ID:abhimanu,项目名称:CVPETpgm,代码行数:19,代码来源:variational.cpp

示例14: CheckInverseCorrect

void CheckInverseCorrect(const arma::colvec input)
{
    // Test the calculation of the inverse using a single value as input.
  for (size_t i = 0; i < input.n_elem; i++)
  {
    BOOST_REQUIRE_CLOSE(ActivationFunction::inv(ActivationFunction::fn(
        input.at(i))), input.at(i), 1e-3);
  }

  // Test the calculation of the inverse using the entire vector as input.
  arma::colvec activations;
  ActivationFunction::fn(input, activations);
  ActivationFunction::inv(activations, activations);

  for (size_t i = 0; i < input.n_elem; i++)
  {
    BOOST_REQUIRE_CLOSE(activations.at(i), input.at(i), 1e-3);
  }
}
开发者ID:PhenixI,项目名称:mlpack,代码行数:19,代码来源:activation_functions_test.cpp

示例15: computeCovMatForAndrews_cpp

arma::mat computeCovMatForAndrews_cpp(arma::colvec u, int breakDate) {
 int bigT = u.n_rows;
 int m = bigT - breakDate;
 mat totSum =zeros(m, m);
 for (int j = 0; j < (breakDate + 1); j++) {
   colvec uUsed = u.rows(j, j + m - 1);
   totSum = totSum + uUsed * trans(uUsed);
 }
 mat Sigma = totSum / (breakDate + 1);
 return(Sigma);
}
开发者ID:irinapim,项目名称:DFMToolkit,代码行数:11,代码来源:runAndrews.cpp


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