[Rcpp-devel] returning array from C
Romain Francois
romain at r-enthusiasts.com
Tue Jun 11 23:40:01 CEST 2013
Le 11 juin 2013 à 22:10, Steve Jaffe <sjaffe at riskspan.com> a écrit :
> On Tuesday, June 11, 2013 3:02 PM, Romain Francois wrote:
>> Maintaining the idea that this external pointer acts as a numeric vector without being one.
>>
>> What happens then you want its mean, its quantile or whatever. You essentially have to reimplement everything.
>>
>> So yes : can be done, but lots of work.
>
> I don't yet know enough about R internals to say, but in principle it seems that if you have the subscript operator you'd be able to do practically any statistical calculation. Without re-implementing anything.
Not at all even kind of close. What you describe here has nothing to do with R.
> (One might also need elementwise addition, multiplication by scalars, etc -- though in principle these can all be defined in terms of subscripting, I assume that R has specialized versions of these for atomic vectors due to performance. But in any case a relatively small number of fundamental operations ought to be enough to make something "act like" a vector. And this is exactly what Krzysztof provided the basics of.)
>
> When I say 'in principle' I'm thinking along the lines of C++ generics -- if I have an object that overloads the subscript operator, then any algorithm that just uses subscripting will simply work. Whether that is true in R I'm not certain, but what I think I know of the idea of generics and class-specific dispatch seems consistent with that picture.
>
> If this is not the case then the object hasn't fulfilled what I mean by "acting like" a numeric vector.
More information about the Rcpp-devel
mailing list