From 30689252e566debdd5335f5f4bf76c3fe0c25c18 Mon Sep 17 00:00:00 2001 From: Lukas Schneiderbauer Date: Fri, 14 Jun 2024 20:36:19 +0200 Subject: [PATCH] set default threads to 2, rename argument to n_threads, and fix fcwt_batch() not passing the argument to fcwt() --- R/fcwt.R | 9 +++++---- R/fcwt_batch.R | 5 +++-- man/fcwt.Rd | 5 +++-- man/fcwt_batch.Rd | 5 +++-- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/R/fcwt.R b/R/fcwt.R index 6ee08e0..214ba7c 100644 --- a/R/fcwt.R +++ b/R/fcwt.R @@ -53,8 +53,9 @@ #' is less then \eqn{4 \Sigma_t}. Values that fall into that range are removed #' if `remove_coi = TRUE`. #' -#' @param nthreads +#' @param n_threads #' Number of threads used by the computation, if supported by your platform. +#' Defaults to 2 threads (to accomodate CRAN requirements). #' #' @return #' The spectogram, a numeric real-valued matrix with dimensions @@ -81,20 +82,20 @@ fcwt <- function(signal, sigma = 1, # abs = FALSE, remove_coi = TRUE, - nthreads = 8L) { + n_threads = 2L) { stopifnot(is.numeric(signal)) stopifnot(is.numeric(sample_freq), sample_freq > 0) stopifnot(is.numeric(freq_begin), freq_begin > 0) stopifnot(is.numeric(freq_end), freq_end > freq_begin) stopifnot(is.numeric(n_freqs), n_freqs > 0) stopifnot(is.numeric(sigma), sigma > 0) - stopifnot(is.numeric(nthreads)) + stopifnot(is.numeric(n_threads)) # stopifnot(is.logical(abs)) output <- fcwt_raw( as.numeric(signal), as.integer(sample_freq), freq_begin, freq_end, - as.integer(n_freqs), sigma, as.integer(nthreads), FALSE, + as.integer(n_freqs), sigma, as.integer(n_threads), FALSE, abs = TRUE ) diff --git a/R/fcwt_batch.R b/R/fcwt_batch.R index 41a2cef..b2e7efa 100644 --- a/R/fcwt_batch.R +++ b/R/fcwt_batch.R @@ -73,7 +73,7 @@ fcwt_batch <- function(signal, freq_end = sample_freq / 2, sigma = 1, max_batch_size = ceiling(4 * 10^9 / (n_freqs * 4)), - nthreads = 8L, + n_threads = 2L, progress_bar = FALSE) { # From FFTW documentation: # FTW is best at handling sizes of the form 2^a 3^b 5^c 7^d 11^e 13^f, @@ -113,7 +113,8 @@ fcwt_batch <- function(signal, freq_end = freq_end, n_freqs = n_freqs, sigma = sigma, - remove_coi = TRUE + remove_coi = TRUE, + n_threads = n_threads ) |> agg(n = reduced_n) diff --git a/man/fcwt.Rd b/man/fcwt.Rd index 451e368..5d5eda9 100644 --- a/man/fcwt.Rd +++ b/man/fcwt.Rd @@ -12,7 +12,7 @@ fcwt( freq_end = sample_freq/2, sigma = 1, remove_coi = TRUE, - nthreads = 8L + n_threads = 2L ) } \arguments{ @@ -47,7 +47,8 @@ the boundary if the distance of the center of the wavelet to the boundary is less then \eqn{4 \Sigma_t}. Values that fall into that range are removed if \code{remove_coi = TRUE}.} -\item{nthreads}{Number of threads used by the computation, if supported by your platform.} +\item{n_threads}{Number of threads used by the computation, if supported by your platform. +Defaults to 2 threads (to accomodate CRAN requirements).} } \value{ The spectogram, a numeric real-valued matrix with dimensions diff --git a/man/fcwt_batch.Rd b/man/fcwt_batch.Rd index 3343e56..4ec7841 100644 --- a/man/fcwt_batch.Rd +++ b/man/fcwt_batch.Rd @@ -13,7 +13,7 @@ fcwt_batch( freq_end = sample_freq/2, sigma = 1, max_batch_size = ceiling(4 * 10^9/(n_freqs * 4)), - nthreads = 8L, + n_threads = 2L, progress_bar = FALSE ) } @@ -48,7 +48,8 @@ resolution and a worse (better) time resolution.} This limits the maximal memory that is used. Defaults to roughly 4GB. The actual batch size is optimized for use with FFTW.} -\item{nthreads}{Number of threads used by the computation, if supported by your platform.} +\item{n_threads}{Number of threads used by the computation, if supported by your platform. +Defaults to 2 threads (to accomodate CRAN requirements).} \item{progress_bar}{Monitoring progress can sometimes be useful when performing time consuming operations. Setting \code{progress_bar = TRUE} enables printing a progress