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


C++ mat::end方法代码示例

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


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

示例1: whichNA

//[[Rcpp::export]]
IntegerVector whichNA(arma::mat X) {
  NumericVector x(X.begin(), X.end());
  int n = x.size();
  IntegerVector y = seq_len(n);//(x.begin(), x.end());
  IntegerVector z = y[is_na(x)];
  if(z.size()==0)
    std::cout << "\nNenhum valor faltante.\n";
  return z;
}
开发者ID:rbarcellos,项目名称:MScPack,代码行数:10,代码来源:mat2vec.cpp

示例2: changeNA

//[[Rcpp::export]]
Rcpp::List changeNA(arma::mat X) {
  NumericVector x(X.begin(), X.end());
  int n = x.size();
  IntegerVector y = seq_len(n)-1;//(x.begin(), x.end());
  IntegerVector z = y[is_na(x)];
  if(z.size()==0){
    std::cout << "Nenhum valor faltante.\n";
    SEXP xNULL = R_NilValue;
    return Rcpp::List::create(xNULL);  
  } else{
    arma::uvec Xna = as<arma::uvec>(z);
    NumericVector bx(Xna.n_rows, 100.0);
    arma::vec b = as<arma::vec>(bx);
    X.elem(Xna) = b;
    return Rcpp::List::create(X);
  }  
}
开发者ID:rbarcellos,项目名称:MScPack,代码行数:18,代码来源:mat2vec.cpp

示例3: calcPotts_cpp

////> Main function ////
// [[Rcpp::export]]
List calcPotts_cpp (const S4& W_SR, const S4& W_LR, arma::mat sample, NumericVector rho, const arma::mat& coords, 
                    const IntegerVector& site_order, int iter_max, double cv_criterion, 
                    bool test_regional, NumericVector distance_ref, double threshold, double neutre, int nbGroup_min, bool multiV, bool last_vs_others, 
                    bool prior, bool type_reg, int verbose){
  
  //// preparation
  int p = sample.n_cols;
  int n = sample.n_rows;
  
  IntegerVector W_SRi = W_SR.slot("i");
  IntegerVector W_SRp = W_SR.slot("p");
  NumericVector W_SRx = W_SR.slot("x");
  
  arma::mat Wpred(n, p);
   
  vector < vector < double > > pred_global(p);
  for(int iter_p = 0 ; iter_p < p ; iter_p ++){
    pred_global[iter_p].resize(n);
    for(int iter_px = 0 ; iter_px < n ; iter_px++){
      pred_global[iter_p][iter_px] = sample(iter_px, iter_p);
    }
  }
  vector < vector < double > > pred_global_hist = pred_global;
    
  if(prior == false){
    std::fill(sample.begin(), sample.end(), 1);
  }
  
  arma::mat V(n, p);
   
  IntegerVector rang;
  bool no_site_order = (site_order[0] < 0);
  if(no_site_order == false){
    rang = site_order;
  }
  
  int index_px;
  double norm;
  double val_criterion = cv_criterion + 1;
  double diff_criterion = 0, diff; 
  double cv_criterion2 = n * cv_criterion ; 
  int iter_updateV = 0 ;
  
  vector < double > res_multipotentiel(n) ;
  int iter = 0 ;
  
  //// estimation
  
  while(iter < iter_max && ( (val_criterion > cv_criterion) || (test_regional == true && iter_updateV != iter) ) ){

    iter++;
    pred_global_hist = pred_global; 
    
    if(no_site_order){
      rang = rank_hpp(runif(n)) - 1; // tirer aleatoirement l ordre des sites
    }
   
    //// regional potential
    if(test_regional == true){
      if(iter == 1 || val_criterion <= cv_criterion || diff_criterion > cv_criterion2){ 
      iter_updateV = iter ;
      
      for(int iter_p = (p - 1) ; iter_p>= 0 ; iter_p --){

        if(last_vs_others == false || iter_p == (p - 1)){
        
        res_multipotentiel =  calcMultiPotential_hpp(W_SR, W_LR, pred_global[iter_p], 
                                                     threshold, coords, Rcpp::as < std::vector < double > >(distance_ref), 
                                                     nbGroup_min, multiV, 
                                                     neutre)[0]; 
            
          for(int iter_px = 0 ; iter_px < n ; iter_px++){
           
            V(iter_px, iter_p) = res_multipotentiel[iter_px];
            
            if(type_reg){
              V(iter_px, iter_p) = V(iter_px, iter_p)  * (V(iter_px, iter_p) - pred_global[iter_p][iter_px]);
            }
          }
        
        }else{
          V.col(iter_p) = 1 - V.col(p - 1);
        }
      }
      
      }else{
        cv_criterion2 /= 1.1;
      } 
    }

    //// update site probabilities
    val_criterion = 0;
    diff_criterion = 0;
    
    for(int iter_px = 0 ; iter_px < n ; iter_px++){ // pour chaque pixel
      
      norm = 0.0;
      index_px = rang(iter_px);
//.........这里部分代码省略.........
开发者ID:bozenne,项目名称:MRIaggr,代码行数:101,代码来源:Functions_Potts.cpp


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