From c82ce5d22e379da6cf1193183f57d3227750994d Mon Sep 17 00:00:00 2001 From: david-cortes Date: Wed, 8 Mar 2023 19:56:56 +0100 Subject: [PATCH] solve CRAN complaints --- CMakeLists.txt | 2 +- DESCRIPTION | 2 +- setup.py | 2 +- src/helpers.c | 6 ++++-- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ce1450a..5af0835 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required (VERSION 3.12.4) -project (cmfrec VERSION 3.6.0) +project (cmfrec VERSION 3.5.1) set(CMAKE_BUILD_TYPE Release) ### Note: this build script allows configuring 4 things manually: diff --git a/DESCRIPTION b/DESCRIPTION index 899f32e..29d65b3 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: cmfrec Type: Package Title: Collective Matrix Factorization for Recommender Systems -Version: 3.6.0 +Version: 3.5.1 Authors@R: c( person(given="David", family="Cortes", role=c("aut", "cre", "cph"), email="david.cortes.rivera@gmail.com"), diff --git a/setup.py b/setup.py index 790943f..a606b35 100644 --- a/setup.py +++ b/setup.py @@ -309,7 +309,7 @@ def test_supports_clang_reassociate(self): setup( name = "cmfrec", packages = ["cmfrec"], - version = '3.5.0-1', + version = '3.5.1', description = 'Collective matrix factorization', author = 'David Cortes', author_email = 'david.cortes.rivera@gmail.com', diff --git a/src/helpers.c b/src/helpers.c index 99509a9..322af04 100644 --- a/src/helpers.c +++ b/src/helpers.c @@ -964,7 +964,7 @@ int_t random_parallel(ArraysToFill arrays, int_t seed, bool normal, int nthreads const size_t BUCKET_SIZE = (size_t)1 << 18; /* <- a bit over 250k */ rng_state_t initial_state[4]; seed_state(seed, initial_state); - if (arrays.sizeA + arrays.sizeB < BUCKET_SIZE) + if (arrays.sizeA + arrays.sizeB <= BUCKET_SIZE) { rnorm_singlethread(arrays, initial_state); return 0; @@ -972,7 +972,9 @@ int_t random_parallel(ArraysToFill arrays, int_t seed, bool normal, int nthreads const size_t buckA = arrays.sizeA / BUCKET_SIZE + (arrays.sizeA % BUCKET_SIZE) != 0; const size_t buckB = arrays.sizeB / BUCKET_SIZE + (arrays.sizeB % BUCKET_SIZE) != 0; - const size_t tot_buckets = buckA + buckB; + const size_t tot_buckets = max2(1, buckA + buckB); + /* Note: the condition above is not needed, but GCC12 complains otherwise + and by extension CRAN complains too */ real_t **ptr_bucket = (real_t**)malloc(tot_buckets*sizeof(real_t*)); size_t *sz_bucket = (size_t*)malloc(tot_buckets*sizeof(size_t));