Git Product home page Git Product logo

Comments (9)

rsparapa avatar rsparapa commented on June 11, 2024 1

Sure, it still doesn't work. But, I will post on Rcpp Gallery when I figure it out.

from rcppeigen.

eddelbuettel avatar eddelbuettel commented on June 11, 2024

Some starters:

Plus a vignette from Rcpp that is also a chapter in the Rcpp book:

It is still fairly daunting material. Maybe start small and try a simple case working to not get carried away.

from rcppeigen.

rsparapa avatar rsparapa commented on June 11, 2024

Hi Gang:

As I was thinking more about this, a question occurred to me. Is it the case that there is no multi-dimensional RcppArray in Rcpp itself? If so, then I think that might be an avenue or alternative to what I proposed above. If not (something like RcppArray does exist), then maybe I could look at those details and that would assist me here. I hope that this questions makes sense ;o)

Thanks

from rcppeigen.

eddelbuettel avatar eddelbuettel commented on June 11, 2024

Well, as I recall, arrays are really just standard vectors with a dim attribute:

R> a <- array(1:8, dim=c(2,2,2))
R> a
, , 1

     [,1] [,2]
[1,]    1    3
[2,]    2    4

, , 2

     [,1] [,2]
[1,]    5    7
[2,]    6    8

R> class(a)
[1] "array"
R> str(a)
 int [1:2, 1:2, 1:2] 1 2 3 4 5 6 7 8
R> 

The above can be done easily (see Rcpp Gallery on setting dim easily). And there is more
as e.g. https://gallery.rcpp.org/articles/simple-array-class/ plus some add-on packages on CRAN.

So if you specify the problem you want to solve more clearly, maybe we can help you. Here it looks like you just redefined one question into another, loosely related one. But maybe I am missing something...

from rcppeigen.

rsparapa avatar rsparapa commented on June 11, 2024

You are right that doesn't really help here. Just have to find some time to work on this issue.

from rcppeigen.

rsparapa avatar rsparapa commented on June 11, 2024

Ok, I see where I was going with my previous question above. The simple array class is ok, but that uses RcppArmadillo. I hesitate to add yet another dependency when I already have an RcppEigen dependency. But, instead of RcppEiegen tensors, I tried a different attack. I'm creating Rcpp 3D arrays on the C++ side which works seemlessly as you suggest. However, how do you access the memory locations? For example, I tried something like...

Rcpp::NumericVector impute_draw(Rcpp::Dimension(nkeeptrain, n, K));
impute_draw(0, 0, 0)=0.;

The first line is fine, but the second generates an error. So, this is what I am trying to do. I realize that this is not an RcppEigen tensor issue per se. Although that could be an avenue taken, I think just figuring this out for Rcpp core would mean that tensors are not really needed (unless of course you have already invested in an Eigen tensor code base which I have not). Am I making more sense now? Thanks

from rcppeigen.

eddelbuettel avatar eddelbuettel commented on June 11, 2024

I guess the (...,) accessor is simply not implemented for three dimensions for a NumericVector type.

Here you create a vector --- a 1-D object. You can play games with N dimensions but you need to map those down to the 1-D case that that class understand.

As for multiple dependencies: up to you. A number of packages on CRAN do just that and depends on RcppArmadillo and RcppEigen. There is no rule against that.

from rcppeigen.

rsparapa avatar rsparapa commented on June 11, 2024

True. But, I'm thinking that if I want this, then many others want it too and the best place is Rcpp itself. I have played around with the 1-D idea, i.e., impute_draw[i]. But, something is wrong with my math. Not sure what I am doing wrong. The simple array class should help here, but I'm not exacly following it. If I can figure this out, then it shows us how to create the (...,...,...) accessor for Rcpp, right? Or is that trouble because it is variadic?

from rcppeigen.

eddelbuettel avatar eddelbuettel commented on June 11, 2024

I do not think this belongs in Rcpp proper as this can be handled just fine in a user-written package such as yours.

Can we close this here too as there is actually no demonstrated issue against RcppEigen...

from rcppeigen.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.