Git Product home page Git Product logo

Comments (8)

eddelbuettel avatar eddelbuettel commented on June 12, 2024

Pull requests would be welcome.

from rcpparmadillo.

antoniopvgs avatar antoniopvgs commented on June 12, 2024

Hi Dirk, that's fair. I'm far from being an expert programmer but found the following code that solves the problem. However, I don't know how easy would be integrating it in your package:

#include <RcppArmadillo.h>
// [[Rcpp::depends(RcppArmadillo)]]

// [[Rcpp::export]]
arma::cube array2cube( SEXP myArray ) {

Rcpp::NumericVector vecArray(myArray);
Rcpp::IntegerVector arrayDims = vecArray.attr("dim");

arma::cube cubeArray(vecArray.begin(), arrayDims[0], arrayDims[1], arrayDims[2], false);

return(cubeArray);  

}

Many thanks in any case for providing the Rcpp package.

from rcpparmadillo.

eddelbuettel avatar eddelbuettel commented on June 12, 2024

This has been added in #64.

from rcpparmadillo.

gvegayon avatar gvegayon commented on June 12, 2024

Great!

George G. Vega Yon (from mobile)
+1 626 381 8171
http://www.its.caltech.edu/~gvegayon
On Dec 1, 2015 4:10 AM, "Dirk Eddelbuettel" [email protected]
wrote:

This has been added in #64
#64.

โ€”
Reply to this email directly or view it on GitHub
#42 (comment)
.

from rcpparmadillo.

eddelbuettel avatar eddelbuettel commented on June 12, 2024

Our thanks to @nathan-russell ๐Ÿ˜ƒ

from rcpparmadillo.

antoniopvgs avatar antoniopvgs commented on June 12, 2024

Thanks a lot.
El 1 dic. 2015 1:10 p. m., "Dirk Eddelbuettel" [email protected]
escribiรณ:

This has been added in #64
#64.

โ€”
Reply to this email directly or view it on GitHub
#42 (comment)
.

from rcpparmadillo.

eddelbuettel avatar eddelbuettel commented on June 12, 2024

For completeness:

 R> library(Rcpp)
 R> cppFunction("arma::cube doubleCube(arma::cube cb) { return 2*cb; }", 
 +                        depends="RcppArmadillo")
R> doubleCube(array(1:8, dim=c(2,2,2)))
 , , 1

      [,1] [,2]
 [1,]    2    6
 [2,]    4    8

 , , 2

      [,1] [,2]
 [1,]   10   14
 [2,]   12   16

 R> 

Thanks again @nathan-russell !

from rcpparmadillo.

nathan-russell avatar nathan-russell commented on June 12, 2024

@eddelbuettel More than happy to help where I'm able to ๐Ÿ‘

from rcpparmadillo.

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.