Skip to content

Commit

Permalink
Update C++ code to resolve issues 20, 35, and 36
Browse files Browse the repository at this point in the history
  • Loading branch information
bhelsel committed May 19, 2024
1 parent 903a689 commit 34cb723
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
^codecov\.yml$
^README\.Rmd$
^tests/testthat/test_gcalibrateC\.R$
^man/figures
^man/figures
.vscode/
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
.RData
.Ruserdata
.DS_Store
.vscode/
11 changes: 8 additions & 3 deletions src/gcalibrate.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// [[Rcpp::plugins(cpp11)]]
#include <RcppArmadillo.h>
#include <iostream>
#include <vector>
Expand Down Expand Up @@ -91,7 +92,7 @@ Rcpp::List gcalibrateC(Rcpp::Nullable<Rcpp::String> pathname = R_NilValue, Rcpp:
}

Rcpp::NumericVector ws {5, 900, 3600};
int startpage, endpage, blocksize = 12 * ws(2), minloadcrit = 72;
int startpage, endpage, blocksize = 12 * ws(2), minloadcrit = 168;
double NR = ceil((90*pow(10, 6)) / (sf*10)) + 1000; // NR = number of '10' second rows (this is for 10 days at 80 Hz)
int count = 0; // counter to keep track of the number of seconds that have been read
double spherecrit = 0.3, sdcriter = 0.013;
Expand Down Expand Up @@ -162,7 +163,8 @@ Rcpp::List gcalibrateC(Rcpp::Nullable<Rcpp::String> pathname = R_NilValue, Rcpp:
if((use > 0) && (use != LD)){
S = data(Rcpp::Range(use, LD-1), Rcpp::_);
}
data = data(Rcpp::Range(0, use-1), Rcpp::_);

if(use != 0) data = data(Rcpp::Range(0, use-1), Rcpp::_);

if(data.nrow() < blocksize * 30){
LD = 0;
Expand Down Expand Up @@ -274,7 +276,9 @@ Rcpp::List gcalibrateC(Rcpp::Nullable<Rcpp::String> pathname = R_NilValue, Rcpp:

for(int i = 0; i < input.nrow(); i++){
for(int j = 0; j < input.ncol(); j++){
closestpoint(i, j) = curr(i, j) / sqrt(rsum[i]);
if(curr(i, j) != 0){
closestpoint(i, j) = curr(i, j) / sqrt(rsum[i]);
}
}
}

Expand Down Expand Up @@ -311,6 +315,7 @@ Rcpp::List gcalibrateC(Rcpp::Nullable<Rcpp::String> pathname = R_NilValue, Rcpp:

if((calErrorEnd < calErrorStart) && (calErrorEnd < 0.01) && (nhoursused > minloadcrit)){
LD = 0;
Rcpp::Rcout << "Recalibration done, no problems detected";
}
}
i += 1;
Expand Down
1 change: 1 addition & 0 deletions src/resample_helpers.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// [[Rcpp::plugins(cpp11)]]
#include <Rcpp.h>
using namespace Rcpp;

Expand Down

0 comments on commit 34cb723

Please sign in to comment.