Skip to content

Minimize dependence on functions/behaviors provided by Rcpp #11

Description

@huisaddison

Suggested by @ryantibs to improve portability. Using operations defined in the standard library also makes our code more easily generalizable via template functions.

An example of how this is done: https://github.com/ryantibs/dspline/blob/main/src/matrix_construction.cpp#L162

I had originally suggested relying on class member functions that have the same name across Rcpp, Eigen, std, etc. classes.

@ryantibs pointed out that we could also do this by relying on std library functions. And I now agree that this is a more robust and easily implementable approach. In principle this should be "easy" since Rcpp Vector classes implement .begin() and .end() member functions which return pointers to the beginning and end of the memory block to which it refers (see above for an example of this usage to apply a standard library function).

Along those lines, as they come up I may change function signatures to explicitly pass by reference when we want this behavior, rather than "abusing" the fact that Rcpp Vectors are really pointers to get pass-by-reference-like behavior. This clarifies the intention of the code to the reader; and down the line one could hypothetically replace the Rcpp Vector types with other Vector types (or template it out) and get the intended behavior.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions