[Rcpp-devel] Rcpp-devel Digest, Vol 14, Issue 17

Romain Francois romain at r-enthusiasts.com
Sun Dec 5 09:26:01 CET 2010


Le 05/12/10 03:50, Christian Gunning a écrit :
> On Sat, Dec 4, 2010 at 7:35 AM,
> <rcpp-devel-request at lists.r-forge.r-project.org>  wrote:
>> While I am on this, would it be valuable to have something like this:
>>
>> typedef SubMatrix<REALSXP>  NumericSubMatrix ;
>>
>> or perhaps inside Matrix we could have:
>>
>> typedef typename SubMatrix<RTYPE>  sub ;
>>
>> So that we would write
>>
>> NumericMatrix::sub yy = xx( Range(0,2), Range(0,3) )
>
> Looks nice.  I was wondering about that.

I was just enquiring about it. This is not commited yet.

> Question -
>
> Is there a simple example where the following differ?  I looked at the
> source, and it looks to me that MatrixColumn, MatrixRow, and SubMatrix
> objects are still tied to the original Matrix object (example 1),

That definitely is the intention.

> whereas example 2 creates an entirely new object.  I don't understand
> the exact consequences of this.  Am I correct in assuming that A, 1
> does not make a new copy, and that B, modifications to the SubMatrix
> object propogate back to the underlying Matrix?

yes.

> 1) NumericMatrix::sub yy1 = xx( Range(0,2), Range(0,3) )
>
> 2) NumericMatrix: yy2 = xx( Range(0,2), Range(0,3) )
>
> thanks,
> Christian

-- 
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://bit.ly/gpCSpH : Evolution of Rcpp code size
|- http://bit.ly/hovakS : RcppGSL initial release
`- http://bit.ly/iaxTdO : parser 0.0-12




More information about the Rcpp-devel mailing list