From 3bd8c5cced4415f531c9ae83adf5f77fce361cb8 Mon Sep 17 00:00:00 2001 From: SpatLyu Date: Thu, 18 Jun 2026 00:00:01 +0800 Subject: [PATCH 01/15] new suggesting dependences --- DESCRIPTION | 3 +++ 1 file changed, 3 insertions(+) diff --git a/DESCRIPTION b/DESCRIPTION index e1b2677..cf58c2a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -17,7 +17,10 @@ LinkingTo: Rcpp, RcppThread Suggests: + infoxtr, + pc, Rcpp, RcppThread, + spEDM Config/roxygen2/markdown: TRUE Config/roxygen2/version: 8.0.0 From 621490d444d0748e7b792b466711513c3b0478a9 Mon Sep 17 00:00:00 2001 From: SpatLyu Date: Thu, 18 Jun 2026 00:00:01 +0800 Subject: [PATCH 02/15] check for available threads --- inst/include/coupling/metacoupling.hpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/inst/include/coupling/metacoupling.hpp b/inst/include/coupling/metacoupling.hpp index 5e0b639..f7cfd26 100644 --- a/inst/include/coupling/metacoupling.hpp +++ b/inst/include/coupling/metacoupling.hpp @@ -312,6 +312,13 @@ inline std::vector> metacoupling_c( result[1][s] = peri_sum; result[2][s] = tele_sum; }; + + // ============================================================ + // Check for available threads + // ============================================================ + if (threads == 0) threads = 1; + size_t hw = std::thread::hardware_concurrency(); + if (hw > 0) threads = std::min(threads, hw); // ============================================================ // Parallel or serial execution @@ -357,6 +364,13 @@ inline std::vector> metacoupling( size_t full_perm = 1ULL << p; + // ============================================================ + // Check for available threads + // ============================================================ + if (threads == 0) threads = 1; + size_t hw = std::thread::hardware_concurrency(); + if (hw > 0) threads = std::min(threads, hw); + // ============================================================ // Step 1: reuse existing C computation // ============================================================ From 3b373062145e3758e7ce405a516f7dce57867236 Mon Sep 17 00:00:00 2001 From: SpatLyu Date: Thu, 18 Jun 2026 00:00:01 +0800 Subject: [PATCH 03/15] check for available threads --- inst/include/coupling/ccd.hpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/inst/include/coupling/ccd.hpp b/inst/include/coupling/ccd.hpp index d978cb8..d2c18ac 100644 --- a/inst/include/coupling/ccd.hpp +++ b/inst/include/coupling/ccd.hpp @@ -295,6 +295,10 @@ inline std::vector ccd_c( if (n_units == 0) return {}; std::vector result(n_units, 0.0); + + if (threads == 0) threads = 1; + size_t hw = std::thread::hardware_concurrency(); + if (hw > 0) threads = std::min(threads, hw); if (threads <= 1) { for (size_t i = 0; i < n_units; ++i) { From b008c427bf29cd44becd864c56499ee9ca5baed0 Mon Sep 17 00:00:00 2001 From: SpatLyu Date: Thu, 18 Jun 2026 00:00:01 +0800 Subject: [PATCH 04/15] check for available threads --- inst/include/coupling/metacoupling.hpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/inst/include/coupling/metacoupling.hpp b/inst/include/coupling/metacoupling.hpp index f7cfd26..a409503 100644 --- a/inst/include/coupling/metacoupling.hpp +++ b/inst/include/coupling/metacoupling.hpp @@ -413,11 +413,7 @@ inline std::vector> metacoupling( return sum_t / static_cast(count); }; - // ============================================================ - // Step 3: assemble results - // ============================================================ - for (size_t s = 0; s < n_units; ++s) { - + auto worker4D = [&](size_t s) { // ---- intra ---- double C_intra = C_res[0][s]; double T_intra = compute_T_intra(s); @@ -456,6 +452,17 @@ inline std::vector> metacoupling( result[4][s] = C_tele; result[5][s] = std::sqrt(C_tele * tele_T_sum); + }; + + // ============================================================ + // Step 3: assemble results + // ============================================================ + if (threads <= 1) { + for (size_t s = 0; s < n_units; ++s) { + worker4D(s); + } + } else { + RcppThread::parallelFor(0, n_units, worker4D, threads); } return result; From dfb8b1f2fc71f2859aad4158a79a97ae09606b3f Mon Sep 17 00:00:00 2001 From: SpatLyu Date: Thu, 18 Jun 2026 00:00:01 +0800 Subject: [PATCH 05/15] update title field in descripion --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index cf58c2a..b9f2150 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: coupling -Title: Coupling Coordination Analysis +Title: Analysis of Coupling Coordination Degree Version: 0.0.0.9000 Authors@R: person(given = "Wenbo", family = "Lyu", From 60c5f78f329ec3d962a5293d2f42445969f88c89 Mon Sep 17 00:00:00 2001 From: SpatLyu Date: Thu, 18 Jun 2026 00:00:01 +0800 Subject: [PATCH 06/15] update title field in descripion --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 92357a5..953b9b0 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ coupling website: https://stscl.github.io/coupling/ -***Coupling** Coordination Analysis* +*Analysis of Coupling Coordination Degree* *coupling* is an R package for coupling coordination analysis based on coupling coordination degree (CCD) models. It incorporates metacoupling frameworks to characterize cross-scale linkages, flows, and feedbacks within and among coupled systems. From b9e8946ca0b36f5f152e6d83c8c7d31ac3646a9a Mon Sep 17 00:00:00 2001 From: SpatLyu Date: Thu, 18 Jun 2026 00:00:01 +0800 Subject: [PATCH 07/15] update title field in pkg website --- _pkgdown.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_pkgdown.yml b/_pkgdown.yml index 36d1273..15cd5bd 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -18,7 +18,7 @@ navbar: home: title: | - ccd | Coupling Coordination Analysis + coupling | Analysis of Coupling Coordination Degree authors: Wenbo Lyu: href: https://spatlyu.github.io/ From fd92c86d13a2827dae3c9e29f7f51c220ceb9bd8 Mon Sep 17 00:00:00 2001 From: SpatLyu Date: Thu, 18 Jun 2026 00:00:01 +0800 Subject: [PATCH 08/15] add cran comments file --- .Rbuildignore | 1 + cran-comments.md | 5 +++++ 2 files changed, 6 insertions(+) create mode 100644 cran-comments.md diff --git a/.Rbuildignore b/.Rbuildignore index b7364c9..3f92db2 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -4,3 +4,4 @@ ^_pkgdown\.yml$ ^docs$ ^pkgdown$ +^cran-comments\.md$ diff --git a/cran-comments.md b/cran-comments.md new file mode 100644 index 0000000..858617d --- /dev/null +++ b/cran-comments.md @@ -0,0 +1,5 @@ +## R CMD check results + +0 errors | 0 warnings | 1 note + +* This is a new release. From 79d5126be9dc73d8f8e6e3a15bd4355db563985a Mon Sep 17 00:00:00 2001 From: SpatLyu Date: Thu, 18 Jun 2026 00:00:01 +0800 Subject: [PATCH 09/15] use news document --- NEWS.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 NEWS.md diff --git a/NEWS.md b/NEWS.md new file mode 100644 index 0000000..833dc81 --- /dev/null +++ b/NEWS.md @@ -0,0 +1,3 @@ +# coupling (development version) + +* Initial CRAN submission. From 1d0854661fc3b858812f253dfe90982960381ef7 Mon Sep 17 00:00:00 2001 From: SpatLyu Date: Thu, 18 Jun 2026 00:00:01 +0800 Subject: [PATCH 10/15] bump version number --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index b9f2150..697e77c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: coupling Title: Analysis of Coupling Coordination Degree -Version: 0.0.0.9000 +Version: 0.1 Authors@R: person(given = "Wenbo", family = "Lyu", email = "lyu.geosocial@gmail.com", From 92a4eebbf0d7772177be33e8a19d5d6a86a5eec0 Mon Sep 17 00:00:00 2001 From: SpatLyu Date: Thu, 18 Jun 2026 00:00:01 +0800 Subject: [PATCH 11/15] bump version number --- NEWS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 833dc81..33ebd9b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,3 @@ -# coupling (development version) +# coupling 0.1 * Initial CRAN submission. From ed79e0801956afad1dbfba6ef9dff89e4a3d13ab Mon Sep 17 00:00:00 2001 From: SpatLyu Date: Thu, 18 Jun 2026 00:00:01 +0800 Subject: [PATCH 12/15] use citation file --- inst/CITATION | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 inst/CITATION diff --git a/inst/CITATION b/inst/CITATION new file mode 100644 index 0000000..f553ffb --- /dev/null +++ b/inst/CITATION @@ -0,0 +1,10 @@ +citHeader("To cite package coupling in publications, please use:") + +bibentry( + bibtype = "Manual", + title = "{coupling: Analysis of Coupling Coordination Degree}", + author = "Wenbo Lyu", + year = "2026", + note = "R package version 0.1", + doi = "10.32614/CRAN.package.coupling" +) From b899a2a9b063c8b0088ca471054300ed90072a3e Mon Sep 17 00:00:00 2001 From: SpatLyu Date: Sun, 10 May 2026 21:47:03 +0800 Subject: [PATCH 13/15] use r-hub github action --- .github/workflows/rhub.yaml | 95 +++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 .github/workflows/rhub.yaml diff --git a/.github/workflows/rhub.yaml b/.github/workflows/rhub.yaml new file mode 100644 index 0000000..74ec7b0 --- /dev/null +++ b/.github/workflows/rhub.yaml @@ -0,0 +1,95 @@ +# R-hub's generic GitHub Actions workflow file. It's canonical location is at +# https://github.com/r-hub/actions/blob/v1/workflows/rhub.yaml +# You can update this file to a newer version using the rhub2 package: +# +# rhub::rhub_setup() +# +# It is unlikely that you need to modify this file manually. + +name: R-hub +run-name: "${{ github.event.inputs.id }}: ${{ github.event.inputs.name || format('Manually run by {0}', github.triggering_actor) }}" + +on: + workflow_dispatch: + inputs: + config: + description: 'A comma separated list of R-hub platforms to use.' + type: string + default: 'linux,windows,macos' + name: + description: 'Run name. You can leave this empty now.' + type: string + id: + description: 'Unique ID. You can leave this empty now.' + type: string + +jobs: + + setup: + runs-on: ubuntu-latest + outputs: + containers: ${{ steps.rhub-setup.outputs.containers }} + platforms: ${{ steps.rhub-setup.outputs.platforms }} + + steps: + # NO NEED TO CHECKOUT HERE + - uses: r-hub/actions/setup@v1 + with: + config: ${{ github.event.inputs.config }} + id: rhub-setup + + linux-containers: + needs: setup + if: ${{ needs.setup.outputs.containers != '[]' }} + runs-on: ubuntu-latest + name: ${{ matrix.config.label }} + strategy: + fail-fast: false + matrix: + config: ${{ fromJson(needs.setup.outputs.containers) }} + container: + image: ${{ matrix.config.container }} + + steps: + - uses: r-hub/actions/checkout@v1 + - uses: r-hub/actions/platform-info@v1 + with: + token: ${{ secrets.RHUB_TOKEN }} + job-config: ${{ matrix.config.job-config }} + - uses: r-hub/actions/setup-deps@v1 + with: + token: ${{ secrets.RHUB_TOKEN }} + job-config: ${{ matrix.config.job-config }} + - uses: r-hub/actions/run-check@v1 + with: + token: ${{ secrets.RHUB_TOKEN }} + job-config: ${{ matrix.config.job-config }} + + other-platforms: + needs: setup + if: ${{ needs.setup.outputs.platforms != '[]' }} + runs-on: ${{ matrix.config.os }} + name: ${{ matrix.config.label }} + strategy: + fail-fast: false + matrix: + config: ${{ fromJson(needs.setup.outputs.platforms) }} + + steps: + - uses: r-hub/actions/checkout@v1 + - uses: r-hub/actions/setup-r@v1 + with: + job-config: ${{ matrix.config.job-config }} + token: ${{ secrets.RHUB_TOKEN }} + - uses: r-hub/actions/platform-info@v1 + with: + token: ${{ secrets.RHUB_TOKEN }} + job-config: ${{ matrix.config.job-config }} + - uses: r-hub/actions/setup-deps@v1 + with: + job-config: ${{ matrix.config.job-config }} + token: ${{ secrets.RHUB_TOKEN }} + - uses: r-hub/actions/run-check@v1 + with: + job-config: ${{ matrix.config.job-config }} + token: ${{ secrets.RHUB_TOKEN }} From 8967ddd6c657ad14d066276947925d00731edece Mon Sep 17 00:00:00 2001 From: SpatLyu Date: Thu, 18 Jun 2026 00:00:01 +0800 Subject: [PATCH 14/15] use r-hub github action --- .github/workflows/rhub.yaml | 95 ------------------------------------- 1 file changed, 95 deletions(-) delete mode 100644 .github/workflows/rhub.yaml diff --git a/.github/workflows/rhub.yaml b/.github/workflows/rhub.yaml deleted file mode 100644 index 74ec7b0..0000000 --- a/.github/workflows/rhub.yaml +++ /dev/null @@ -1,95 +0,0 @@ -# R-hub's generic GitHub Actions workflow file. It's canonical location is at -# https://github.com/r-hub/actions/blob/v1/workflows/rhub.yaml -# You can update this file to a newer version using the rhub2 package: -# -# rhub::rhub_setup() -# -# It is unlikely that you need to modify this file manually. - -name: R-hub -run-name: "${{ github.event.inputs.id }}: ${{ github.event.inputs.name || format('Manually run by {0}', github.triggering_actor) }}" - -on: - workflow_dispatch: - inputs: - config: - description: 'A comma separated list of R-hub platforms to use.' - type: string - default: 'linux,windows,macos' - name: - description: 'Run name. You can leave this empty now.' - type: string - id: - description: 'Unique ID. You can leave this empty now.' - type: string - -jobs: - - setup: - runs-on: ubuntu-latest - outputs: - containers: ${{ steps.rhub-setup.outputs.containers }} - platforms: ${{ steps.rhub-setup.outputs.platforms }} - - steps: - # NO NEED TO CHECKOUT HERE - - uses: r-hub/actions/setup@v1 - with: - config: ${{ github.event.inputs.config }} - id: rhub-setup - - linux-containers: - needs: setup - if: ${{ needs.setup.outputs.containers != '[]' }} - runs-on: ubuntu-latest - name: ${{ matrix.config.label }} - strategy: - fail-fast: false - matrix: - config: ${{ fromJson(needs.setup.outputs.containers) }} - container: - image: ${{ matrix.config.container }} - - steps: - - uses: r-hub/actions/checkout@v1 - - uses: r-hub/actions/platform-info@v1 - with: - token: ${{ secrets.RHUB_TOKEN }} - job-config: ${{ matrix.config.job-config }} - - uses: r-hub/actions/setup-deps@v1 - with: - token: ${{ secrets.RHUB_TOKEN }} - job-config: ${{ matrix.config.job-config }} - - uses: r-hub/actions/run-check@v1 - with: - token: ${{ secrets.RHUB_TOKEN }} - job-config: ${{ matrix.config.job-config }} - - other-platforms: - needs: setup - if: ${{ needs.setup.outputs.platforms != '[]' }} - runs-on: ${{ matrix.config.os }} - name: ${{ matrix.config.label }} - strategy: - fail-fast: false - matrix: - config: ${{ fromJson(needs.setup.outputs.platforms) }} - - steps: - - uses: r-hub/actions/checkout@v1 - - uses: r-hub/actions/setup-r@v1 - with: - job-config: ${{ matrix.config.job-config }} - token: ${{ secrets.RHUB_TOKEN }} - - uses: r-hub/actions/platform-info@v1 - with: - token: ${{ secrets.RHUB_TOKEN }} - job-config: ${{ matrix.config.job-config }} - - uses: r-hub/actions/setup-deps@v1 - with: - job-config: ${{ matrix.config.job-config }} - token: ${{ secrets.RHUB_TOKEN }} - - uses: r-hub/actions/run-check@v1 - with: - job-config: ${{ matrix.config.job-config }} - token: ${{ secrets.RHUB_TOKEN }} From f548d117687ccaf6d5710650208b452f119c7385 Mon Sep 17 00:00:00 2001 From: SpatLyu Date: Thu, 18 Jun 2026 00:00:01 +0800 Subject: [PATCH 15/15] use r-hub github action --- .github/workflows/rhub.yaml | 95 +++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 .github/workflows/rhub.yaml diff --git a/.github/workflows/rhub.yaml b/.github/workflows/rhub.yaml new file mode 100644 index 0000000..74ec7b0 --- /dev/null +++ b/.github/workflows/rhub.yaml @@ -0,0 +1,95 @@ +# R-hub's generic GitHub Actions workflow file. It's canonical location is at +# https://github.com/r-hub/actions/blob/v1/workflows/rhub.yaml +# You can update this file to a newer version using the rhub2 package: +# +# rhub::rhub_setup() +# +# It is unlikely that you need to modify this file manually. + +name: R-hub +run-name: "${{ github.event.inputs.id }}: ${{ github.event.inputs.name || format('Manually run by {0}', github.triggering_actor) }}" + +on: + workflow_dispatch: + inputs: + config: + description: 'A comma separated list of R-hub platforms to use.' + type: string + default: 'linux,windows,macos' + name: + description: 'Run name. You can leave this empty now.' + type: string + id: + description: 'Unique ID. You can leave this empty now.' + type: string + +jobs: + + setup: + runs-on: ubuntu-latest + outputs: + containers: ${{ steps.rhub-setup.outputs.containers }} + platforms: ${{ steps.rhub-setup.outputs.platforms }} + + steps: + # NO NEED TO CHECKOUT HERE + - uses: r-hub/actions/setup@v1 + with: + config: ${{ github.event.inputs.config }} + id: rhub-setup + + linux-containers: + needs: setup + if: ${{ needs.setup.outputs.containers != '[]' }} + runs-on: ubuntu-latest + name: ${{ matrix.config.label }} + strategy: + fail-fast: false + matrix: + config: ${{ fromJson(needs.setup.outputs.containers) }} + container: + image: ${{ matrix.config.container }} + + steps: + - uses: r-hub/actions/checkout@v1 + - uses: r-hub/actions/platform-info@v1 + with: + token: ${{ secrets.RHUB_TOKEN }} + job-config: ${{ matrix.config.job-config }} + - uses: r-hub/actions/setup-deps@v1 + with: + token: ${{ secrets.RHUB_TOKEN }} + job-config: ${{ matrix.config.job-config }} + - uses: r-hub/actions/run-check@v1 + with: + token: ${{ secrets.RHUB_TOKEN }} + job-config: ${{ matrix.config.job-config }} + + other-platforms: + needs: setup + if: ${{ needs.setup.outputs.platforms != '[]' }} + runs-on: ${{ matrix.config.os }} + name: ${{ matrix.config.label }} + strategy: + fail-fast: false + matrix: + config: ${{ fromJson(needs.setup.outputs.platforms) }} + + steps: + - uses: r-hub/actions/checkout@v1 + - uses: r-hub/actions/setup-r@v1 + with: + job-config: ${{ matrix.config.job-config }} + token: ${{ secrets.RHUB_TOKEN }} + - uses: r-hub/actions/platform-info@v1 + with: + token: ${{ secrets.RHUB_TOKEN }} + job-config: ${{ matrix.config.job-config }} + - uses: r-hub/actions/setup-deps@v1 + with: + job-config: ${{ matrix.config.job-config }} + token: ${{ secrets.RHUB_TOKEN }} + - uses: r-hub/actions/run-check@v1 + with: + job-config: ${{ matrix.config.job-config }} + token: ${{ secrets.RHUB_TOKEN }}