本文整理汇总了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;
}
示例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);
}
}
示例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);
//.........这里部分代码省略.........