Skip to content

Commit

Permalink
set default threads to 2, rename argument to n_threads, and fix fcwt_…
Browse files Browse the repository at this point in the history
…batch() not passing the argument to fcwt()
  • Loading branch information
lschneiderbauer committed Jun 14, 2024
1 parent a63295e commit 3068925
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
9 changes: 5 additions & 4 deletions R/fcwt.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
)

Expand Down
5 changes: 3 additions & 2 deletions R/fcwt_batch.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)

Expand Down
5 changes: 3 additions & 2 deletions man/fcwt.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions man/fcwt_batch.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3068925

Please sign in to comment.