WSL/SLF GitLab Repository

Commit 1a0302e9 authored by Adrien Michel's avatar Adrien Michel
Browse files

Code cleaning

parent 2e55df38
......@@ -54,17 +54,13 @@ Rcpp::List snowDaysComparisonCpp(const NumericMatrix data_1,
bool interrupt = false;
// Convert R object to proper c++ object since R objects are not thread safe
std::clock_t start;
start = std::clock();
const size_t num_pixels=data_1.nrow();
const size_t num_years=indices.size();
std::vector< std::vector<size_t> > indices_cpp(num_years);
for(size_t i=0; i< num_years; ++i)
{
indices_cpp[i]=Rcpp::as< std::vector<size_t> >(indices[i]);
}
const std::vector<double> data_1_cpp = Rcpp::as< std::vector<double> >((data_1));
const std::vector<double> data_2_cpp = Rcpp::as< std::vector<double> >((data_2));
......@@ -72,10 +68,6 @@ Rcpp::List snowDaysComparisonCpp(const NumericMatrix data_1,
for(size_t i=0; i< num_pixels; ++i){
out_cpp[i] = std::vector< size_t >(num_years*4);
}
std::cout << "copy " << ( std::clock() - start ) / (double) CLOCKS_PER_SEC << std::endl;
start = std::clock();
std::vector<size_t> snow_days_1(indices_cpp[0].size());
std::vector<size_t> snow_days_2(indices_cpp[0].size());
......@@ -117,8 +109,6 @@ Rcpp::List snowDaysComparisonCpp(const NumericMatrix data_1,
if (interrupt) {
throw interrupt_exception("[I] The computation was interrupted by user");
}
std::cout << "algo " << ( std::clock() - start ) / (double) CLOCKS_PER_SEC << std::endl;
start = std::clock();
Rcpp::List out(num_pixels);
Rcpp::NumericMatrix content(4,num_years);
......@@ -127,8 +117,5 @@ Rcpp::List snowDaysComparisonCpp(const NumericMatrix data_1,
out(i) = Rcpp::NumericMatrix(4 , num_years , out_cpp[i].begin() );
colnames(out(i)) = out_names;
}
std::cout << "out " << ( std::clock() - start ) / (double) CLOCKS_PER_SEC << std::endl;
return(out);
}
......@@ -98,8 +98,6 @@ Rcpp::NumericMatrix snowSeasonLengthCpp(const NumericMatrix data,
bool interrupt = false;
// Convert R object to proper c++ object since R objects are not thread safe
std::clock_t start;
start = std::clock();
const size_t num_pixels=data.nrow();
const size_t num_years=indices.size();
......@@ -113,9 +111,6 @@ Rcpp::NumericMatrix snowSeasonLengthCpp(const NumericMatrix data,
std::vector< size_t > out_cpp(num_pixels*num_years);
std::cout << "copy " << ( std::clock() - start ) / (double) CLOCKS_PER_SEC << std::endl;
start = std::clock();
std::vector<double> snow_height(366);
#if defined(_OPENMP)
......@@ -154,15 +149,11 @@ Rcpp::NumericMatrix snowSeasonLengthCpp(const NumericMatrix data,
if (interrupt) {
throw interrupt_exception("[I] The computation was interrupted by user");
}
std::cout << "algo " << ( std::clock() - start ) / (double) CLOCKS_PER_SEC << std::endl;
start = std::clock();
Rcpp::NumericMatrix out(num_pixels,num_years,out_cpp.begin());
Rcpp::CharacterVector out_names = Rcpp::as<CharacterVector>(indices.names());
colnames(out) = out_names;
std::cout << "out " << ( std::clock() - start ) / (double) CLOCKS_PER_SEC << std::endl;
return(out);
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment