I think x, y, and weights are in my case not necessarily SEXPs, but can be 
(i.e., some of them are pure Armadillo colvecs, while others are created from a 
NumericVector without copying its contents).

Davor


On 2010-05-11, at 1:25 PM, Romain Francois wrote:

> 
> Thanks for letting us know of the problem ... and the solution
> 
> Not sure what the problem is. The _["x"] =  is intended for implicit calls to 
> wrap, but it should not trouble you if you make them explicit. maybe we did 
> not handle properly the special case where the rhs is already a SEXP.
> 
> Will have a look when I get a chance.
> 
> Thanks.
> 
> Romain
> 
> Le 11/05/10 22:17, Davor Cubranic a écrit :
>> 
>> Hmm, once I stopped using 'wrap' and just passed Armadillo objects using 
>> 'Named', I'm able to run unit tests with no errors.
>> 
>> I.e., I now use:
>> 
>>   List data = List::create(_["x"] = x,
>>                         _["y"] = y);
>>   const NumericVector out_r = predict_fn(loess_fn(formula_fn("y~x"),
>>                                                data,
>>                                                _["weights"] = weights,
>>                                                _["span"] = span));
>> 
>> Could the issue really have been caused my using 'wrap'? What does 'wrap' do 
>> that would lead to a segfault, that I now avoid by using 'Named'?
>> 
>> Davor
>> (R 2.10.1, Rcpp 0.7.11, Armadillo 0.9.4)
>> 
>> 
>> On 2010-05-11, at 12:35 PM, Davor Cubranic wrote:
>> 
>>> Can anyone tell me about issues I have to look out for when dealing with 
>>> Rcpp Functions and passing Armadillo objects as arguments? I'm getting "not 
>>> compatible with INTSXP" and segfault errors when calling the following Rcpp 
>>> equivalent of R's 'predict(loess(y~x, weights=w, span=span))'. The errors 
>>> usually only manifest only after several dozen calls.
>>> 
>>> Davor
>>> 
>>> 
>>> const vec predict(const vec&  x, const vec&  y,
>>>                     const vec&  weights, const double span) {
>>>  Function formula_fn("formula");
>>>  Function loess_fn("loess");
>>>  Function predict_fn("predict");
>>> 
>>>  List data = List::create(_["x"] = wrap(x),
>>>                        _["y"] = wrap(y));
>>>  NumericVector weights_r = wrap(weights);
>>>  const NumericVector out_r = predict_fn(loess_fn(formula_fn("y~x"),
>>>                                               data,
>>>                                               weights_r,
>>>                                               Named("span") = span));
>>>  const vec out = vec(out_r.begin(), out_r.size());
>>>  return out;
>>> }
> 
> 
> 
> -- 
> Romain Francois
> Professional R Enthusiast
> +33(0) 6 28 91 30 30
> http://romainfrancois.blog.free.fr
> |- http://bit.ly/9aKDM9 : embed images in Rd documents
> |- http://tr.im/OIXN : raster images and RImageJ
> |- http://tr.im/OcQe : Rcpp 0.7.7
> 

_______________________________________________
Rcpp-devel mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Reply via email to