I may be confusing Armadillo classes and Rcpp classes but I seem to recall that there is an Rcpp class for arrays with more than 2 dimensions. However, I can't find anything that looks like that in the declarations or in the unit tests. I can easily create such an object by installing a dim attribute on a Vector type but I didn't want to reinvent the wheel. Is there such a class or am I misremembering?
[Rcpp-devel] Is there an Rcpp class for arrays with > 2 dimensions?
6 messages · Romain Francois, Douglas Bates, Dominick Samperi
Le 15/06/10 20:08, Douglas Bates a ?crit :
I may be confusing Armadillo classes and Rcpp classes but I seem to recall that there is an Rcpp class for arrays with more than 2 dimensions. However, I can't find anything that looks like that in the declarations or in the unit tests. I can easily create such an object by installing a dim attribute on a Vector type but I didn't want to reinvent the wheel. Is there such a class or am I misremembering?
We do not have invented that wheel. It should not be too hard to generalize what we do with Rcpp::Matrix You can ignore the member functions that have diag in their names. although, we would probably also have to extend the Vector::operator() for more dimensions, and probably also Vector::offset. I feel somewhat lazy here, but if you or someone else decides to pick it up, I will have a look. Romain
Romain Francois Professional R Enthusiast +33(0) 6 28 91 30 30 http://romainfrancois.blog.free.fr |- http://bit.ly/98Uf7u : Rcpp 0.8.1 |- http://bit.ly/c6YnCi : graph gallery collage `- http://bit.ly/bZ7ltC : inline 0.3.5
I have tried something like Rcpp::NumericVector nm(Rcpp::Dimension(2,3,4)); But there seems to be a problem due to non-public fields. Am I misunderstanding the purpose of Dimension() here? On Tue, Jun 15, 2010 at 2:19 PM, Romain Francois
<romain at r-enthusiasts.com>wrote:
Le 15/06/10 20:08, Douglas Bates a ?crit :
I may be confusing Armadillo classes and Rcpp classes but I seem to recall that there is an Rcpp class for arrays with more than 2 dimensions. However, I can't find anything that looks like that in the declarations or in the unit tests. I can easily create such an object by installing a dim attribute on a Vector type but I didn't want to reinvent the wheel. Is there such a class or am I misremembering?
We do not have invented that wheel. It should not be too hard to generalize what we do with Rcpp::Matrix You can ignore the member functions that have diag in their names. although, we would probably also have to extend the Vector::operator() for more dimensions, and probably also Vector::offset. I feel somewhat lazy here, but if you or someone else decides to pick it up, I will have a look. Romain -- Romain Francois Professional R Enthusiast +33(0) 6 28 91 30 30 http://romainfrancois.blog.free.fr |- http://bit.ly/98Uf7u : Rcpp 0.8.1 |- http://bit.ly/c6YnCi : graph gallery collage `- http://bit.ly/bZ7ltC : inline 0.3.5
_______________________________________________ Rcpp-devel mailing list Rcpp-devel at lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20100615/fc1c0ddd/attachment.htm>
Le 15/06/10 20:45, Dominick Samperi a ?crit :
I have tried something like Rcpp::NumericVector nm(Rcpp::Dimension(2,3,4));
I get this:
> require( Rcpp )
Le chargement a n?cessit? le package : Rcpp
> require( inline )
Le chargement a n?cessit? le package : inline
> fx <- cxxfunction( signature(), ' return NumericVector(
Dimension(2,3,4) ) ;', plugin = "Rcpp" )
>
> fx()
, , 1
[,1] [,2] [,3]
[1,] 0 0 0
[2,] 0 0 0
, , 2
[,1] [,2] [,3]
[1,] 0 0 0
[2,] 0 0 0
, , 3
[,1] [,2] [,3]
[1,] 0 0 0
[2,] 0 0 0
, , 4
[,1] [,2] [,3]
[1,] 0 0 0
[2,] 0 0 0
which looks about right. although not much useful without some more
support such as extract or set the values.
But there seems to be a problem due to non-public fields.
What do you mean ?
Am I misunderstanding the purpose of Dimension() here?
Perhaps. Perhaps not. You did not tell us what you understand.
On Tue, Jun 15, 2010 at 2:19 PM, Romain Francois
<romain at r-enthusiasts.com <mailto:romain at r-enthusiasts.com>> wrote:
Le 15/06/10 20:08, Douglas Bates a ?crit :
I may be confusing Armadillo classes and Rcpp classes but I seem to
recall that there is an Rcpp class for arrays with more than 2
dimensions. However, I can't find anything that looks like that in
the declarations or in the unit tests. I can easily create such an
object by installing a dim attribute on a Vector type but I didn't
want to reinvent the wheel.
Is there such a class or am I misremembering?
We do not have invented that wheel. It should not be too hard to
generalize what we do with Rcpp::Matrix
You can ignore the member functions that have diag in their names.
although, we would probably also have to extend the
Vector::operator() for more dimensions, and probably also
Vector::offset.
I feel somewhat lazy here, but if you or someone else decides to
pick it up, I will have a look.
Romain
Romain Francois Professional R Enthusiast +33(0) 6 28 91 30 30 http://romainfrancois.blog.free.fr |- http://bit.ly/98Uf7u : Rcpp 0.8.1 |- http://bit.ly/c6YnCi : graph gallery collage `- http://bit.ly/bZ7ltC : inline 0.3.5
On Tue, Jun 15, 2010 at 2:11 PM, Romain Francois
<romain at r-enthusiasts.com> wrote:
Le 15/06/10 20:45, Dominick Samperi a ?crit :
I have tried something like Rcpp::NumericVector nm(Rcpp::Dimension(2,3,4));
I get this:
require( Rcpp )
Le chargement a n?cessit? le package : Rcpp
require( inline )
Le chargement a n?cessit? le package : inline
fx <- cxxfunction( signature(), ' return NumericVector( Dimension(2,3,4) ) ;', plugin = "Rcpp" ) fx()
, , 1 ? ? [,1] [,2] [,3] [1,] ? ?0 ? ?0 ? ?0 [2,] ? ?0 ? ?0 ? ?0 , , 2 ? ? [,1] [,2] [,3] [1,] ? ?0 ? ?0 ? ?0 [2,] ? ?0 ? ?0 ? ?0 , , 3 ? ? [,1] [,2] [,3] [1,] ? ?0 ? ?0 ? ?0 [2,] ? ?0 ? ?0 ? ?0 , , 4 ? ? [,1] [,2] [,3] [1,] ? ?0 ? ?0 ? ?0 [2,] ? ?0 ? ?0 ? ?0 which looks about right. although not much useful without some more support such as extract or set the values.
Actually, that was what I was thinking of. All I want to do is to generate the array and then I will fill in the values using a pointer.
But there seems to be a problem due to non-public fields.
What do you mean ?
Am I misunderstanding the purpose of Dimension() here?
Perhaps. Perhaps not. You did not tell us what you understand.
On Tue, Jun 15, 2010 at 2:19 PM, Romain Francois <romain at r-enthusiasts.com <mailto:romain at r-enthusiasts.com>> wrote: ? ?Le 15/06/10 20:08, Douglas Bates a ?crit : ? ? ? ?I may be confusing Armadillo classes and Rcpp classes but I seem to ? ? ? ?recall that there is an Rcpp class for arrays with more than 2 ? ? ? ?dimensions. ?However, I can't find anything that looks like that in ? ? ? ?the declarations or in the unit tests. ?I can easily create such an ? ? ? ?object by installing a dim attribute on a Vector type but I didn't ? ? ? ?want to reinvent the wheel. ? ? ? ?Is there such a class or am I misremembering? ? ?We do not have invented that wheel. It should not be too hard to ? ?generalize what we do with Rcpp::Matrix ? ?You can ignore the member functions that have diag in their names. ? ?although, we would probably also have to extend the ? ?Vector::operator() for more dimensions, and probably also ? ?Vector::offset. ? ?I feel somewhat lazy here, but if you or someone else decides to ? ?pick it up, I will have a look. ? ?Romain
-- Romain Francois Professional R Enthusiast +33(0) 6 28 91 30 30 http://romainfrancois.blog.free.fr |- http://bit.ly/98Uf7u : Rcpp 0.8.1 |- http://bit.ly/c6YnCi : graph gallery collage `- http://bit.ly/bZ7ltC : inline 0.3.5
_______________________________________________ Rcpp-devel mailing list Rcpp-devel at lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
[should have used reply all] On Tue, Jun 15, 2010 at 3:11 PM, Romain Francois
<romain at r-enthusiasts.com>wrote:
But there seems to be a problem due to non-public fields.
What do you mean ?
I made the mistake of using NumericMatrix(Dimension(2,3,4)) instead of NumericVector(Dimension(2,3,4)). That is why I had compilation problems. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20100615/579111d3/attachment-0001.htm>