Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/miaaft_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ double xi_coefficient(arma::vec x, arma::vec y);
// so that the inverse FFT results in a real-valued time series.
vec generate_shared_random_phases(int n) {
vec phases(n, fill::zeros);
GetRNGstate(); // Pull RNG state from R

// Generate random phases for positive frequencies
for(int i = 1; i <= (n - 1) / 2; i++) {
Expand All @@ -28,7 +27,6 @@ vec generate_shared_random_phases(int n) {
phases(n / 2) = 0;
}

PutRNGstate(); // Return RNG state to R
return phases;
}

Expand Down
4 changes: 0 additions & 4 deletions src/xi_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@ using namespace arma;
// Shuffles indices using R's random number generator to ensure
// exact reproducibility with set.seed() from the R environment.
void shuffle_indices_with_r_seed(uvec& idx) {
GetRNGstate(); // Pull RNG state from R
int n = idx.n_elem;
for (int i = n - 1; i > 0; i--) {
int j = floor(R::runif(0, 1) * (i + 1));
uword tmp = idx[i];
idx[i] = idx[j];
idx[j] = tmp;
}
PutRNGstate(); // Return RNG state to R
}

// ============================================================
Expand Down Expand Up @@ -99,7 +97,6 @@ arma::mat generate_iaaft_surrogates(arma::vec x, int n_surr, int max_iter = 100)
vec amplitudes = abs(X_fft);

vec x_sorted = sort(x);
GetRNGstate();

for(int s = 0; s < n_surr; s++) {
vec surr = shuffle(x);
Expand All @@ -125,7 +122,6 @@ arma::mat generate_iaaft_surrogates(arma::vec x, int n_surr, int max_iter = 100)
surrogates.col(s) = surr;
}

PutRNGstate();
return surrogates;
}

Expand Down
Loading