Skip to content

Commit 2e8d519

Browse files
committed
Squash: compacted 1b5d31c..ec1b3e7 into single commit
1 parent 2cf1438 commit 2e8d519

File tree

23 files changed

+315
-352
lines changed

23 files changed

+315
-352
lines changed

.Rbuildignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
^Makefile$
1212
^README\.Rmd$
1313
^README\.html$
14+
^README\.md$
1415
^cran-comments\.md$
1516
^dev$
1617
^doc$
@@ -21,4 +22,3 @@
2122
^scripts$
2223
^vignettes$
2324
^cpp11headers$
24-
.*\.md$

.github/workflows/R-CMD-check.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ jobs:
4444
env:
4545
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
4646
R_KEEP_PKG_SOURCE: yes
47+
TESTTHAT_PARALLEL: false
4748

4849
steps:
4950
- uses: actions/checkout@v4
@@ -78,20 +79,19 @@ jobs:
7879
if: matrix.config.custom != 'no-cpp4rtest'
7980
run: |
8081
options(warn = 2)
81-
pak::local_install_dev_deps("./extended-tests/cpp4rtest", dependencies = TRUE)
82+
pak::local_install_dev_deps("extended-tests/cpp4rtest", dependencies = TRUE)
8283
install.packages("./", repos = NULL, type = "source")
83-
install.packages("./extended-tests/cpp4rtest", repos = NULL, INSTALL_opts = "--install-tests", type = "source")
84+
install.packages("extended-tests/cpp4rtest", repos = NULL, INSTALL_opts = "--install-tests", type = "source")
8485
shell: Rscript {0}
8586

8687
- uses: r-lib/actions/check-r-package@v2
8788
with:
88-
upload-snapshots: true
8989
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'
9090

9191
- name: Run cpp4rtest tests
9292
if: matrix.config.custom != 'no-cpp4rtest'
9393
run: |
94-
setwd("./extended-tests/cpp4rtest/tests")
94+
setwd("extended-tests/cpp4rtest/tests")
9595
library(testthat)
9696
library(cpp4rtest)
9797
test_check("cpp4rtest", reporter = "progress")

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ check:
2020
@$(MAKE) clean
2121
@$(MAKE) install
2222
@$(MAKE) register
23+
@Rscript -e 'devtools::check("./", error_on = "error")'
2324
@Rscript -e 'cpp4r::register("extended-tests/cpp4rtest")'
2425
@Rscript -e 'devtools::check("./", error_on = "error")'
2526
@echo "==============================="
@@ -29,7 +30,7 @@ check:
2930
@rm -f extended-tests-results/check-results.md
3031
@export -p USE_CLANG; /bin/bash -euo pipefail -c './scripts/check_loop.sh'
3132
@echo "==============================="
32-
33+
3334
bench:
3435
@rm -f extended-tests-results/*.rds
3536
@rm -f extended-tests-results/bench_summary.md

extended-tests/Rcppbenchmark/src/RcppExports.cpp

Lines changed: 66 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -6,86 +6,92 @@
66
using namespace Rcpp;
77

88
#ifdef RCPP_USE_GLOBAL_ROSTREAM
9-
Rcpp::Rostream<true>& Rcpp::Rcout = Rcpp::Rcpp_cout_get();
9+
Rcpp::Rostream<true>& Rcpp::Rcout = Rcpp::Rcpp_cout_get();
1010
Rcpp::Rostream<false>& Rcpp::Rcerr = Rcpp::Rcpp_cerr_get();
1111
#endif
1212

1313
// add_two_rcpp_
1414
NumericMatrix add_two_rcpp_(NumericMatrix a, NumericMatrix b);
1515
RcppExport SEXP _Rcppbenchmark_add_two_rcpp_(SEXP aSEXP, SEXP bSEXP) {
16-
BEGIN_RCPP
17-
Rcpp::RObject rcpp_result_gen;
18-
Rcpp::RNGScope rcpp_rngScope_gen;
19-
Rcpp::traits::input_parameter< NumericMatrix >::type a(aSEXP);
20-
Rcpp::traits::input_parameter< NumericMatrix >::type b(bSEXP);
21-
rcpp_result_gen = Rcpp::wrap(add_two_rcpp_(a, b));
22-
return rcpp_result_gen;
23-
END_RCPP
16+
BEGIN_RCPP
17+
Rcpp::RObject rcpp_result_gen;
18+
Rcpp::RNGScope rcpp_rngScope_gen;
19+
Rcpp::traits::input_parameter<NumericMatrix>::type a(aSEXP);
20+
Rcpp::traits::input_parameter<NumericMatrix>::type b(bSEXP);
21+
rcpp_result_gen = Rcpp::wrap(add_two_rcpp_(a, b));
22+
return rcpp_result_gen;
23+
END_RCPP
2424
}
2525
// add_four_rcpp_
26-
NumericMatrix add_four_rcpp_(NumericMatrix a, NumericMatrix b, NumericMatrix c, NumericMatrix d);
27-
RcppExport SEXP _Rcppbenchmark_add_four_rcpp_(SEXP aSEXP, SEXP bSEXP, SEXP cSEXP, SEXP dSEXP) {
28-
BEGIN_RCPP
29-
Rcpp::RObject rcpp_result_gen;
30-
Rcpp::RNGScope rcpp_rngScope_gen;
31-
Rcpp::traits::input_parameter< NumericMatrix >::type a(aSEXP);
32-
Rcpp::traits::input_parameter< NumericMatrix >::type b(bSEXP);
33-
Rcpp::traits::input_parameter< NumericMatrix >::type c(cSEXP);
34-
Rcpp::traits::input_parameter< NumericMatrix >::type d(dSEXP);
35-
rcpp_result_gen = Rcpp::wrap(add_four_rcpp_(a, b, c, d));
36-
return rcpp_result_gen;
37-
END_RCPP
26+
NumericMatrix add_four_rcpp_(NumericMatrix a, NumericMatrix b, NumericMatrix c,
27+
NumericMatrix d);
28+
RcppExport SEXP _Rcppbenchmark_add_four_rcpp_(SEXP aSEXP, SEXP bSEXP, SEXP cSEXP,
29+
SEXP dSEXP) {
30+
BEGIN_RCPP
31+
Rcpp::RObject rcpp_result_gen;
32+
Rcpp::RNGScope rcpp_rngScope_gen;
33+
Rcpp::traits::input_parameter<NumericMatrix>::type a(aSEXP);
34+
Rcpp::traits::input_parameter<NumericMatrix>::type b(bSEXP);
35+
Rcpp::traits::input_parameter<NumericMatrix>::type c(cSEXP);
36+
Rcpp::traits::input_parameter<NumericMatrix>::type d(dSEXP);
37+
rcpp_result_gen = Rcpp::wrap(add_four_rcpp_(a, b, c, d));
38+
return rcpp_result_gen;
39+
END_RCPP
3840
}
3941
// multiply_four_rcpp_
40-
NumericMatrix multiply_four_rcpp_(NumericMatrix a, NumericMatrix b, NumericMatrix c, NumericMatrix d);
41-
RcppExport SEXP _Rcppbenchmark_multiply_four_rcpp_(SEXP aSEXP, SEXP bSEXP, SEXP cSEXP, SEXP dSEXP) {
42-
BEGIN_RCPP
43-
Rcpp::RObject rcpp_result_gen;
44-
Rcpp::RNGScope rcpp_rngScope_gen;
45-
Rcpp::traits::input_parameter< NumericMatrix >::type a(aSEXP);
46-
Rcpp::traits::input_parameter< NumericMatrix >::type b(bSEXP);
47-
Rcpp::traits::input_parameter< NumericMatrix >::type c(cSEXP);
48-
Rcpp::traits::input_parameter< NumericMatrix >::type d(dSEXP);
49-
rcpp_result_gen = Rcpp::wrap(multiply_four_rcpp_(a, b, c, d));
50-
return rcpp_result_gen;
51-
END_RCPP
42+
NumericMatrix multiply_four_rcpp_(NumericMatrix a, NumericMatrix b, NumericMatrix c,
43+
NumericMatrix d);
44+
RcppExport SEXP _Rcppbenchmark_multiply_four_rcpp_(SEXP aSEXP, SEXP bSEXP, SEXP cSEXP,
45+
SEXP dSEXP) {
46+
BEGIN_RCPP
47+
Rcpp::RObject rcpp_result_gen;
48+
Rcpp::RNGScope rcpp_rngScope_gen;
49+
Rcpp::traits::input_parameter<NumericMatrix>::type a(aSEXP);
50+
Rcpp::traits::input_parameter<NumericMatrix>::type b(bSEXP);
51+
Rcpp::traits::input_parameter<NumericMatrix>::type c(cSEXP);
52+
Rcpp::traits::input_parameter<NumericMatrix>::type d(dSEXP);
53+
rcpp_result_gen = Rcpp::wrap(multiply_four_rcpp_(a, b, c, d));
54+
return rcpp_result_gen;
55+
END_RCPP
5256
}
5357
// submatrix_manipulation_rcpp_
5458
NumericMatrix submatrix_manipulation_rcpp_(NumericMatrix a, NumericMatrix b);
5559
RcppExport SEXP _Rcppbenchmark_submatrix_manipulation_rcpp_(SEXP aSEXP, SEXP bSEXP) {
56-
BEGIN_RCPP
57-
Rcpp::RObject rcpp_result_gen;
58-
Rcpp::RNGScope rcpp_rngScope_gen;
59-
Rcpp::traits::input_parameter< NumericMatrix >::type a(aSEXP);
60-
Rcpp::traits::input_parameter< NumericMatrix >::type b(bSEXP);
61-
rcpp_result_gen = Rcpp::wrap(submatrix_manipulation_rcpp_(a, b));
62-
return rcpp_result_gen;
63-
END_RCPP
60+
BEGIN_RCPP
61+
Rcpp::RObject rcpp_result_gen;
62+
Rcpp::RNGScope rcpp_rngScope_gen;
63+
Rcpp::traits::input_parameter<NumericMatrix>::type a(aSEXP);
64+
Rcpp::traits::input_parameter<NumericMatrix>::type b(bSEXP);
65+
rcpp_result_gen = Rcpp::wrap(submatrix_manipulation_rcpp_(a, b));
66+
return rcpp_result_gen;
67+
END_RCPP
6468
}
6569
// multi_operation_rcpp_
6670
double multi_operation_rcpp_(NumericMatrix a, NumericMatrix b, NumericMatrix c);
6771
RcppExport SEXP _Rcppbenchmark_multi_operation_rcpp_(SEXP aSEXP, SEXP bSEXP, SEXP cSEXP) {
68-
BEGIN_RCPP
69-
Rcpp::RObject rcpp_result_gen;
70-
Rcpp::RNGScope rcpp_rngScope_gen;
71-
Rcpp::traits::input_parameter< NumericMatrix >::type a(aSEXP);
72-
Rcpp::traits::input_parameter< NumericMatrix >::type b(bSEXP);
73-
Rcpp::traits::input_parameter< NumericMatrix >::type c(cSEXP);
74-
rcpp_result_gen = Rcpp::wrap(multi_operation_rcpp_(a, b, c));
75-
return rcpp_result_gen;
76-
END_RCPP
72+
BEGIN_RCPP
73+
Rcpp::RObject rcpp_result_gen;
74+
Rcpp::RNGScope rcpp_rngScope_gen;
75+
Rcpp::traits::input_parameter<NumericMatrix>::type a(aSEXP);
76+
Rcpp::traits::input_parameter<NumericMatrix>::type b(bSEXP);
77+
Rcpp::traits::input_parameter<NumericMatrix>::type c(cSEXP);
78+
rcpp_result_gen = Rcpp::wrap(multi_operation_rcpp_(a, b, c));
79+
return rcpp_result_gen;
80+
END_RCPP
7781
}
7882

7983
static const R_CallMethodDef CallEntries[] = {
80-
{"_Rcppbenchmark_add_two_rcpp_", (DL_FUNC) &_Rcppbenchmark_add_two_rcpp_, 2},
81-
{"_Rcppbenchmark_add_four_rcpp_", (DL_FUNC) &_Rcppbenchmark_add_four_rcpp_, 4},
82-
{"_Rcppbenchmark_multiply_four_rcpp_", (DL_FUNC) &_Rcppbenchmark_multiply_four_rcpp_, 4},
83-
{"_Rcppbenchmark_submatrix_manipulation_rcpp_", (DL_FUNC) &_Rcppbenchmark_submatrix_manipulation_rcpp_, 2},
84-
{"_Rcppbenchmark_multi_operation_rcpp_", (DL_FUNC) &_Rcppbenchmark_multi_operation_rcpp_, 3},
85-
{NULL, NULL, 0}
86-
};
84+
{"_Rcppbenchmark_add_two_rcpp_", (DL_FUNC)&_Rcppbenchmark_add_two_rcpp_, 2},
85+
{"_Rcppbenchmark_add_four_rcpp_", (DL_FUNC)&_Rcppbenchmark_add_four_rcpp_, 4},
86+
{"_Rcppbenchmark_multiply_four_rcpp_", (DL_FUNC)&_Rcppbenchmark_multiply_four_rcpp_,
87+
4},
88+
{"_Rcppbenchmark_submatrix_manipulation_rcpp_",
89+
(DL_FUNC)&_Rcppbenchmark_submatrix_manipulation_rcpp_, 2},
90+
{"_Rcppbenchmark_multi_operation_rcpp_",
91+
(DL_FUNC)&_Rcppbenchmark_multi_operation_rcpp_, 3},
92+
{NULL, NULL, 0}};
8793

88-
RcppExport void R_init_Rcppbenchmark(DllInfo *dll) {
89-
R_registerRoutines(dll, NULL, CallEntries, NULL, NULL);
90-
R_useDynamicSymbols(dll, FALSE);
94+
RcppExport void R_init_Rcppbenchmark(DllInfo* dll) {
95+
R_registerRoutines(dll, NULL, CallEntries, NULL, NULL);
96+
R_useDynamicSymbols(dll, FALSE);
9197
}

extended-tests/cpp4rtest/src/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#include <cpp4r.hpp>
22

3-
#include <numeric> // for std::accumulate
4-
#include <deque> // for std::deque
53
#include <Rmath.h> // for Rf_rgamma, Rf_rnorm
4+
#include <deque> // for std::deque
5+
#include <numeric> // for std::accumulate
66

77
using namespace cpp4r;
88

extended-tests/cpp4rtest/src/matrix.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@
100100
}
101101

102102
// Test function for automatic integer to double matrix coercion
103-
[[cpp4r::register]] cpp4r::doubles_matrix<> matrix_add(
104-
const cpp4r::doubles_matrix<>& x, const cpp4r::doubles_matrix<>& y) {
103+
[[cpp4r::register]] cpp4r::doubles_matrix<> matrix_add(const cpp4r::doubles_matrix<>& x,
104+
const cpp4r::doubles_matrix<>& y) {
105105
int nrow = x.nrow();
106106
int ncol = x.ncol();
107107

extended-tests/cpp4rtest/src/test-runner.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* This file ensures that the package exports a 'run_testthat_tests()'
2+
* This file ensures that the package exports a 'run_testthat_tests()'
33
* C routine that can be used to run the Catch unit tests.
44
*/
55

inst/include/cpp4r/R.hpp

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ namespace detail {
6767
// which can throw warnings with `-Wsign-compare` on Windows.
6868
inline SEXPTYPE r_typeof(SEXP x) noexcept { return static_cast<SEXPTYPE>(TYPEOF(x)); }
6969

70-
/// Get an object from an environment
71-
///
72-
/// SAFETY: Keep as a pure C function. Call like an R API function, i.e. wrap in `safe[]`
73-
/// as required.
70+
// Get an object from an environment
71+
//
72+
// SAFETY: Keep as a pure C function. Call like an R API function, i.e. wrap in `safe[]`
73+
// as required.
7474
inline SEXP r_env_get(SEXP env, SEXP sym) {
7575
#if defined(R_VERSION) && R_VERSION >= R_Version(4, 5, 0)
7676
const Rboolean inherits = FALSE;
@@ -102,10 +102,10 @@ inline SEXP r_env_get(SEXP env, SEXP sym) {
102102
#endif
103103
}
104104

105-
/// Check if an object exists in an environment
106-
///
107-
/// SAFETY: Keep as a pure C function. Call like an R API function, i.e. wrap in `safe[]`
108-
/// as required.
105+
// Check if an object exists in an environment
106+
//
107+
// SAFETY: Keep as a pure C function. Call like an R API function, i.e. wrap in `safe[]`
108+
// as required.
109109
inline bool r_env_has(SEXP env, SEXP sym) {
110110
#if R_VERSION >= R_Version(4, 2, 0)
111111
return R_existsVarInFrame(env, sym);
@@ -119,7 +119,8 @@ inline bool r_env_has(SEXP env, SEXP sym) {
119119
template <typename T>
120120
inline T na();
121121

122-
// Progressive C++ optimization: Use if constexpr in C++17+ for zero-overhead type dispatch
122+
// Progressive C++ optimization: Use if constexpr in C++17+ for zero-overhead type
123+
// dispatch
123124
#if CPP4R_HAS_CXX17
124125
template <typename T>
125126
CPP4R_HOT inline bool is_na(const T& value) {
@@ -135,16 +136,18 @@ CPP4R_HOT inline bool is_na(const T& value) {
135136
#else
136137
// C++11/14: Use SFINAE (slower compilation, same runtime performance)
137138
template <typename T>
138-
CPP4R_HOT inline typename std::enable_if<!std::is_same<typename std::decay<T>::type, double>::value,
139-
bool>::type
140-
is_na(const T& value) {
139+
CPP4R_HOT inline
140+
typename std::enable_if<!std::is_same<typename std::decay<T>::type, double>::value,
141+
bool>::type
142+
is_na(const T& value) {
141143
return value == na<T>();
142144
}
143145

144146
template <typename T>
145-
CPP4R_HOT inline typename std::enable_if<std::is_same<typename std::decay<T>::type, double>::value,
146-
bool>::type
147-
is_na(const T& value) {
147+
CPP4R_HOT inline
148+
typename std::enable_if<std::is_same<typename std::decay<T>::type, double>::value,
149+
bool>::type
150+
is_na(const T& value) {
148151
return ISNA(value);
149152
}
150153
#endif

inst/include/cpp4r/as.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ enable_if_std_string<T, T> as_cpp(SEXP from) {
224224
return {as_cpp<const char*>(from)};
225225
}
226226

227-
/// Temporary workaround for compatibility with cpp4r 0.1.0
227+
// Temporary workaround for compatibility with cpp4r 0.1.0
228228
template <typename T>
229229
enable_if_t<!std::is_same<decay_t<T>, T>::value, decay_t<T>> as_cpp(SEXP from) {
230230
return as_cpp<decay_t<T>>(from);

inst/include/cpp4r/complexes.hpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ inline complexes as_complexes(SEXP x) {
101101
throw type_error(CPLXSXP, detail::r_typeof(x));
102102
}
103103

104-
// No proxy redefinition here — use the generic proxy implementation from r_vector_writable_impl.hpp
104+
// No proxy redefinition here — use the generic proxy implementation from
105+
// r_vector_writable_impl.hpp
105106

106107
// New complex_vector class for handling complex numbers in SEXP
107108
class complex_vector {
@@ -150,7 +151,8 @@ inline r_vector<r_complex>::r_vector(std::initializer_list<r_complex> il)
150151

151152
// Comparison operators for r_vector<r_complex>
152153
template <>
153-
inline bool operator==(const r_vector<r_complex>& lhs, const r_vector<r_complex>& rhs) noexcept {
154+
inline bool operator==(const r_vector<r_complex>& lhs,
155+
const r_vector<r_complex>& rhs) noexcept {
154156
if (lhs.size() != rhs.size()) return false;
155157
for (R_xlen_t i = 0; i < lhs.size(); ++i) {
156158
if (!(lhs[i] == rhs[i])) return false;
@@ -159,7 +161,8 @@ inline bool operator==(const r_vector<r_complex>& lhs, const r_vector<r_complex>
159161
}
160162

161163
template <>
162-
inline bool operator!=(const r_vector<r_complex>& lhs, const r_vector<r_complex>& rhs) noexcept {
164+
inline bool operator!=(const r_vector<r_complex>& lhs,
165+
const r_vector<r_complex>& rhs) noexcept {
163166
return !(lhs == rhs);
164167
}
165168

0 commit comments

Comments
 (0)