diff --git a/DESCRIPTION b/DESCRIPTION index 9ddabbb6..b5be0e34 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ name: iboot -version: 4.1.0 -date: 2022-07-14 +version: 4.1.1 +date: 2022-07-15 author: Andrew Penn maintainer: Andrew Penn title: A statistics package with a variety of bootstrap resampling tools diff --git a/inst/bootknife.m b/inst/bootknife.m index d167667a..a196e312 100644 --- a/inst/bootknife.m +++ b/inst/bootknife.m @@ -271,37 +271,42 @@ % If applicable, setup a parallel pool if ~isoctave % MATLAB - if ~vectorized - % bootfun is not vectorized - if (ncpus > 0) - % MANUAL - try - pool = gcp ('nocreate'); - if isempty (pool) + % bootfun is not vectorized + if (ncpus > 0) + % MANUAL + try + pool = gcp ('nocreate'); + if isempty (pool) + if (ncpus > 1) + % Start parallel pool with ncpus workers + parpool (ncpus); + else + % Parallel pool is not running and ncpus is 1 so run function evaluations in serial + ncpus = 1; + end + else + if (pool.NumWorkers ~= ncpus) + % Check if number of workers matches ncpus and correct it accordingly if not + delete (pool); if (ncpus > 1) - % Start parallel pool with ncpus workers parpool (ncpus); - else - % Parallel pool is not running and ncpus is 1 so run function evaluations in serial - ncpus = 1; - end - else - if (pool.NumWorkers ~= ncpus) - % Check if number of workers matches ncpus and correct it accordingly if not - delete (pool); - if (ncpus > 1) - parpool (ncpus); - end end end - catch - % Parallel toolbox not installed, run function evaluations in serial - ncpus = 1; end + catch + % MATLAB Parallel Computing Toolbox is not installed + warning('MATLAB Parallel Computing Toolbox is not installed. Falling back to serial processing.') + ncpus = 1; end end + else + if (ncpus > 1) && ~isparallel + % OCTAVE Parallel Computing Package is not installed or loaded + warning('OCTAVE Parallel Computing Package is not installed and/or loaded. Falling back to serial processing.') + ncpus = 1; + end end - + % If the function of the data is a vector, calculate the statistics for each element m = numel(T0); if m > 1 @@ -451,7 +456,7 @@ else % MATLAB T = zeros (n, 1); - parfor i = 1:n; T(i) = jackfun(i); end + parfor i = 1:n; T(i) = feval(jackfun,i); end end else % SERIAL evaluation of bootfun on each jackknife resample diff --git a/inst/bootnhst.m b/inst/bootnhst.m index e28db198..aa47bd56 100644 --- a/inst/bootnhst.m +++ b/inst/bootnhst.m @@ -966,7 +966,9 @@ end end catch - % Parallel toolbox not installed, run function evaluations in serial + % MATLAB Parallel Computing Toolbox is not installed + warning('MATLAB Parallel Computing Toolbox is not installed. Falling back to serial processing.') + paropt.UseParallel = false; paropt.nproc = 1; end else @@ -986,6 +988,13 @@ end end end + else + if paropt.UseParallel && (paropt.nproc > 1) && ~isparallel + % OCTAVE Parallel Computing Package is not installed or loaded + warning('OCTAVE Parallel Computing Package is not installed and/or loaded. Falling back to serial processing.') + paropt.UseParallel = false; + paropt.nproc = 1; + end end % Define a function to calculate maxT