From murdoch.duncan at gmail.com  Mon Mar  2 13:01:09 2015
From: murdoch.duncan at gmail.com (Duncan Murdoch)
Date: Mon, 02 Mar 2015 07:01:09 -0500
Subject: [Rd] R-devel does not update the C++ returned variables
In-Reply-To: <CAHyAz7TOELUyX2XW=8Abvuz2tU0_ZXVuyx-B84RBk7TQyM-mAA@mail.gmail.com>
References: <CAHyAz7TOELUyX2XW=8Abvuz2tU0_ZXVuyx-B84RBk7TQyM-mAA@mail.gmail.com>
Message-ID: <54F45105.40608@gmail.com>

On 02/03/2015 3:50 AM, sarah manderni wrote:
> Hi,
> 
> Within my R code, I am using a C++ function as below:
> 
>      overlaps <- matrix(0, nrow=B, ncol=length(N))
>         overlaps.P <- matrix(0, nrow=B, ncol=length(N))
> 
>        .C("speedUp", D, S, pD, pS, nrow(D), as.integer(N), length(N),
>            ssq[i], i, as.integer(B), overlaps, overlaps.P, DUP=FALSE)
> 
> 
> the function "speedUp", is supposed to update matrices overlaps and
>  overlaps.P and it works with official R versions.
> However, using the same code in R-devel, it does not update matrices and
> they remain all zero without returning any errors.

See the NEWS:  DUP=FALSE is now ignored.  It led to too many bugs.  Use
the .Call interface if duplication causes problems.

Duncan Murdoch

> But, if I store the return values from C function in a variable lets say
> "test" as follows:
> 
> test <-        .C("speedUp", D, S, pD, pS, nrow(D), as.integer(N),
> length(N),
>            ssq[i], i, as.integer(B), overlaps, overlaps.P, DUP=FALSE)
> 
> then the corresponding element of test to matrix "overlaps"
> (test[["overlaps"]]) again has the updated values (correct non-zero values)
> though the overlaps matrix itself is still empty.
> 
> I mean in official R, the "overlaps" matrix is updated after calling the
> function but not in R-devel. Also it works in both environment and return
> correct values to variable "test" in R-devel as well.
> Did you face any similar problem so that R-devel does not update the
> variable returned by C++?
> 
> Thanks for the help.
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>



[Rd] R-devel does not update the C++ returned variables
Duncan Murdoch