GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — armadillo glue code · Issue #185 · Rcpp11/Rcpp11

armadillo glue code #185

New issue
Copy link
New issue
Copy link
Open
Open
armadillo glue code#185
Copy link
Labels
design

Description

@romainfrancois
romainfrancois
opened on May 27, 2014
Issue body actions

armadillo is quite popular and people will want to be able to use it with Rcpp11.
Unfortunately, the glue code in RcppArmadillo is not compatible with the implementation of as and wrap in Rcpp11.

However, writing this glue code will be much easier than it was at the time.

I don't particularly want to maintain some sort of Rcpp11Armadillo package, we should be able to leverage the headers of RcppArmadillo (only selecting the interesting parts), i.e. dumping Rcpp glue code and stuff related to what is in src/.

The question really comes down to where this glue code should be.

What I'd like is for packages to be able to say:

LinkingTo: Rcpp11, RcppArmadillo

And perhaps some relevant information in the Makevars. Also desirable that we can write:

#include <RcppArmadillo.h>

// [[depends(RcppArmadillo)]]

// [[export]]
arma::mat foo(){
    // do stuff 
}

The way I see this going is hosting the glue code (will be a few files) directly in Rcpp11. Somewhat independently of where armadillo comes from. People using it would then just have to link to both Rcpp11 and RcppArmadillo.

Alternatively we could make the glue code be included automatically if <armadillo> was included. So that we'd have:

#include <armadillo>     // from RcppArmadillo's hosted armadillo
#include <Rcpp11>        // from Rcpp11

The downside of this I guess is that we would not be able to take advantage of code injection directly with the `armadillo classes, i.e. these:

#define ARMA_EXTRA_MAT_PROTO RcppArmadillo/Mat_proto.h
#define ARMA_EXTRA_MAT_MEAT  RcppArmadillo/Mat_meat.h
#define ARMA_EXTRA_COL_PROTO RcppArmadillo/Col_proto.h
#define ARMA_EXTRA_COL_MEAT  RcppArmadillo/Col_meat.h
#define ARMA_EXTRA_ROW_PROTO RcppArmadillo/Row_proto.h
#define ARMA_EXTRA_ROW_MEAT  RcppArmadillo/Row_meat.h

These allow us to inject constructors directly in armadillo classes, so that e.g. we can create an armadillo matrix out of an Rcpp sugar expression.

Perhaps we can do it the other way around:

#include <Rcpp11>        
#include <armadillo>     // from RcppArmadillo's hosted armadillo

But in that case the problem is that we don't have a way to signal Rcpp11 that it should include armadillo glue code.

One thing that might be possible would be to have the #define from above in Rcpp11 no matter what. It does not hurt, these are just defines. And perhaps abuse one of them to include the glue code. Actually all we need to do is include the glue code for mat inside Mat_meat, ...

I think that's the way I want to do it. It just feels nice to have:

#include <Rcpp11>
#include <armadillo>

Activity

  1. romainfrancois
    added
    design
    on May 27, 2014
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

    design

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.