├── .Rbuildignore ├── .Rinstignore ├── .codecov.yml ├── .editorconfig ├── .gitattributes ├── .github ├── CONTRIBUTING.md ├── FUNDING.yml ├── ISSUE_TEMPLATE.md ├── PULL_REQUEST_TEMPLATE.md └── workflows │ ├── ci.yaml │ ├── docker.yaml │ ├── linuxarm.yaml │ ├── macos.yaml │ └── stale.yaml ├── .gitignore ├── ChangeLog ├── Contributing.md ├── DESCRIPTION ├── LICENSE ├── NAMESPACE ├── R ├── 00_classes.R ├── 01_show.R ├── 02_completion.R ├── 03_prompt.R ├── Attributes.R ├── Module.R ├── Rcpp.package.skeleton.R ├── RcppClass.R ├── RcppLdpath.R ├── bib.R ├── compilerCheck.R ├── exceptions.R ├── exposeClass.R ├── inline.R ├── loadModule.R ├── loadRcppModules.R ├── populate.R ├── tools.R └── zzz.R ├── README.md ├── Rcpp.Rproj ├── TODO ├── cleanup ├── docker ├── ci-3.4 │ └── Dockerfile ├── ci-3.5 │ └── Dockerfile ├── ci-3.6 │ └── Dockerfile ├── ci-4.0 │ └── Dockerfile ├── ci-4.1 │ └── Dockerfile ├── ci-4.2 │ └── Dockerfile ├── ci-4.3 │ └── Dockerfile ├── ci-4.4 │ └── Dockerfile ├── ci-dev │ └── Dockerfile ├── ci │ └── Dockerfile ├── plus │ └── Dockerfile └── run │ └── Dockerfile ├── doxyfile ├── inst ├── CITATION ├── NEWS.Rd ├── announce │ ├── ANNOUNCE-0.10.0.txt │ ├── ANNOUNCE-0.11.0.txt │ ├── ANNOUNCE-0.6.0.txt │ ├── ANNOUNCE-0.7.0.txt │ ├── ANNOUNCE-0.8.0.txt │ └── ANNOUNCE-0.9.0.txt ├── bib │ └── Rcpp.bib ├── discovery │ └── cxx0x.R ├── examples │ ├── Attributes │ │ ├── Depends.cpp │ │ ├── Export.cpp │ │ ├── cppFunction.R │ │ └── sourceCpp.R │ ├── ConvolveBenchmarks │ │ ├── GNUmakefile │ │ ├── buildAndRun.sh │ │ ├── convolve10_cpp.cpp │ │ ├── convolve10_cpp.h │ │ ├── convolve11_cpp.cpp │ │ ├── convolve12_cpp.cpp │ │ ├── convolve13_cpp.cpp │ │ ├── convolve14_cpp.cpp │ │ ├── convolve2_c.c │ │ ├── convolve3_cpp.cpp │ │ ├── convolve4_cpp.cpp │ │ ├── convolve5_cpp.cpp │ │ ├── convolve7_c.c │ │ ├── convolve8_cpp.cpp │ │ ├── convolve9_cpp.cpp │ │ ├── exampleRCode.r │ │ ├── loopmacro.h │ │ ├── overhead.r │ │ ├── overhead.sh │ │ ├── overhead_1.cpp │ │ └── overhead_2.c │ ├── FastLM │ │ ├── benchmark.r │ │ ├── benchmarkLongley.r │ │ ├── fastLMviaArmadillo.r │ │ ├── fastLMviaGSL.r │ │ ├── lmArmadillo.R │ │ └── lmGSL.R │ ├── Misc │ │ ├── fibonacci.r │ │ ├── ifelseLooped.r │ │ ├── newFib.r │ │ ├── piBySimulation.r │ │ └── piSugar.cpp │ ├── OpenMP │ │ ├── GNUmakefile │ │ ├── OpenMPandInline.r │ │ ├── check.R │ │ └── piWithInterrupts.cpp │ ├── RcppGibbs │ │ ├── RcppGibbs.R │ │ ├── RcppGibbs_Updated.R │ │ └── timeRNGs.R │ ├── RcppInline │ │ ├── RObject.r │ │ ├── RcppInlineExample.r │ │ ├── RcppInlineWithLibsExamples.r │ │ ├── RcppSimpleExample.r │ │ ├── UncaughtExceptions.r │ │ └── external_pointer.r │ ├── SugarPerformance │ │ ├── Timer.h │ │ ├── Timertest.cpp │ │ └── sugarBenchmarks.R │ ├── functionCallback │ │ ├── README │ │ └── newApiExample.r │ └── performance │ │ ├── extractors.R │ │ └── performance.R ├── include │ ├── Rcpp.h │ ├── Rcpp │ │ ├── Benchmark │ │ │ └── Timer.h │ │ ├── DataFrame.h │ │ ├── Dimension.h │ │ ├── DottedPair.h │ │ ├── DottedPairImpl.h │ │ ├── Environment.h │ │ ├── Extractor.h │ │ ├── Fast.h │ │ ├── Formula.h │ │ ├── Function.h │ │ ├── InputParameter.h │ │ ├── InternalFunction.h │ │ ├── InternalFunctionWithStdFunction.h │ │ ├── Interrupt.h │ │ ├── Language.h │ │ ├── Light │ │ ├── Lighter │ │ ├── Lightest │ │ ├── Module.h │ │ ├── Na_Proxy.h │ │ ├── Named.h │ │ ├── Nullable.h │ │ ├── Pairlist.h │ │ ├── Promise.h │ │ ├── RNGScope.h │ │ ├── RObject.h │ │ ├── Rcpp │ │ ├── Reference.h │ │ ├── Rmath.h │ │ ├── S4.h │ │ ├── StretchyList.h │ │ ├── String.h │ │ ├── StringTransformer.h │ │ ├── Symbol.h │ │ ├── Vector.h │ │ ├── WeakReference.h │ │ ├── XPtr.h │ │ ├── algo.h │ │ ├── algorithm.h │ │ ├── api │ │ │ ├── bones │ │ │ │ ├── Date.h │ │ │ │ ├── Datetime.h │ │ │ │ ├── bones.h │ │ │ │ └── wrap_extra_steps.h │ │ │ └── meat │ │ │ │ ├── DataFrame.h │ │ │ │ ├── Date.h │ │ │ │ ├── Datetime.h │ │ │ │ ├── Dimension.h │ │ │ │ ├── DottedPairImpl.h │ │ │ │ ├── Environment.h │ │ │ │ ├── Rcpp_eval.h │ │ │ │ ├── S4.h │ │ │ │ ├── StretchyList.h │ │ │ │ ├── Vector.h │ │ │ │ ├── as.h │ │ │ │ ├── export.h │ │ │ │ ├── is.h │ │ │ │ ├── meat.h │ │ │ │ ├── message.h │ │ │ │ ├── module │ │ │ │ └── Module.h │ │ │ │ ├── protection.h │ │ │ │ ├── proxy.h │ │ │ │ └── wrap.h │ │ ├── as.h │ │ ├── barrier.h │ │ ├── clone.h │ │ ├── complex.h │ │ ├── config.h │ │ ├── date_datetime │ │ │ ├── Date.h │ │ │ ├── Datetime.h │ │ │ ├── date_datetime.h │ │ │ ├── newDateVector.h │ │ │ ├── newDatetimeVector.h │ │ │ ├── oldDateVector.h │ │ │ └── oldDatetimeVector.h │ │ ├── exceptions.h │ │ ├── exceptions_impl.h │ │ ├── grow.h │ │ ├── hash │ │ │ ├── IndexHash.h │ │ │ ├── SelfHash.h │ │ │ └── hash.h │ │ ├── internal │ │ │ ├── Exporter.h │ │ │ ├── GreedyVector.h │ │ │ ├── ListInitialization.h │ │ │ ├── NAComparator.h │ │ │ ├── NAEquals.h │ │ │ ├── Proxy_Iterator.h │ │ │ ├── SEXP_Iterator.h │ │ │ ├── call.h │ │ │ ├── caster.h │ │ │ ├── converter.h │ │ │ ├── export.h │ │ │ ├── na.h │ │ │ ├── r_coerce.h │ │ │ ├── r_vector.h │ │ │ ├── wrap.h │ │ │ └── wrap_end.h │ │ ├── iostream │ │ │ └── Rstreambuf.h │ │ ├── is.h │ │ ├── lang.h │ │ ├── lgrow.h │ │ ├── longlong.h │ │ ├── macros │ │ │ ├── cat.hpp │ │ │ ├── config.hpp │ │ │ ├── debug.h │ │ │ ├── dispatch.h │ │ │ ├── interface.h │ │ │ ├── macros.h │ │ │ ├── module.h │ │ │ ├── traits.h │ │ │ ├── unroll.h │ │ │ └── xp.h │ │ ├── module │ │ │ ├── CppFunction.h │ │ │ ├── Module.h │ │ │ ├── Module_Add_Property.h │ │ │ ├── Module_Field.h │ │ │ ├── Module_Property.h │ │ │ ├── class.h │ │ │ ├── class_Base.h │ │ │ └── get_return_type.h │ │ ├── platform │ │ │ ├── compiler.h │ │ │ └── solaris.h │ │ ├── print.h │ │ ├── protection │ │ │ ├── Armor.h │ │ │ ├── Shelter.h │ │ │ ├── Shield.h │ │ │ └── protection.h │ │ ├── proxy │ │ │ ├── AttributeProxy.h │ │ │ ├── Binding.h │ │ │ ├── DottedPairProxy.h │ │ │ ├── FieldProxy.h │ │ │ ├── GenericProxy.h │ │ │ ├── NamesProxy.h │ │ │ ├── ProtectedProxy.h │ │ │ ├── RObjectMethods.h │ │ │ ├── SlotProxy.h │ │ │ ├── TagProxy.h │ │ │ └── proxy.h │ │ ├── r │ │ │ ├── compat.h │ │ │ └── headers.h │ │ ├── r_cast.h │ │ ├── routines.h │ │ ├── sprintf.h │ │ ├── stats │ │ │ ├── beta.h │ │ │ ├── binom.h │ │ │ ├── cauchy.h │ │ │ ├── chisq.h │ │ │ ├── dpq │ │ │ │ ├── dpq.h │ │ │ │ └── macros.h │ │ │ ├── exp.h │ │ │ ├── f.h │ │ │ ├── gamma.h │ │ │ ├── geom.h │ │ │ ├── hyper.h │ │ │ ├── lnorm.h │ │ │ ├── logis.h │ │ │ ├── nbeta.h │ │ │ ├── nbinom.h │ │ │ ├── nbinom_mu.h │ │ │ ├── nchisq.h │ │ │ ├── nf.h │ │ │ ├── norm.h │ │ │ ├── nt.h │ │ │ ├── pois.h │ │ │ ├── random │ │ │ │ ├── random.h │ │ │ │ ├── rbeta.h │ │ │ │ ├── rbinom.h │ │ │ │ ├── rcauchy.h │ │ │ │ ├── rchisq.h │ │ │ │ ├── rexp.h │ │ │ │ ├── rf.h │ │ │ │ ├── rgamma.h │ │ │ │ ├── rgeom.h │ │ │ │ ├── rhyper.h │ │ │ │ ├── rlnorm.h │ │ │ │ ├── rlogis.h │ │ │ │ ├── rnbinom.h │ │ │ │ ├── rnbinom_mu.h │ │ │ │ ├── rnchisq.h │ │ │ │ ├── rnorm.h │ │ │ │ ├── rpois.h │ │ │ │ ├── rsignrank.h │ │ │ │ ├── rt.h │ │ │ │ ├── runif.h │ │ │ │ ├── rweibull.h │ │ │ │ └── rwilcox.h │ │ │ ├── stats.h │ │ │ ├── t.h │ │ │ ├── unif.h │ │ │ └── weibull.h │ │ ├── storage │ │ │ ├── NoProtectStorage.h │ │ │ ├── PreserveStorage.h │ │ │ └── storage.h │ │ ├── sugar │ │ │ ├── Range.h │ │ │ ├── block │ │ │ │ ├── SugarBlock_1.h │ │ │ │ ├── SugarBlock_2.h │ │ │ │ ├── SugarBlock_3.h │ │ │ │ ├── SugarMath.h │ │ │ │ ├── Vectorized_Math.h │ │ │ │ └── block.h │ │ │ ├── functions │ │ │ │ ├── Lazy.h │ │ │ │ ├── all.h │ │ │ │ ├── any.h │ │ │ │ ├── cbind.h │ │ │ │ ├── clamp.h │ │ │ │ ├── complex.h │ │ │ │ ├── cummax.h │ │ │ │ ├── cummin.h │ │ │ │ ├── cumprod.h │ │ │ │ ├── cumsum.h │ │ │ │ ├── diff.h │ │ │ │ ├── duplicated.h │ │ │ │ ├── functions.h │ │ │ │ ├── head.h │ │ │ │ ├── ifelse.h │ │ │ │ ├── is_finite.h │ │ │ │ ├── is_infinite.h │ │ │ │ ├── is_na.h │ │ │ │ ├── is_nan.h │ │ │ │ ├── lapply.h │ │ │ │ ├── mapply.h │ │ │ │ ├── mapply │ │ │ │ │ ├── mapply_2.h │ │ │ │ │ └── mapply_3.h │ │ │ │ ├── match.h │ │ │ │ ├── math.h │ │ │ │ ├── max.h │ │ │ │ ├── mean.h │ │ │ │ ├── median.h │ │ │ │ ├── min.h │ │ │ │ ├── na_omit.h │ │ │ │ ├── pmax.h │ │ │ │ ├── pmin.h │ │ │ │ ├── pow.h │ │ │ │ ├── range.h │ │ │ │ ├── rep.h │ │ │ │ ├── rep_each.h │ │ │ │ ├── rep_len.h │ │ │ │ ├── rev.h │ │ │ │ ├── rowSums.h │ │ │ │ ├── sample.h │ │ │ │ ├── sapply.h │ │ │ │ ├── sd.h │ │ │ │ ├── self_match.h │ │ │ │ ├── seq_along.h │ │ │ │ ├── setdiff.h │ │ │ │ ├── sign.h │ │ │ │ ├── strings │ │ │ │ │ ├── collapse.h │ │ │ │ │ ├── strings.h │ │ │ │ │ └── trimws.h │ │ │ │ ├── sum.h │ │ │ │ ├── table.h │ │ │ │ ├── tail.h │ │ │ │ ├── unique.h │ │ │ │ ├── var.h │ │ │ │ ├── which_max.h │ │ │ │ └── which_min.h │ │ │ ├── logical │ │ │ │ ├── SingleLogicalResult.h │ │ │ │ ├── and.h │ │ │ │ ├── can_have_na.h │ │ │ │ ├── is.h │ │ │ │ ├── logical.h │ │ │ │ ├── not.h │ │ │ │ └── or.h │ │ │ ├── matrix │ │ │ │ ├── as_vector.h │ │ │ │ ├── col.h │ │ │ │ ├── diag.h │ │ │ │ ├── lower_tri.h │ │ │ │ ├── matrix_functions.h │ │ │ │ ├── outer.h │ │ │ │ ├── row.h │ │ │ │ ├── tools.h │ │ │ │ └── upper_tri.h │ │ │ ├── nona │ │ │ │ └── nona.h │ │ │ ├── operators │ │ │ │ ├── Comparator.h │ │ │ │ ├── Comparator_With_One_Value.h │ │ │ │ ├── divides.h │ │ │ │ ├── logical_operators__Vector__Vector.h │ │ │ │ ├── logical_operators__Vector__primitive.h │ │ │ │ ├── minus.h │ │ │ │ ├── not.h │ │ │ │ ├── operators.h │ │ │ │ ├── plus.h │ │ │ │ ├── r_binary_op.h │ │ │ │ ├── times.h │ │ │ │ └── unary_minus.h │ │ │ ├── sets.h │ │ │ ├── sugar.h │ │ │ ├── sugar_forward.h │ │ │ ├── tools │ │ │ │ └── iterator.h │ │ │ └── undoRmath.h │ │ ├── traits │ │ │ ├── char_type.h │ │ │ ├── enable_if.h │ │ │ ├── expands_to_logical.h │ │ │ ├── get_na.h │ │ │ ├── has_iterator.h │ │ │ ├── has_na.h │ │ │ ├── if_.h │ │ │ ├── index_sequence.h │ │ │ ├── init_type.h │ │ │ ├── integral_constant.h │ │ │ ├── is_arithmetic.h │ │ │ ├── is_bool.h │ │ │ ├── is_const.h │ │ │ ├── is_convertible.h │ │ │ ├── is_eigen_base.h │ │ │ ├── is_finite.h │ │ │ ├── is_infinite.h │ │ │ ├── is_module_object.h │ │ │ ├── is_na.h │ │ │ ├── is_nan.h │ │ │ ├── is_pointer.h │ │ │ ├── is_primitive.h │ │ │ ├── is_reference.h │ │ │ ├── is_sugar_expression.h │ │ │ ├── is_trivial.h │ │ │ ├── is_wide_string.h │ │ │ ├── longlong.h │ │ │ ├── matrix_interface.h │ │ │ ├── module_wrap_traits.h │ │ │ ├── named_object.h │ │ │ ├── num2type.h │ │ │ ├── one_type.h │ │ │ ├── r_sexptype_traits.h │ │ │ ├── r_type_traits.h │ │ │ ├── remove_const.h │ │ │ ├── remove_const_and_reference.h │ │ │ ├── remove_reference.h │ │ │ ├── result_of.h │ │ │ ├── same_type.h │ │ │ ├── storage_type.h │ │ │ ├── traits.h │ │ │ ├── un_pointer.h │ │ │ └── wrap_type_traits.h │ │ ├── unwindProtect.h │ │ ├── utils │ │ │ ├── tinyformat.h │ │ │ └── tinyformat │ │ │ │ └── tinyformat.h │ │ └── vector │ │ │ ├── 00_forward_Vector.h │ │ │ ├── 00_forward_proxy.h │ │ │ ├── ChildVector.h │ │ │ ├── DimNameProxy.h │ │ │ ├── LazyVector.h │ │ │ ├── ListOf.h │ │ │ ├── Matrix.h │ │ │ ├── MatrixBase.h │ │ │ ├── MatrixColumn.h │ │ │ ├── MatrixRow.h │ │ │ ├── RangeIndexer.h │ │ │ ├── SubMatrix.h │ │ │ ├── Subsetter.h │ │ │ ├── Vector.h │ │ │ ├── VectorBase.h │ │ │ ├── const_generic_proxy.h │ │ │ ├── const_string_proxy.h │ │ │ ├── converter.h │ │ │ ├── generic_proxy.h │ │ │ ├── instantiation.h │ │ │ ├── no_init.h │ │ │ ├── proxy.h │ │ │ ├── string_proxy.h │ │ │ ├── swap.h │ │ │ ├── traits.h │ │ │ └── vector_from_string.h │ ├── RcppCommon.h │ └── doxygen │ │ └── Examples.h ├── prompt │ └── module.Rd ├── skeleton │ ├── Num.cpp │ ├── Rcpp_modules_examples.Rd │ ├── manual-page-stub.Rd │ ├── rcpp_hello_world.R │ ├── rcpp_hello_world.Rd │ ├── rcpp_hello_world.cpp │ ├── rcpp_hello_world.h │ ├── rcpp_hello_world_attributes.cpp │ ├── rcpp_module.cpp │ ├── stdVector.cpp │ └── zzz.R └── tinytest │ ├── bin │ ├── amd64 │ │ └── r-cran-testrcpppackage_0.1.0-1_amd64.deb │ └── i386 │ │ └── r-cran-testrcpppackage_0.1.0-1_i386.deb │ ├── cpp │ ├── DataFrame.cpp │ ├── Environment.cpp │ ├── Exceptions_nocall.cpp │ ├── Function.cpp │ ├── InternalFunction.cpp │ ├── InternalFunctionCPP11.cpp │ ├── ListOf.cpp │ ├── Matrix.cpp │ ├── Module.cpp │ ├── RObject.cpp │ ├── Reference.cpp │ ├── S4.cpp │ ├── String.cpp │ ├── Subset.cpp │ ├── Vector.cpp │ ├── VectorOld.cpp │ ├── XPtr.cpp │ ├── algorithm.cpp │ ├── as.cpp │ ├── attributes.cpp │ ├── attributes.hpp │ ├── coerce.cpp │ ├── dates.cpp │ ├── dispatch.cpp │ ├── embeddedR.cpp │ ├── embeddedR2.cpp │ ├── exceptions.cpp │ ├── language.cpp │ ├── misc.cpp │ ├── modref.cpp │ ├── na.cpp │ ├── rcppversion.cpp │ ├── rmath.cpp │ ├── stack.cpp │ ├── stats.cpp │ ├── sugar.cpp │ ├── support.cpp │ ├── table.cpp │ ├── wrap.cpp │ └── wstring.cpp │ ├── src │ ├── r-cran-testrcpppackage_0.1.0-1.diff.gz │ ├── r-cran-testrcpppackage_0.1.0-1.dsc │ ├── r-cran-testrcpppackage_0.1.0-1_amd64.changes │ ├── r-cran-testrcpppackage_0.1.0-1_amd64.deb │ ├── r-cran-testrcpppackage_0.1.0-1_i386.changes │ └── r-cran-testrcpppackage_0.1.0-1_i386.deb │ ├── testRcppAttributePackage │ ├── DESCRIPTION │ ├── NAMESPACE │ └── src │ │ └── rcpp_test.cpp │ ├── testRcppClass │ ├── DESCRIPTION │ ├── NAMESPACE │ ├── R │ │ ├── load.R │ │ └── rcpp_hello_world.R │ ├── man │ │ ├── Rcpp_class_examples.Rd │ │ ├── rcpp_hello_world.Rd │ │ └── testRcppClass-package.Rd │ ├── src │ │ ├── Num.cpp │ │ ├── init.c │ │ ├── rcpp_hello_world.cpp │ │ ├── rcpp_hello_world.h │ │ ├── rcpp_module.cpp │ │ └── stdVector.cpp │ └── tests │ │ └── classes.R │ ├── testRcppInterfaceExporter │ ├── DESCRIPTION │ ├── NAMESPACE │ ├── R │ │ ├── RcppExports.R │ │ └── exporter.R │ ├── inst │ │ └── include │ │ │ ├── testRcppInterfaceExporter.h │ │ │ └── testRcppInterfaceExporter_RcppExports.h │ └── src │ │ ├── RcppExports.cpp │ │ ├── exporter.cpp │ │ └── unwound.h │ ├── testRcppInterfaceUser │ ├── DESCRIPTION │ ├── NAMESPACE │ ├── R │ │ └── user.R │ ├── src │ │ ├── config.h │ │ ├── unwound.h │ │ └── user.cpp │ └── tests │ │ └── tests.R │ ├── testRcppModule │ ├── DESCRIPTION │ ├── NAMESPACE │ ├── R │ │ ├── rcpp_hello_world.R │ │ └── zzz.R │ ├── man │ │ ├── Rcpp_modules_examples.Rd │ │ ├── rcpp_hello_world.Rd │ │ └── testRcppModule-package.Rd │ ├── src │ │ ├── Num.cpp │ │ ├── init.c │ │ ├── rcpp_hello_world.cpp │ │ ├── rcpp_hello_world.h │ │ ├── rcpp_module.cpp │ │ └── stdVector.cpp │ └── tests │ │ └── modules.R │ ├── testRcppPackage │ ├── DESCRIPTION │ ├── NAMESPACE │ ├── R │ │ └── rcpp_hello_world.R │ ├── debian │ │ ├── changelog │ │ ├── compat │ │ ├── control │ │ ├── copyright │ │ ├── rules │ │ └── source │ │ │ └── format │ ├── man │ │ └── testRcppPackage-package.Rd │ └── src │ │ ├── rcpp_hello_world.cpp │ │ └── rcpp_hello_world.h │ ├── test_algorithm.R │ ├── test_as.R │ ├── test_attribute_package.R │ ├── test_attributes.R │ ├── test_binary_package.R │ ├── test_client_package.R │ ├── test_coerce.R │ ├── test_dataframe.R │ ├── test_date.R │ ├── test_dispatch.R │ ├── test_embedded_r.R │ ├── test_environments.R │ ├── test_exceptions.R │ ├── test_exceptions_nocall.R │ ├── test_expose_class.R │ ├── test_function.R │ ├── test_global_rostream.R │ ├── test_interface.R │ ├── test_internal_function.R │ ├── test_internal_function_cpp11.R │ ├── test_language.R │ ├── test_listof.R │ ├── test_matrix.R │ ├── test_misc.R │ ├── test_modref.R │ ├── test_module.R │ ├── test_module_client_package.R │ ├── test_na.R │ ├── test_packageversion.R │ ├── test_quickanddirty.R │ ├── test_rcpp_package_skeleton.R │ ├── test_reference.R │ ├── test_rmath.R │ ├── test_robject.R │ ├── test_s4.R │ ├── test_stack.R │ ├── test_stats.R │ ├── test_string.R │ ├── test_subset.R │ ├── test_sugar.R │ ├── test_sugar_var.R │ ├── test_support.R │ ├── test_system.R │ ├── test_table.R │ ├── test_vector.R │ ├── test_vector_old.R │ ├── test_wrap.R │ ├── test_wstring.R │ └── test_xptr.R ├── local ├── README └── THANKS ├── man ├── CppClass-class.Rd ├── CppConstructor-class.Rd ├── CppField-class.Rd ├── CppFunction-class.Rd ├── CppObject-class.Rd ├── CppOverloadedMethods-class.Rd ├── DollarNames-methods.Rd ├── Module-class.Rd ├── Module.Rd ├── Rcpp-deprecated.Rd ├── Rcpp-internal.Rd ├── Rcpp-package.Rd ├── Rcpp.package.skeleton.Rd ├── Rcpp.plugin.maker.Rd ├── RcppLdFlags.Rd ├── RcppUnitTests.Rd ├── compileAttributes.Rd ├── compilerCheck.Rd ├── cppFunction.Rd ├── demangle.Rd ├── dependsAttribute.Rd ├── evalCpp.Rd ├── exportAttribute.Rd ├── exposeClass.Rd ├── formals.Rd ├── getRcppVersion.Rd ├── interfacesAttribute.Rd ├── loadModule.Rd ├── loadRcppModules-deprecated.Rd ├── pluginsAttribute.Rd ├── populate.Rd ├── registerPlugin.Rd ├── setRcppClass.Rd └── sourceCpp.Rd ├── src ├── Makevars ├── Makevars.win ├── api.cpp ├── attributes.cpp ├── barrier.cpp ├── date.cpp ├── internal.h ├── module.cpp └── rcpp_init.cpp ├── tests └── tinytest.R └── vignettes ├── .gitignore ├── Makefile ├── Rcpp-FAQ.Rnw ├── Rcpp-FAQ.pdf ├── Rcpp-attributes.Rnw ├── Rcpp-attributes.pdf ├── Rcpp-extending.Rnw ├── Rcpp-extending.pdf ├── Rcpp-introduction.Rnw ├── Rcpp-introduction.pdf ├── Rcpp-jss-2011.Rnw ├── Rcpp-jss-2011.pdf ├── Rcpp-libraries.Rnw ├── Rcpp-libraries.pdf ├── Rcpp-modules.Rnw ├── Rcpp-modules.pdf ├── Rcpp-package.Rnw ├── Rcpp-package.pdf ├── Rcpp-quickref.Rnw ├── Rcpp-quickref.pdf ├── Rcpp-sugar.Rnw ├── Rcpp-sugar.pdf ├── pdf ├── Rcpp-FAQ.pdf ├── Rcpp-attributes.pdf ├── Rcpp-extending.pdf ├── Rcpp-introduction.pdf ├── Rcpp-jss-2011.pdf ├── Rcpp-libraries.pdf ├── Rcpp-modules.pdf ├── Rcpp-package.pdf ├── Rcpp-quickref.pdf └── Rcpp-sugar.pdf └── rmd ├── .install_extras ├── Makefile ├── Rcpp-FAQ.Rmd ├── Rcpp-attributes.Rmd ├── Rcpp-extending.Rmd ├── Rcpp-introduction.Rmd ├── Rcpp-jss-2011.Rnw ├── Rcpp-libraries.Rmd ├── Rcpp-modules.Rmd ├── Rcpp-package.Rmd ├── Rcpp-quickref.Rmd ├── Rcpp-sugar.Rmd ├── Rcpp.bib ├── figures ├── bootstrap.pdf ├── dist_graphs-1.pdf ├── function_annotation_cpp.png └── samplePkg-files-light-bg.png ├── getCurrentVersionsOfCitedPackages.R ├── jss.bst └── notyet ├── Rcpp-api.Rnw └── Rcpp-unitTests.Rnw /.Rbuildignore: -------------------------------------------------------------------------------- 1 | debian 2 | inst/doc/html 3 | inst/doc/latex 4 | inst/doc/man 5 | inst/doc/jss.bst 6 | vignettes/jss.bst 7 | ^.*\.Rproj$ 8 | ^\.Rproj\.user$ 9 | vignettes/notyet 10 | doxyfile 11 | \.travis\.yml 12 | \.dir-locals\.el 13 | \.clang_format 14 | vignettes/getCurrentVersionsOfCitedPackages.R 15 | ^Contributing.md$ 16 | ^\.codecov\.yml$ 17 | inst/include/Rcpp.h.new 18 | inst/include/Rcpp.h.old 19 | LICENSE 20 | .*\.tar\.gz$ 21 | \.editorconfig 22 | docker 23 | ^GPATH 24 | ^GRTAGS 25 | ^GTAGS 26 | ^local 27 | vignettes/Makefile 28 | vignettes/rmd 29 | \.github 30 | ^issue.*\.md 31 | ^note.*\.md 32 | \.vscode 33 | -------------------------------------------------------------------------------- /.Rinstignore: -------------------------------------------------------------------------------- 1 | inst/doc/Makefile 2 | inst/doc/jss.bst 3 | inst/doc/RJournal.sty 4 | inst/unitTests/src 5 | -------------------------------------------------------------------------------- /.codecov.yml: -------------------------------------------------------------------------------- 1 | comment: false 2 | coverage: 3 | status: 4 | project: 5 | default: 6 | target: 70% # the (on purpose low) required coverage value 7 | threshold: 2% # the permitted delta in hitting the target 8 | patch: 9 | default: 10 | target: 0% # the (on purpose low) required coverage value 11 | 12 | # layout: "header, diff, tree, changes" 13 | # behavior: default 14 | # require_changes: false # if true: only post the comment if coverage changes 15 | # branches: null 16 | # flags: null 17 | # paths: null 18 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: http://EditorConfig.org 2 | 3 | # top-most EditorConfig file 4 | root = true 5 | 6 | # Unix-style newlines with a newline ending every file 7 | [*] 8 | end_of_line = lf 9 | insert_final_newline = true 10 | trim_trailing_whitespace = true 11 | 12 | # Matches multiple files with brace expansion notation 13 | # 4 space indentation 14 | [*.{c,cpp,h,hpp,R,r}] 15 | indent_style = space 16 | indent_size = 4 17 | 18 | # Tab indentation (no size specified) 19 | [Makefile] 20 | indent_style = tab 21 | 22 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | ChangeLog merge=union 2 | inst/NEWS.Rd merge=union 3 | 4 | # gitattribute override for linguist 5 | *.h linguist-language=C++ 6 | -------------------------------------------------------------------------------- /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | 2 | ### Contributing to Rcpp 3 | 4 | Please see the file [Contributing](https://github.com/RcppCore/Rcpp/blob/master/Contributing.md) for details on 5 | 6 | - how to report an issue: a [Minimally Complete (and) Verifiable Example (MCVE)](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) helps a lot; 7 | - how to submit a pull request: post an issue first, get consensus about _what_ and _how_; 8 | - how to follow our (informal) coding style: simply do as other files do and do not invent a new style; 9 | - how to be nice and add [ChangeLog](https://github.com/RcppCore/Rcpp/blob/master/ChangeLog) and [NEWS.Rd](https://github.com/RcppCore/Rcpp/blob/master/ChangeLog). 10 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: eddelbuettel 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | ### Reporting an Issue 3 | 4 | Make use of the *Preview* tab just above! 5 | 6 | #### Before filing an issue with Rcpp, please ensure that you 7 | 8 | - searched the mailing list archives for the [rcpp-devel](https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel) list for the question you want to ask about; you can do this at at Google with the `site:` qualifier as in this simple example: `site:lists.r-forge.r-project.org rcpp-devel how do I declare a const vector`; 9 | 10 | - searched the [StackOverflow](https://stackoverflow.com/) `[rcpp]` tag _e.g._ via `[rcpp] how do I sample a vector`; 11 | 12 | - searched existing [GitHub issues](https://github.com/RcppCore/Rcpp/issues) which can be searched among open and closed ones; 13 | 14 | - read the [Contributing](https://github.com/RcppCore/Rcpp/blob/master/Contributing.md) page for details on preferred reporting and style; 15 | 16 | If you have the above, remove the text above and provide a [Minimally Complete and Verifiable Example (MCVE)](https://stackoverflow.com/help/minimal-reproducible-example), the output of `sessionInfo()` plus relevant information about the C++ compiler. All this takes a little bit of effort---but greatly increases your chances of getting an applicable and helpful follow-up in return. 17 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | ### Pull Request Template for Rcpp 3 | 4 | Please explain the changes you want to apply to Rcpp, preferably in an issue ticket **before** you create a pull request. See the file [Contributing](https://github.com/RcppCore/Rcpp/blob/master/Contributing.md) and the other templates for details. 5 | 6 | #### Checklist 7 | 8 | - [ ] Code compiles correctly 9 | - [ ] `R CMD check` still passes all tests 10 | - [ ] Preferably, new tests were added which fail without the change 11 | - [ ] Document the changes by file in [ChangeLog](https://github.com/RcppCore/Rcpp/blob/master/ChangeLog) 12 | -------------------------------------------------------------------------------- /.github/workflows/linuxarm.yaml: -------------------------------------------------------------------------------- 1 | # Run CI for R using https://eddelbuettel.github.io/r-ci/ 2 | 3 | name: linuxarm 4 | 5 | on: 6 | #push: 7 | #pull_request: 8 | workflow_dispatch: 9 | 10 | env: 11 | _R_CHECK_FORCE_SUGGESTS_: "false" 12 | 13 | jobs: 14 | ci: 15 | strategy: 16 | matrix: 17 | include: 18 | #- {os: ubuntu-latest} 19 | - {os: ubuntu-24.04-arm} 20 | 21 | runs-on: ${{ matrix.os }} 22 | 23 | steps: 24 | - name: Checkout 25 | uses: actions/checkout@v4 26 | 27 | - name: Setup 28 | uses: eddelbuettel/github-actions/r-ci@master 29 | 30 | - name: Dependencies 31 | run: ./run.sh install_deps 32 | 33 | - name: Test 34 | run: ./run.sh run_tests 35 | 36 | #- name: Coverage 37 | # if: ${{ matrix.os == 'ubuntu-latest' }} 38 | # run: ./run.sh coverage 39 | -------------------------------------------------------------------------------- /.github/workflows/macos.yaml: -------------------------------------------------------------------------------- 1 | # Run CI for R using https://eddelbuettel.github.io/r-ci/ 2 | 3 | name: macos 4 | 5 | on: 6 | push: 7 | pull_request: 8 | 9 | env: 10 | _R_CHECK_FORCE_SUGGESTS_: "false" 11 | 12 | jobs: 13 | ci: 14 | strategy: 15 | matrix: 16 | include: 17 | - {os: macos-latest} 18 | - {os: macos-13} 19 | #- {os: ubuntu-latest} 20 | #- {os: ubuntu-24.04-arm} 21 | 22 | runs-on: ${{ matrix.os }} 23 | 24 | steps: 25 | - name: Checkout 26 | uses: actions/checkout@v4 27 | 28 | - name: Setup 29 | uses: eddelbuettel/github-actions/r-ci@master 30 | 31 | - name: Dependencies 32 | run: ./run.sh install_deps 33 | 34 | - name: Test 35 | run: ./run.sh run_tests 36 | 37 | #- name: Coverage 38 | # if: ${{ matrix.os == 'ubuntu-latest' }} 39 | # run: ./run.sh coverage 40 | -------------------------------------------------------------------------------- /.github/workflows/stale.yaml: -------------------------------------------------------------------------------- 1 | # Mark stale issues and pull requests 2 | # cf https://github.com/actions/stale 3 | 4 | name: stale 5 | 6 | on: 7 | schedule: 8 | - cron: "11 1 * * 6" 9 | 10 | jobs: 11 | stale: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/stale@v8 15 | with: 16 | repo-token: ${{ secrets.GITHUB_TOKEN }} 17 | stale-issue-label: 'no-issue-activity' 18 | stale-pr-label: 'no-pr-activity' 19 | days-before-stale: 365 20 | days-before-close: 31 21 | stale-issue-message: > 22 | This issue is stale (365 days without activity) and will be closed 23 | in 31 days unless new activity is seen. Please feel free to re-open 24 | it is still a concern, possibly with additional data. 25 | stale-pr-message: > 26 | This pull request is is stale (365 days without activity) and will 27 | be closed in 31 days unless new activity is seen. Please feel free 28 | to open a new issue to discuss a fresh approach. 29 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | inst/lib 2 | .Rproj.user 3 | src/*.o 4 | src/*.so 5 | src/*.dll 6 | src/symbols.rds 7 | .Rhistory 8 | .RData 9 | .DS_Store 10 | 11 | ## QtCreator 12 | Rcpp.pro 13 | Rcpp.pro.user 14 | *.autosave 15 | .#* 16 | 17 | *.tar.gz 18 | 19 | vignettes/*_cache 20 | 21 | ## GNU global 22 | GPATH 23 | GRTAGS 24 | GTAGS 25 | 26 | ## 27 | local/ 28 | 29 | ## docker helpers 30 | docker/*sh 31 | docker/*/*.sh 32 | 33 | ## Emacs 34 | *~ 35 | 36 | ## VSCode 37 | .vscode/ 38 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | useDynLib(Rcpp, .registration = TRUE) 2 | 3 | import(methods) 4 | importFrom(utils, capture.output, assignInNamespace, .DollarNames, prompt, 5 | packageDescription, package.skeleton, glob2rx) 6 | 7 | exportClasses(Module, "C++Field", 8 | "C++OverloadedMethods", 9 | "C++Constructor", 10 | "C++Class", "C++Object", "C++Function") 11 | 12 | S3method(.DollarNames, "C++Object") 13 | S3method(.DollarNames, "Module") 14 | exportMethods(prompt, show, .DollarNames, initialize, "formals<-") 15 | 16 | export(Module, 17 | Rcpp.package.skeleton, 18 | populate, 19 | loadRcppModules, # deprecated since Rcpp 0.12.5 released May 2016 20 | setRcppClass, 21 | loadRcppClass, 22 | loadModule, 23 | cppFunction, 24 | exposeClass, 25 | evalCpp, 26 | sourceCpp, 27 | compileAttributes, 28 | registerPlugin, 29 | RcppLdFlags, # deprecated since Rcpp 0.12.19 released Sep 2018 30 | LdFlags, # deprecated since Rcpp 0.12.19 released Sep 2018 31 | demangle, 32 | sizeof, 33 | cpp_object_initializer, 34 | cpp_object_dummy, 35 | Rcpp.plugin.maker, 36 | getRcppVersion 37 | ) 38 | S3method(print, bytes) 39 | S3method(format, Rcpp_stack_trace) 40 | S3method(str, Rcpp_stack_trace) 41 | S3method(print, Rcpp_stack_trace) 42 | exportClass(RcppClass) 43 | -------------------------------------------------------------------------------- /R/bib.R: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2010 - 2017 Dirk Eddelbuettel and Romain Francois 2 | # 3 | # This file is part of Rcpp. 4 | # 5 | # Rcpp is free software: you can redistribute it and/or modify it 6 | # under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 2 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # Rcpp is distributed in the hope that it will be useful, but 11 | # WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with Rcpp. If not, see . 17 | 18 | bib <- function() { 19 | sub("\\.bib$", "", system.file("bib", "Rcpp.bib", package = "Rcpp")) 20 | } 21 | -------------------------------------------------------------------------------- /R/populate.R: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2010 - 2011 John Chambers, Dirk Eddelbuettel and Romain Francois 2 | # 3 | # This file is part of Rcpp. 4 | # 5 | # Rcpp is free software: you can redistribute it and/or modify it 6 | # under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 2 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # Rcpp is distributed in the hope that it will be useful, but 11 | # WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with Rcpp. If not, see . 17 | 18 | populate <- function( module, env ){ 19 | 20 | # make sure the module is loaded 21 | module <- Module( module, mustStart = TRUE ) 22 | 23 | storage <- get( "storage", as.environment(module ) ) 24 | symbols <- ls( storage ) 25 | 26 | is_ns <- isNamespace( env ) 27 | for( x in symbols ){ 28 | forceAssignInNamespace( x, storage[[x]], env ) 29 | } 30 | } 31 | 32 | -------------------------------------------------------------------------------- /R/zzz.R: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2009 - 2016 Dirk Eddelbuettel and Romain Francois 2 | # 3 | # This file is part of Rcpp. 4 | # 5 | # Rcpp is free software: you can redistribute it and/or modify it 6 | # under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 2 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # Rcpp is distributed in the hope that it will be useful, but 11 | # WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with Rcpp. If not, see . 17 | 18 | .dummyInstancePointer <- new.env() # just something permanent 19 | 20 | .classes_map <- new.env() 21 | 22 | .onLoad <- function(libname, pkgname){ 23 | new_dummyObject(.dummyInstancePointer) # nocov 24 | } 25 | 26 | 27 | -------------------------------------------------------------------------------- /Rcpp.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 4 10 | Encoding: UTF-8 11 | 12 | RnwWeave: Sweave 13 | LaTeX: pdfLaTeX 14 | 15 | AutoAppendNewline: Yes 16 | StripTrailingWhitespace: Yes 17 | 18 | BuildType: Package 19 | PackageInstallArgs: --no-multiarch --with-keep.source 20 | -------------------------------------------------------------------------------- /docker/ci-3.4/Dockerfile: -------------------------------------------------------------------------------- 1 | ## Emacs, make this -*- mode: sh; -*- 2 | 3 | FROM r-base:3.4.4 4 | 5 | LABEL org.label-schema.license="GPL-2.0" \ 6 | org.label-schema.vcs-url="https://github.com/RcppCore/Rcpp" \ 7 | maintainer="Dirk Eddelbuettel " 8 | 9 | RUN apt-get update \ 10 | && apt-get install -y --no-install-recommends \ 11 | git \ 12 | && install.r inline pkgKitten rbenchmark tinytest 13 | 14 | ENV _R_CHECK_FORCE_SUGGESTS_ FALSE 15 | ENV _R_CHECK_TESTS_NLINES_ 0 16 | ENV RunAllRcppTests yes 17 | 18 | CMD ["bash"] 19 | -------------------------------------------------------------------------------- /docker/ci-3.5/Dockerfile: -------------------------------------------------------------------------------- 1 | ## Emacs, make this -*- mode: sh; -*- 2 | 3 | FROM r-base:3.5.3 4 | 5 | LABEL org.label-schema.license="GPL-2.0" \ 6 | org.label-schema.vcs-url="https://github.com/RcppCore/Rcpp" \ 7 | maintainer="Dirk Eddelbuettel " 8 | 9 | RUN apt-get update \ 10 | && apt-get install -y --no-install-recommends git \ 11 | && install.r inline pkgKitten rbenchmark tinytest 12 | 13 | ENV _R_CHECK_FORCE_SUGGESTS_ FALSE 14 | ENV _R_CHECK_TESTS_NLINES_ 0 15 | ENV RunAllRcppTests yes 16 | 17 | CMD ["bash"] 18 | -------------------------------------------------------------------------------- /docker/ci-3.6/Dockerfile: -------------------------------------------------------------------------------- 1 | ## Emacs, make this -*- mode: sh; -*- 2 | 3 | FROM r-base:3.6.3 4 | 5 | LABEL org.label-schema.license="GPL-2.0" \ 6 | org.label-schema.vcs-url="https://github.com/RcppCore/Rcpp" \ 7 | maintainer="Dirk Eddelbuettel " 8 | 9 | RUN apt-get update \ 10 | && apt-get install -y --no-install-recommends git \ 11 | && install.r inline pkgKitten rbenchmark tinytest 12 | 13 | ENV _R_CHECK_FORCE_SUGGESTS_ FALSE 14 | ENV _R_CHECK_TESTS_NLINES_ 0 15 | ENV RunAllRcppTests yes 16 | 17 | CMD ["bash"] 18 | -------------------------------------------------------------------------------- /docker/ci-4.0/Dockerfile: -------------------------------------------------------------------------------- 1 | ## Emacs, make this -*- mode: sh; -*- 2 | 3 | FROM r-base:4.0.5 4 | 5 | LABEL org.label-schema.license="GPL-2.0" \ 6 | org.label-schema.vcs-url="https://github.com/RcppCore/Rcpp" \ 7 | maintainer="Dirk Eddelbuettel " 8 | 9 | RUN apt-get update \ 10 | && apt-get install -y --no-install-recommends git \ 11 | && install.r inline pkgKitten rbenchmark tinytest 12 | 13 | ENV _R_CHECK_FORCE_SUGGESTS_ FALSE 14 | ENV _R_CHECK_TESTS_NLINES_ 0 15 | ENV RunAllRcppTests yes 16 | 17 | CMD ["bash"] 18 | -------------------------------------------------------------------------------- /docker/ci-4.1/Dockerfile: -------------------------------------------------------------------------------- 1 | ## Emacs, make this -*- mode: sh; -*- 2 | 3 | FROM r-base:4.1.3 4 | 5 | LABEL org.label-schema.license="GPL-2.0" \ 6 | org.label-schema.vcs-url="https://github.com/RcppCore/Rcpp" \ 7 | maintainer="Dirk Eddelbuettel " 8 | 9 | RUN apt-get update \ 10 | && apt-get install -y --no-install-recommends git \ 11 | && install.r inline pkgKitten rbenchmark tinytest 12 | 13 | ENV _R_CHECK_FORCE_SUGGESTS_ FALSE 14 | ENV _R_CHECK_TESTS_NLINES_ 0 15 | ENV RunAllRcppTests yes 16 | 17 | CMD ["bash"] 18 | -------------------------------------------------------------------------------- /docker/ci-4.2/Dockerfile: -------------------------------------------------------------------------------- 1 | ## Emacs, make this -*- mode: sh; -*- 2 | 3 | FROM r-base:4.2.3 4 | 5 | LABEL org.label-schema.license="GPL-2.0" \ 6 | org.label-schema.vcs-url="https://github.com/RcppCore/Rcpp" \ 7 | maintainer="Dirk Eddelbuettel " 8 | 9 | RUN apt-get update \ 10 | && apt-get install -y --no-install-recommends git \ 11 | && install.r inline pkgKitten rbenchmark tinytest 12 | 13 | ENV _R_CHECK_FORCE_SUGGESTS_ FALSE 14 | ENV _R_CHECK_TESTS_NLINES_ 0 15 | ENV RunAllRcppTests yes 16 | 17 | CMD ["bash"] 18 | -------------------------------------------------------------------------------- /docker/ci-4.3/Dockerfile: -------------------------------------------------------------------------------- 1 | ## Emacs, make this -*- mode: sh; -*- 2 | 3 | FROM r-base:4.3.3 4 | 5 | LABEL org.label-schema.license="GPL-2.0" \ 6 | org.label-schema.vcs-url="https://github.com/RcppCore/Rcpp" \ 7 | maintainer="Dirk Eddelbuettel " 8 | 9 | RUN apt-get update \ 10 | && apt-get install -y --no-install-recommends git \ 11 | && install.r inline pkgKitten rbenchmark tinytest 12 | 13 | ENV _R_CHECK_FORCE_SUGGESTS_ FALSE 14 | ENV _R_CHECK_TESTS_NLINES_ 0 15 | ENV RunAllRcppTests yes 16 | 17 | CMD ["bash"] 18 | -------------------------------------------------------------------------------- /docker/ci-4.4/Dockerfile: -------------------------------------------------------------------------------- 1 | ## Emacs, make this -*- mode: sh; -*- 2 | 3 | FROM r-base:4.4.3 4 | 5 | LABEL org.label-schema.license="GPL-2.0" \ 6 | org.label-schema.vcs-url="https://github.com/RcppCore/Rcpp" \ 7 | maintainer="Dirk Eddelbuettel " 8 | 9 | RUN apt-get update \ 10 | && apt-get install -y --no-install-recommends git \ 11 | && install.r inline pkgKitten rbenchmark tinytest 12 | 13 | ENV _R_CHECK_FORCE_SUGGESTS_=FALSE 14 | ENV _R_CHECK_TESTS_NLINES_=0 15 | ENV RunAllRcppTests=yes 16 | 17 | CMD ["bash"] 18 | -------------------------------------------------------------------------------- /docker/ci-dev/Dockerfile: -------------------------------------------------------------------------------- 1 | ## Emacs, make this -*- mode: sh; -*- 2 | 3 | FROM rocker/drd 4 | 5 | LABEL org.label-schema.license="GPL-2.0" \ 6 | org.label-schema.vcs-url="https://github.com/RcppCore/Rcpp" \ 7 | maintainer="Dirk Eddelbuettel " 8 | 9 | RUN rm -f /etc/apt/sources.list.d/experimental.list \ 10 | && apt update -y \ 11 | && apt install -y --no-install-recommends git \ 12 | && RDscript -e 'install.packages(c("codetools", "inline", "pkgKitten", "rbenchmark", "tinytest"))' 13 | 14 | ENV _R_CHECK_FORCE_SUGGESTS_ FALSE 15 | ENV _R_CHECK_TESTS_NLINES_ 0 16 | ENV RunAllRcppTests yes 17 | 18 | CMD ["bash"] 19 | -------------------------------------------------------------------------------- /docker/ci/Dockerfile: -------------------------------------------------------------------------------- 1 | ## Emacs, make this -*- mode: sh; -*- 2 | 3 | FROM rocker/r2u:latest 4 | 5 | LABEL org.label-schema.license="GPL-2.0" \ 6 | org.label-schema.vcs-url="https://github.com/RcppCore/Rcpp" \ 7 | maintainer="Dirk Eddelbuettel " 8 | 9 | RUN apt-get update \ 10 | && apt-get install -y --no-install-recommends \ 11 | libcurl4-openssl-dev \ 12 | libssl-dev \ 13 | r-cran-covr \ 14 | r-cran-inline \ 15 | r-cran-pkgkitten \ 16 | r-cran-tinytest \ 17 | r-cran-xml2 \ 18 | git \ 19 | && install.r rbenchmark 20 | 21 | ENV _R_CHECK_FORCE_SUGGESTS_ FALSE 22 | ENV _R_CHECK_TESTS_NLINES_ 0 23 | ENV RunAllRcppTests yes 24 | 25 | CMD ["bash"] 26 | -------------------------------------------------------------------------------- /docker/plus/Dockerfile: -------------------------------------------------------------------------------- 1 | ## Emacs, make this -*- mode: sh; -*- 2 | 3 | FROM rcpp/run 4 | 5 | LABEL org.label-schema.license="GPL-2.0" \ 6 | org.label-schema.vcs-url="https://github.com/RcppCore/Rcpp" \ 7 | maintainer="Dirk Eddelbuettel " 8 | 9 | RUN apt-get update \ 10 | && apt-get install -y --no-install-recommends \ 11 | r-cran-bh \ 12 | r-cran-bit64 \ 13 | r-cran-curl \ 14 | r-cran-httr \ 15 | r-cran-knitr \ 16 | r-cran-lazyeval \ 17 | r-cran-microbenchmark \ 18 | r-cran-openssl \ 19 | r-cran-pinp \ 20 | r-cran-rcpparmadillo \ 21 | r-cran-rcppeigen \ 22 | r-cran-rcppgsl \ 23 | r-cran-rmarkdown \ 24 | r-cran-runit \ 25 | r-cran-withr 26 | 27 | CMD ["bash"] 28 | -------------------------------------------------------------------------------- /docker/run/Dockerfile: -------------------------------------------------------------------------------- 1 | ## Emacs, make this -*- mode: sh; -*- 2 | 3 | FROM rcpp/ci 4 | 5 | LABEL org.label-schema.license="GPL-2.0" \ 6 | org.label-schema.vcs-url="https://github.com/RcppCore/Rcpp" \ 7 | maintainer="Dirk Eddelbuettel " 8 | 9 | ## If on CRAN, install the latest version from CRAN 10 | RUN install.r Rcpp 11 | 12 | ## Alternatively, install from Github (after first installing remotes) 13 | #RUN install.r remotes && installGithub.r RcppCore/Rcpp 14 | 15 | CMD ["bash"] 16 | -------------------------------------------------------------------------------- /inst/examples/Attributes/Depends.cpp: -------------------------------------------------------------------------------- 1 | 2 | // [[Rcpp::depends(RcppArmadillo)]] 3 | 4 | #include 5 | 6 | using namespace Rcpp; 7 | 8 | // [[Rcpp::export]] 9 | List fastLm(NumericVector yr, NumericMatrix Xr) { 10 | 11 | int n = Xr.nrow(), k = Xr.ncol(); 12 | 13 | arma::mat X(Xr.begin(), n, k, false); // reuses memory and avoids extra copy 14 | arma::colvec y(yr.begin(), yr.size(), false); 15 | 16 | arma::colvec coef = arma::solve(X, y); // fit model y ~ X 17 | arma::colvec resid = y - X*coef; // residuals 18 | 19 | double sig2 = arma::as_scalar( arma::trans(resid)*resid/(n-k) ); 20 | // std.error of estimate 21 | arma::colvec stderrest = arma::sqrt( 22 | sig2 * arma::diagvec( arma::inv(arma::trans(X)*X)) ); 23 | 24 | return List::create(Named("coefficients") = coef, 25 | Named("stderr") = stderrest 26 | ); 27 | } 28 | 29 | -------------------------------------------------------------------------------- /inst/examples/Attributes/Export.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | using namespace Rcpp; 5 | 6 | // [[Rcpp::export]] 7 | int fibonacci(const int x) { 8 | 9 | if (x == 0) return(0); 10 | if (x == 1) return(1); 11 | 12 | return (fibonacci(x - 1)) + fibonacci(x - 2); 13 | } 14 | 15 | 16 | // [[Rcpp::export("convolveCpp")]] 17 | NumericVector convolve(NumericVector a, NumericVector b) { 18 | 19 | int na = a.size(), nb = b.size(); 20 | int nab = na + nb - 1; 21 | NumericVector xab(nab); 22 | 23 | for (int i = 0; i < na; i++) 24 | for (int j = 0; j < nb; j++) 25 | xab[i + j] += a[i] * b[j]; 26 | 27 | return xab; 28 | } 29 | 30 | 31 | // [[Rcpp::export]] 32 | List lapplyCpp(List input, Function f) { 33 | 34 | List output(input.size()); 35 | 36 | std::transform(input.begin(), input.end(), output.begin(), f); 37 | output.names() = input.names(); 38 | 39 | return output; 40 | } 41 | -------------------------------------------------------------------------------- /inst/examples/Attributes/sourceCpp.R: -------------------------------------------------------------------------------- 1 | 2 | library(Rcpp) 3 | 4 | sourceCpp("Export.cpp") 5 | fibonacci(5) 6 | 7 | 8 | sourceCpp("Depends.cpp") 9 | fastLm(c(1,2,3), matrix(3,3)) 10 | 11 | -------------------------------------------------------------------------------- /inst/examples/ConvolveBenchmarks/GNUmakefile: -------------------------------------------------------------------------------- 1 | 2 | ## comment this out if you need a different version of R, 3 | ## and set set R_HOME accordingly as an environment variable 4 | R_HOME := $(shell R RHOME) 5 | 6 | ## include headers and libraries for R 7 | RCPPFLAGS := $(shell $(R_HOME)/bin/R CMD config --cppflags) 8 | RLDFLAGS := $(shell $(R_HOME)/bin/R CMD config --ldflags) 9 | 10 | ## include headers and libraries for Rcpp interface classes 11 | RCPPINCL := $(shell echo 'Rcpp:::CxxFlags()' | $(R_HOME)/bin/R --vanilla --slave) 12 | RCPPLIBS := $(shell echo 'Rcpp:::LdFlags()' | $(R_HOME)/bin/R --vanilla --slave) 13 | 14 | c_sources := $(wildcard *.c) 15 | c_sharedlibs := $(patsubst %.c,%.o,$(c_sources)) 16 | 17 | cpp_sources := $(wildcard *.cpp) 18 | cpp_sharedlibs := $(patsubst %.cpp,%.o,$(cpp_sources)) 19 | 20 | all : $(c_sharedlibs) $(cpp_sharedlibs) 21 | 22 | %.o : %.c 23 | R CMD SHLIB $< 24 | 25 | %.o : %.cpp 26 | PKG_CPPFLAGS="$(RCPPFLAGS) $(RCPPINCL)" PKG_LIBS="$(RLDFLAGS) $(RCPPLIBS)" R CMD SHLIB $< 27 | 28 | run : $(c_sharedlibs) $(cpp_sharedlibs) 29 | Rscript exampleRCode.r 30 | -------------------------------------------------------------------------------- /inst/examples/ConvolveBenchmarks/buildAndRun.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | rm -f *.o *.so 4 | 5 | # build the shared library for the C variant 6 | R CMD SHLIB convolve2_c.c 7 | R CMD SHLIB convolve7_c.c 8 | 9 | # build the shared library for the C++ variant 10 | # we have to let R know where the Rcpp header and library are 11 | export PKG_CPPFLAGS=`Rscript -e "Rcpp:::CxxFlags()"` 12 | export PKG_LIBS=`Rscript -e "Rcpp:::LdFlags()"` 13 | R CMD SHLIB convolve3_cpp.cpp 14 | R CMD SHLIB convolve4_cpp.cpp 15 | R CMD SHLIB convolve5_cpp.cpp 16 | R CMD SHLIB convolve8_cpp.cpp 17 | R CMD SHLIB convolve9_cpp.cpp 18 | R CMD SHLIB convolve10_cpp.cpp 19 | R CMD SHLIB convolve11_cpp.cpp 20 | R CMD SHLIB convolve12_cpp.cpp 21 | R CMD SHLIB convolve14_cpp.cpp 22 | 23 | # call R so that we get an interactive session 24 | Rscript exampleRCode.r 25 | 26 | -------------------------------------------------------------------------------- /inst/examples/ConvolveBenchmarks/convolve10_cpp.cpp: -------------------------------------------------------------------------------- 1 | // -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*- 2 | 3 | // this version expands convolve8_cpp by making Vec mimic the structure of 4 | // NumericVector. It peforms well, so this is is not the structure of 5 | // NumericVector that is the problem. So what is it then ? 6 | // 7 | // could it be because NumericVector is in a different library than 8 | // this code, so that operator[] is not inlined ? 9 | // 10 | // clues: 11 | // - http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.faqs/ka3538.html 12 | 13 | #include 14 | 15 | #include "convolve10_cpp.h" 16 | 17 | RcppExport SEXP convolve10cpp(SEXP a, SEXP b){ 18 | Rcpp::NumericVector xa(a); 19 | Rcpp::NumericVector xb(b); 20 | int n_xa = xa.size() ; 21 | int n_xb = xb.size() ; 22 | int nab = n_xa + n_xb - 1; 23 | Rcpp::NumericVector xab(nab); 24 | 25 | Vec vab(xab.begin()), va(xa.begin()), vb(xb.begin()) ; 26 | 27 | for (int i = 0; i < n_xa; i++) 28 | for (int j = 0; j < n_xb; j++) 29 | vab[i + j] += va[i] * vb[j]; 30 | 31 | return xab ; 32 | } 33 | 34 | #include "loopmacro.h" 35 | LOOPMACRO_CPP(convolve10cpp) 36 | 37 | -------------------------------------------------------------------------------- /inst/examples/ConvolveBenchmarks/convolve10_cpp.h: -------------------------------------------------------------------------------- 1 | 2 | class Cache{ 3 | public: 4 | typedef double& proxy ; 5 | typedef double* iterator ; 6 | 7 | Cache( iterator data_) : data(data_){} 8 | 9 | inline proxy ref(int i){ return data[i] ; } 10 | inline proxy ref(int i) const { return data[i] ; } 11 | 12 | private: 13 | iterator data ; 14 | } ; 15 | 16 | class Vec { 17 | public: 18 | typedef double& proxy ; 19 | 20 | Vec( double* data_ ) : cache(data_){} 21 | inline proxy operator[]( int i){ return cache.ref(i) ; } 22 | inline proxy operator[]( int i) const { return cache.ref(i) ; } 23 | 24 | private: 25 | Cache cache ; 26 | } ; 27 | 28 | -------------------------------------------------------------------------------- /inst/examples/ConvolveBenchmarks/convolve11_cpp.cpp: -------------------------------------------------------------------------------- 1 | // -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*- 2 | 3 | // This version uses nona to indicate that xb does not contain any missing 4 | // value. This is the assumption that all other versions do. 5 | 6 | #include 7 | using namespace Rcpp ; 8 | 9 | 10 | RcppExport SEXP convolve11cpp(SEXP a, SEXP b) { 11 | NumericVector xa(a); int n_xa = xa.size() ; 12 | NumericVector xb(b); int n_xb = xb.size() ; 13 | NumericVector xab(n_xa + n_xb - 1,0.0); 14 | 15 | Range r( 0, n_xb-1 ); 16 | for(int i=0; i 6 | 7 | RcppExport SEXP convolve12cpp(SEXP a, SEXP b){ 8 | Rcpp::NumericVector xa(a), xb(b); 9 | int n_xa = xa.size(), n_xb = xb.size(); 10 | Rcpp::NumericVector xab(n_xa + n_xb - 1); 11 | 12 | typedef Rcpp::NumericVector::iterator vec_iterator ; 13 | vec_iterator ia = xa.begin(), ib = xb.begin(); 14 | vec_iterator iab = xab.begin(); 15 | for (int i = 0; i < n_xa; i++) 16 | for (int j = 0; j < n_xb; j++) 17 | iab[i + j] += ia[i] * ib[j]; 18 | 19 | return xab; 20 | } 21 | 22 | #include "loopmacro.h" 23 | LOOPMACRO_CPP(convolve12cpp) 24 | 25 | -------------------------------------------------------------------------------- /inst/examples/ConvolveBenchmarks/convolve13_cpp.cpp: -------------------------------------------------------------------------------- 1 | // -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*- 2 | 3 | // This is a rewrite of the 'Writing R Extensions' section 5.10.1 example 4 | 5 | #include 6 | 7 | template 8 | T convolve( const T& a, const T& b ){ 9 | int na = a.size() ; int nb = b.size() ; 10 | T out(na + nb - 1); 11 | typename T::iterator iter_a(a.begin()), iter_b(b.begin()), iter_ab( out.begin() ) ; 12 | 13 | for (int i = 0; i < na; i++) 14 | for (int j = 0; j < nb; j++) 15 | iter_ab[i + j] += iter_a[i] * iter_b[j]; 16 | 17 | return out ; 18 | } 19 | 20 | 21 | RcppExport SEXP convolve13cpp(SEXP a, SEXP b){ 22 | return convolve( Rcpp::NumericVector(a), Rcpp::NumericVector(b) ) ; 23 | } 24 | 25 | #include "loopmacro.h" 26 | LOOPMACRO_CPP(convolve13cpp) 27 | 28 | -------------------------------------------------------------------------------- /inst/examples/ConvolveBenchmarks/convolve14_cpp.cpp: -------------------------------------------------------------------------------- 1 | // -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*- 2 | 3 | // This is a rewrite of the 'Writing R Extensions' section 5.10.1 example 4 | 5 | #include 6 | 7 | using namespace Rcpp ; 8 | RcppExport SEXP convolve14cpp(SEXP a, SEXP b){ 9 | NumericVector xa(a), xb(b); 10 | int n_xa = xa.size() ; 11 | int n_xb = xb.size() ; 12 | int nab = n_xa + n_xb - 1; 13 | NumericVector xab(nab); 14 | Fast fa(xa), fb(xb), fab(xab) ; 15 | 16 | for (int i = 0; i < n_xa; i++) 17 | for (int j = 0; j < n_xb; j++) 18 | fab[i + j] += fa[i] * fb[j]; 19 | 20 | return xab ; 21 | } 22 | 23 | #include "loopmacro.h" 24 | LOOPMACRO_CPP(convolve14cpp) 25 | 26 | -------------------------------------------------------------------------------- /inst/examples/ConvolveBenchmarks/convolve2_c.c: -------------------------------------------------------------------------------- 1 | 2 | /* This is from 'Writing R Extensions' section 5.10.1 */ 3 | 4 | #include 5 | #include 6 | 7 | SEXP convolve2(SEXP a, SEXP b) 8 | { 9 | int i, j, na, nb, nab; 10 | double *xa, *xb, *xab; 11 | SEXP ab; 12 | 13 | PROTECT(a = AS_NUMERIC(a)); 14 | PROTECT(b = AS_NUMERIC(b)); 15 | na = LENGTH(a); nb = LENGTH(b); nab = na + nb - 1; 16 | PROTECT(ab = NEW_NUMERIC(nab)); 17 | xa = NUMERIC_POINTER(a); xb = NUMERIC_POINTER(b); 18 | xab = NUMERIC_POINTER(ab); 19 | for(i = 0; i < nab; i++) xab[i] = 0.0; 20 | for(i = 0; i < na; i++) 21 | for(j = 0; j < nb; j++) xab[i + j] += xa[i] * xb[j]; 22 | UNPROTECT(3); 23 | return(ab); 24 | } 25 | 26 | #include "loopmacro.h" 27 | LOOPMACRO_C(convolve2) 28 | 29 | -------------------------------------------------------------------------------- /inst/examples/ConvolveBenchmarks/convolve3_cpp.cpp: -------------------------------------------------------------------------------- 1 | // -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*- 2 | 3 | // This is a rewrite of the 'Writing R Extensions' section 5.10.1 example 4 | 5 | #include 6 | 7 | RcppExport SEXP convolve3cpp(SEXP a, SEXP b){ 8 | Rcpp::NumericVector xa(a); 9 | Rcpp::NumericVector xb(b); 10 | int n_xa = xa.size() ; 11 | int n_xb = xb.size() ; 12 | int nab = n_xa + n_xb - 1; 13 | Rcpp::NumericVector xab(nab); 14 | 15 | for (int i = 0; i < n_xa; i++) 16 | for (int j = 0; j < n_xb; j++) 17 | xab[i + j] += xa[i] * xb[j]; 18 | 19 | return xab ; 20 | } 21 | 22 | #include "loopmacro.h" 23 | LOOPMACRO_CPP(convolve3cpp) 24 | 25 | -------------------------------------------------------------------------------- /inst/examples/ConvolveBenchmarks/convolve4_cpp.cpp: -------------------------------------------------------------------------------- 1 | // -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*- 2 | 3 | // This is a rewrite of the 'Writing R Extensions' section 5.10.1 example 4 | 5 | #include 6 | 7 | RcppExport SEXP convolve4cpp(SEXP a, SEXP b) { 8 | Rcpp::NumericVector xa(a); 9 | Rcpp::NumericVector xb(b); 10 | int n_xa = xa.size() ; 11 | int n_xb = xb.size() ; 12 | int nab = n_xa + n_xb - 1; 13 | Rcpp::NumericVector xab(nab,0.0); 14 | 15 | double* pa = xa.begin() ; 16 | double* pb = xb.begin() ; 17 | double* pab = xab.begin() ; 18 | int i,j=0; 19 | for (i = 0; i < n_xa; i++) 20 | for (j = 0; j < n_xb; j++) 21 | pab[i + j] += pa[i] * pb[j]; 22 | 23 | return xab ; 24 | } 25 | 26 | #include "loopmacro.h" 27 | LOOPMACRO_CPP(convolve4cpp) 28 | 29 | 30 | -------------------------------------------------------------------------------- /inst/examples/ConvolveBenchmarks/convolve5_cpp.cpp: -------------------------------------------------------------------------------- 1 | // -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*- 2 | 3 | // This is a rewrite of the 'Writing R Extensions' section 5.10.1 example 4 | 5 | #include 6 | using namespace Rcpp ; 7 | 8 | 9 | RcppExport SEXP convolve5cpp(SEXP a, SEXP b) { 10 | NumericVector xa(a); int n_xa = xa.size() ; 11 | NumericVector xb(b); int n_xb = xb.size() ; 12 | NumericVector xab(n_xa + n_xb - 1,0.0); 13 | 14 | Range r( 0, n_xb-1 ); 15 | for(int i=0; i 6 | #include 7 | 8 | SEXP convolve7(SEXP a, SEXP b) 9 | { 10 | int i, j, na, nb, nab; 11 | SEXP ab; 12 | 13 | PROTECT(a = AS_NUMERIC(a)); 14 | PROTECT(b = AS_NUMERIC(b)); 15 | na = LENGTH(a); nb = LENGTH(b); nab = na + nb - 1; 16 | PROTECT(ab = NEW_NUMERIC(nab)); 17 | for(i = 0; i < nab; i++) REAL(ab)[i] = 0.0; 18 | for(i = 0; i < na; i++) 19 | for(j = 0; j < nb; j++) REAL(ab)[i + j] += REAL(a)[i] * REAL(b)[j]; 20 | UNPROTECT(3); 21 | return(ab); 22 | 23 | } 24 | 25 | 26 | #include "loopmacro.h" 27 | LOOPMACRO_C(convolve7) 28 | 29 | -------------------------------------------------------------------------------- /inst/examples/ConvolveBenchmarks/convolve8_cpp.cpp: -------------------------------------------------------------------------------- 1 | // -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*- 2 | 3 | // this version is between the Rcpp_New_ptr and the Rcpp_New_std version 4 | // test elapsed relative user.self sys.self 5 | // 5 Rcpp_New_ptr(REPS, a, b) 0.214 1.000000 0.213 0.001 6 | // 7 Rcpp_New_std_2(REPS, a, b) 0.223 1.042056 0.216 0.006 7 | // 4 Rcpp_New_std(REPS, a, b) 0.524 2.448598 0.523 0.001 8 | // 9 | // so there is some overhead due to creating Vec objects and indexing them 10 | // but much less than when we index the NumericVector 11 | 12 | #include 13 | 14 | class Vec { 15 | public: 16 | Vec( double* data_ ) : data(data_){} 17 | inline double& operator[]( int i){ return data[i] ; } 18 | 19 | private: 20 | double* data ; 21 | } ; 22 | 23 | 24 | RcppExport SEXP convolve8cpp(SEXP a, SEXP b){ 25 | Rcpp::NumericVector xa(a); 26 | Rcpp::NumericVector xb(b); 27 | int n_xa = xa.size() ; 28 | int n_xb = xb.size() ; 29 | int nab = n_xa + n_xb - 1; 30 | Rcpp::NumericVector xab(nab); 31 | 32 | Vec vab(xab.begin()), va(xa.begin()), vb(xb.begin()) ; 33 | 34 | for (int i = 0; i < n_xa; i++) 35 | for (int j = 0; j < n_xb; j++) 36 | vab[i + j] += va[i] * vb[j]; 37 | 38 | return xab ; 39 | } 40 | 41 | #include "loopmacro.h" 42 | LOOPMACRO_CPP(convolve8cpp) 43 | 44 | -------------------------------------------------------------------------------- /inst/examples/ConvolveBenchmarks/loopmacro.h: -------------------------------------------------------------------------------- 1 | 2 | #define LOOPMACRO_C(name) \ 3 | SEXP name##__loop(SEXP n_, SEXP a, SEXP b){ \ 4 | int n = INTEGER(n_)[0] ; \ 5 | SEXP res = R_NilValue ; \ 6 | for( int i=0; i 6 | // using namespace Rcpp ; 7 | 8 | SEXP overhead_cpp(SEXP a, SEXP b) { 9 | return R_NilValue ; 10 | } 11 | 12 | extern "C" void R_init_overhead_1(DllInfo *info){ 13 | 14 | R_CallMethodDef callMethods[] = { 15 | {"overhead_cpp", (DL_FUNC) &overhead_cpp, 2}, 16 | {NULL, NULL, 0} 17 | }; 18 | 19 | R_registerRoutines(info, NULL, callMethods, NULL, NULL); 20 | } 21 | 22 | -------------------------------------------------------------------------------- /inst/examples/ConvolveBenchmarks/overhead_2.c: -------------------------------------------------------------------------------- 1 | // -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*- 2 | 3 | // This is a rewrite of the 'Writing R Extensions' section 5.10.1 example 4 | #include 5 | #include 6 | #include 7 | 8 | SEXP overhead_c(SEXP a, SEXP b) { 9 | return R_NilValue ; 10 | } 11 | 12 | void R_init_overhead_2(DllInfo *info){ 13 | 14 | R_CallMethodDef callMethods[] = { 15 | {"overhead_c", (DL_FUNC) &overhead_c, 2}, 16 | {NULL, NULL, 0} 17 | }; 18 | 19 | R_registerRoutines(info, NULL, callMethods, NULL, NULL); 20 | } 21 | 22 | -------------------------------------------------------------------------------- /inst/examples/Misc/newFib.r: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env r 2 | 3 | ## New and shorter version of Fibonacci example using Rcpp 0.9.16 or later features 4 | ## The the sibbling file 'fibonacci.r' for context 5 | 6 | require(Rcpp) # no longer need inline 7 | 8 | ## R version 9 | fibR <- function(seq) { 10 | if (seq < 2) return(seq) 11 | return (fibR(seq - 1) + fibR(seq - 2)) 12 | } 13 | 14 | ## C++ code 15 | cpptxt <- ' 16 | int fibonacci(const int x) { 17 | if (x < 2) return(x); 18 | return (fibonacci(x - 1)) + fibonacci(x - 2); 19 | }' 20 | 21 | ## C++ version 22 | fibCpp <- cppFunction(cpptxt) # compiles, load, links, ... 23 | 24 | ## load rbenchmark to compare 25 | library(rbenchmark) 26 | 27 | N <- 35 ## same parameter as original post 28 | res <- benchmark(fibR(N), fibCpp(N), 29 | columns=c("test", "replications", "elapsed", "relative"), 30 | order="relative", replications=1) 31 | print(res) ## show result 32 | 33 | -------------------------------------------------------------------------------- /inst/examples/Misc/piBySimulation.r: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env r 2 | 3 | library(Rcpp) 4 | library(rbenchmark) 5 | 6 | piR <- function(N) { 7 | x <- runif(N) 8 | y <- runif(N) 9 | d <- sqrt(x^2 + y^2) 10 | return(4 * sum(d < 1.0) / N) 11 | } 12 | 13 | sourceCpp("piSugar.cpp") 14 | 15 | N <- 1e6 16 | 17 | set.seed(42) 18 | resR <- piR(N) 19 | 20 | set.seed(42) 21 | resCpp <- piSugar(N) 22 | 23 | ## important: check results are identical with RNG seeded 24 | stopifnot(identical(resR, resCpp)) 25 | 26 | res <- benchmark(piR(N), piSugar(N), order="relative") 27 | 28 | print(res[,1:4]) 29 | -------------------------------------------------------------------------------- /inst/examples/Misc/piSugar.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | using namespace Rcpp; 5 | 6 | // [[Rcpp::export]] 7 | double piSugar(const int N) { 8 | NumericVector x = runif(N); 9 | NumericVector y = runif(N); 10 | NumericVector d = sqrt(x*x + y*y); 11 | return 4.0 * sum(d < 1.0) / N; 12 | } 13 | -------------------------------------------------------------------------------- /inst/examples/OpenMP/GNUmakefile: -------------------------------------------------------------------------------- 1 | 2 | ## comment this out if you need a different version of R, 3 | ## and set set R_HOME accordingly as an environment variable 4 | R_HOME := $(shell R RHOME) 5 | 6 | ## include headers and libraries for R 7 | RCPPFLAGS := $(shell $(R_HOME)/bin/R CMD config --cppflags) 8 | RLDFLAGS := $(shell $(R_HOME)/bin/R CMD config --ldflags) 9 | 10 | ## include headers and libraries for Rcpp interface classes 11 | RCPPINCL := $(shell echo 'Rcpp:::CxxFlags()' | $(R_HOME)/bin/R --vanilla --slave) 12 | RCPPLIBS := $(shell echo 'Rcpp:::LdFlags()' | $(R_HOME)/bin/R --vanilla --slave) 13 | 14 | ## OpenMP 15 | OPENMPFLAGS := -fopenmp 16 | 17 | c_sources := $(wildcard *.c) 18 | c_sharedlibs := $(patsubst %.c,%.o,$(c_sources)) 19 | 20 | cpp_sources := $(wildcard *.cpp) 21 | cpp_sharedlibs := $(patsubst %.cpp,%.o,$(cpp_sources)) 22 | 23 | all : $(c_sharedlibs) $(cpp_sharedlibs) 24 | 25 | %.o : %.c 26 | R CMD SHLIB $< 27 | 28 | %.o : %.cpp 29 | PKG_CPPFLAGS="$(RCPPFLAGS) $(RCPPINCL) $(OPENMPFLAGS)" PKG_LIBS="$(RLDFLAGS) $(RCPPLIBS) $(OPENMPFLAGS)" R CMD SHLIB $< 30 | 31 | -------------------------------------------------------------------------------- /inst/examples/OpenMP/check.R: -------------------------------------------------------------------------------- 1 | 2 | dyn.load("piWithInterrupts.so") 3 | #res <- .Call("PiLeibniz", n=1e9, frequency=1e6) 4 | res <- .Call("PiLeibniz", n=1e9, frequency=1e6) 5 | print(res, digits=10) 6 | -------------------------------------------------------------------------------- /inst/examples/RcppInline/RcppSimpleExample.r: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env r 2 | 3 | 4 | suppressMessages(library(Rcpp)) 5 | suppressMessages(library(inline)) 6 | 7 | 8 | foo <- ' 9 | int i, j, na, nb, nab; 10 | double *xa, *xb, *xab; 11 | SEXP ab; 12 | 13 | PROTECT(a = AS_NUMERIC(a)); 14 | PROTECT(b = AS_NUMERIC(b)); 15 | na = LENGTH(a); nb = LENGTH(b); nab = na + nb - 1; 16 | PROTECT(ab = NEW_NUMERIC(nab)); 17 | xa = NUMERIC_POINTER(a); xb = NUMERIC_POINTER(b); 18 | xab = NUMERIC_POINTER(ab); 19 | for(i = 0; i < nab; i++) xab[i] = 0.0; 20 | for(i = 0; i < na; i++) 21 | for(j = 0; j < nb; j++) xab[i + j] += xa[i] * xb[j]; 22 | UNPROTECT(3); 23 | return(ab); 24 | ' 25 | 26 | funx <- cfunction(signature(a="numeric",b="numeric"), foo, Rcpp=FALSE, verbose=FALSE) 27 | funx(a=1:20, b=2:11) 28 | -------------------------------------------------------------------------------- /inst/examples/SugarPerformance/Timertest.cpp: -------------------------------------------------------------------------------- 1 | // -*- mode: c++; compile-command: "g++ -Wall -O3 -o Timertest Timertest.cpp"; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*- 2 | 3 | // from http://www.cs.uiowa.edu/~sriram/30/fall03/ 4 | 5 | #include 6 | #include 7 | #include "Timer.h" 8 | 9 | int main() { 10 | Timer test; 11 | 12 | std::cout << "Sleeping 2 seconds" << std::endl; 13 | test.Start(); 14 | sleep(2); 15 | test.Stop(); 16 | std::cout << "Sleep lasted for " << test.ElapsedTime() << " seconds." << std::endl; 17 | std::cout << "Sleeping 1 second" << std::endl; 18 | test.Start(); 19 | sleep(1); 20 | test.Stop(); 21 | std::cout << "Sleep lasted for " << test.ElapsedTime() << " seconds." << std::endl; 22 | std::cout << "Cumulative time is " << test.CumulativeTime() << " seconds." << std::endl; 23 | std::cout << "Reseting" << std::endl; 24 | test.Reset(); 25 | std::cout << "Sleeping 2 seconds" << std::endl; 26 | test.Start(); 27 | sleep(2); 28 | test.Stop(); 29 | std::cout << "Sleep lasted for " << test.ElapsedTime() << " seconds." << std::endl; 30 | std::cout << "Cumulative time is " << test.CumulativeTime() << " seconds." << std::endl; 31 | } 32 | -------------------------------------------------------------------------------- /inst/examples/functionCallback/README: -------------------------------------------------------------------------------- 1 | 2 | A much simpler version of the example is provided in the file newApiExample.r. 3 | With littler installed, it can be run 'as is' as a shell script; else it can 4 | be sourced into R. 5 | 6 | -- Dirk Eddelbuettel and Romain Francois, 06 Feb 2010 7 | 8 | 9 | This directory provides a simple example of how an R function 10 | can be passed back and forth between R and C++. 11 | 12 | We define the function at the R level, pass it to C++ using the Rcpp 13 | interface and have C++ call it. This works by subclassing the C++ class 14 | RcppFunction (from Rcpp) and adding a new member function transformVector() 15 | which is vector-valued. We then instantiate this new class in the C++ 16 | function called from R -- and by calling the transformVector() function from 17 | C++ we get R to operate on the supplied vector. 18 | 19 | In this demo, we simply exponeniate the data vector but also plot it as a 20 | side effect -- effectively giving us R plotting from a C++ function. 21 | 22 | -- Dirk Eddelbuettel, 29 Sep 2009 23 | -------------------------------------------------------------------------------- /inst/examples/performance/performance.R: -------------------------------------------------------------------------------- 1 | 2 | require( inline ) 3 | require( Rcpp ) 4 | 5 | expressions <- list( 6 | times = "x * y" , 7 | plus = "x + y" 8 | # , 9 | # minus = "x - y", 10 | # divides = "x / y", 11 | # exp_ = "exp( x )" 12 | ) 13 | 14 | signatures <- lapply( expressions, function(.) signature( x_ = "numeric", y_ = "numeric", n_ = "integer" ) ) 15 | bodies <- lapply( expressions, function(.){ 16 | sprintf( ' 17 | int n = as( n_ ) ; 18 | NumericVector x(x_), y(y_), z(x.size()) ; 19 | for( int i=0; i. 21 | 22 | #ifndef Rcpp__Extractor_h 23 | #define Rcpp__Extractor_h 24 | 25 | namespace Rcpp { 26 | namespace traits { 27 | 28 | template 29 | struct Extractor { 30 | typedef VECTOR type ; 31 | } ; 32 | 33 | } // traits 34 | } // Rcpp 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /inst/include/Rcpp/Light: -------------------------------------------------------------------------------- 1 | // Rcpp/Light: R/C++ interface class library -- without Rcpp Modules 2 | // 3 | // Copyright (C) 2008 - 2021 Dirk Eddelbuettel 4 | // Copyright (C) 2009 - 2021 Dirk Eddelbuettel and Romain Francois 5 | // 6 | // This file is part of Rcpp. 7 | // 8 | // Rcpp is free software: you can redistribute it and/or modify it 9 | // under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation, either version 2 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // Rcpp is distributed in the hope that it will be useful, but 14 | // WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with Rcpp. If not, see . 20 | 21 | // no Modules 22 | #define RCPP_NO_MODULES 23 | 24 | // include Rcpp as usual 25 | #include 26 | -------------------------------------------------------------------------------- /inst/include/Rcpp/Lighter: -------------------------------------------------------------------------------- 1 | // Rcpp/Lighter: R/C++ interface class library -- without Rcpp Modules + RTTI 2 | // 3 | // Copyright (C) 2008 - 2021 Dirk Eddelbuettel 4 | // Copyright (C) 2009 - 2021 Dirk Eddelbuettel and Romain Francois 5 | // 6 | // This file is part of Rcpp. 7 | // 8 | // Rcpp is free software: you can redistribute it and/or modify it 9 | // under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation, either version 2 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // Rcpp is distributed in the hope that it will be useful, but 14 | // WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with Rcpp. If not, see . 20 | 21 | // no RTTI (actually implies no Modules) -- solid gain 22 | #define RCPP_NO_RTTI 23 | 24 | // include Rcpp/Light which includes Rcpp 25 | #include 26 | -------------------------------------------------------------------------------- /inst/include/Rcpp/Lightest: -------------------------------------------------------------------------------- 1 | // Rcpp/Lightest: R/C++ interface class library -- without Rcpp Modules, RTTI, Sugar 2 | // 3 | // Copyright (C) 2008 - 2021 Dirk Eddelbuettel 4 | // Copyright (C) 2009 - 2021 Dirk Eddelbuettel and Romain Francois 5 | // 6 | // This file is part of Rcpp. 7 | // 8 | // Rcpp is free software: you can redistribute it and/or modify it 9 | // under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation, either version 2 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // Rcpp is distributed in the hope that it will be useful, but 14 | // WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with Rcpp. If not, see . 20 | // New (draft) header with optional components off 21 | 22 | // no Sugar (but unclear how much it helps) 23 | #define RCPP_NO_SUGAR 24 | 25 | // include Rcpp/Lighter 26 | #include 27 | -------------------------------------------------------------------------------- /inst/include/Rcpp/Rcpp: -------------------------------------------------------------------------------- 1 | // Rcpp/Rcpp: R/C++ interface class library 2 | // 3 | // Copyright (C) 2008 - 2021 Dirk Eddelbuettel 4 | // Copyright (C) 2009 - 2021 Dirk Eddelbuettel and Romain Francois 5 | // 6 | // This file is part of Rcpp. 7 | // 8 | // Rcpp is free software: you can redistribute it and/or modify it 9 | // under the terms of the GNU General Public License as published by 10 | // the Free Software Foundation, either version 2 of the License, or 11 | // (at your option) any later version. 12 | // 13 | // Rcpp is distributed in the hope that it will be useful, but 14 | // WITHOUT ANY WARRANTY; without even the implied warranty of 15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | // GNU General Public License for more details. 17 | // 18 | // You should have received a copy of the GNU General Public License 19 | // along with Rcpp. If not, see . 20 | 21 | #include 22 | -------------------------------------------------------------------------------- /inst/include/Rcpp/api/bones/bones.h: -------------------------------------------------------------------------------- 1 | // -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 4 -*- 2 | // 3 | // bones.h: Rcpp R/C++ interface class library -- 4 | // 5 | // Copyright (C) 2010 - 2012 Dirk Eddelbuettel and Romain Francois 6 | // 7 | // This file is part of Rcpp. 8 | // 9 | // Rcpp is free software: you can redistribute it and/or modify it 10 | // under the terms of the GNU General Public License as published by 11 | // the Free Software Foundation, either version 2 of the License, or 12 | // (at your option) any later version. 13 | // 14 | // Rcpp is distributed in the hope that it will be useful, but 15 | // WITHOUT ANY WARRANTY; without even the implied warranty of 16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | // GNU General Public License for more details. 18 | // 19 | // You should have received a copy of the GNU General Public License 20 | // along with Rcpp. If not, see . 21 | 22 | #ifndef Rcpp__api__bones__bones_h 23 | #define Rcpp__api__bones__bones_h 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /inst/include/Rcpp/api/bones/wrap_extra_steps.h: -------------------------------------------------------------------------------- 1 | // -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*- 2 | /* :tabSize=4:indentSize=4:noTabs=false:folding=explicit:collapseFolds=1: */ 3 | // 4 | // wrap_extra_steps.h: Rcpp R/C++ interface class library -- wrap forward decl 5 | // 6 | // Copyright (C) 2010 - 2017 Dirk Eddelbuettel and Romain Francois 7 | // 8 | // This file is part of Rcpp. 9 | // 10 | // Rcpp is free software: you can redistribute it and/or modify it 11 | // under the terms of the GNU General Public License as published by 12 | // the Free Software Foundation, either version 2 of the License, or 13 | // (at your option) any later version. 14 | // 15 | // Rcpp is distributed in the hope that it will be useful, but 16 | // WITHOUT ANY WARRANTY; without even the implied warranty of 17 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | // GNU General Public License for more details. 19 | // 20 | // You should have received a copy of the GNU General Public License 21 | // along with Rcpp. If not, see . 22 | 23 | #ifndef Rcpp__api__bones__wrap_extra_steps_h 24 | #define Rcpp__api__bones__wrap_extra_steps_h 25 | 26 | namespace Rcpp { 27 | 28 | template SEXP wrap_extra_steps(SEXP x) { // #nocov start 29 | return x; 30 | } // #nocov end 31 | 32 | } // Rcpp 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /inst/include/Rcpp/api/meat/DataFrame.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013 Romain Francois 2 | // 3 | // This file is part of Rcpp. 4 | // 5 | // Rcpp is free software: you can redistribute it and/or modify it 6 | // under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 2 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // Rcpp is distributed in the hope that it will be useful, but 11 | // WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with Rcpp. If not, see . 17 | 18 | #ifndef Rcpp_api_meat_DataFrame_h 19 | #define Rcpp_api_meat_DataFrame_h 20 | 21 | namespace Rcpp{ 22 | 23 | template