[Rcpp-devel] SUGAR: Vector-Scalar operations

Cedric Ginestet c.ginestet05 at googlemail.com
Wed Dec 22 12:04:01 CET 2010


Perfect. You were correct. It was just to do with my compiler. It worked.
For future reference, my compiler's version is:
gcc 4.4.3

Cheers,
Cedric

On 22/12/10 10:49, romain at r-enthusiasts.com wrote:
> Hmm. It works for me :
>
> romain@ /tmp $ Rscript scalar.R
> Le chargement a nécessité le package : Rcpp
> Le chargement a nécessité le package : methods
> Le chargement a nécessité le package : inline
>    [1]  0.118499288 -1.817607621 -0.222048483 -1.237370127 -0.311005542
>    [6] -1.171129611 -1.762177277  0.134816230 -2.230150904 -1.736497106
>   [11] -1.577510938 -1.858586669  0.079285891 -3.466982811  0.219942848
>   [16] -1.374955508  0.534610385 -0.188049657 -0.239022351 -0.329254539
>   [21]  1.150376610 -0.990762235 -0.070175505 -0.445601007 -0.099297762
>   [26] -0.287019364 -3.389394113 -1.993029377 -1.590514545 -1.065722302
>   [31] -3.460952157 -1.867655599  0.229615701 -0.410936745  1.117024762
>   [36] -0.487425696 -1.145210714  1.024045071 -0.737104441  0.518910679
>   [41] -0.665078071 -1.406334488  0.125085776 -2.371727343 -1.279575397
>   [46] -2.305043859 -2.147031987 -0.755815063 -0.067598214 -0.458736436
>   [51] -0.171158608  0.744965097  0.425070016 -1.185900552  0.179289788
>   [56] -0.847640835 -0.258556630  0.605688949 -0.717832015 -0.168420487
>   [61]  0.243449273 -0.692708676 -0.945844306 -1.316996351 -0.280337423
>   [66] -1.950979808 -1.405278438 -1.048402157 -1.029075325 -1.706454756
>   [71]  0.169759087 -0.612959584 -0.659272696 -2.973512678 -0.976065052
>   [76] -1.646860959 -1.596064263 -2.711273537 -3.959144495 -0.664824533
>   [81] -2.379473770 -2.577303097 -2.770794150 -1.576718619 -2.730671467
>   [86] -0.555793202 -0.505486723  0.424688418 -1.532137692 -3.360660142
>   [91] -1.001758355 -1.815617351 -2.361497560 -0.390096800  0.004245176
>   [96] -0.665323212 -1.332042011 -2.352568749  0.313995354 -0.393143654
>
> Can you try to replace "1" by "1.0" ?
>
> You might have a more recent compiler version that is stricter than mine (OSX / gcc 4.2.1).
>
> Romain
>
>   Le mer 22/12/10 10:39, "Cedric Ginestet" c.ginestet05 at googlemail.com a écrit:
>> Dear Rcpp experts,
>> I've got another problem related to Rcpp Sugar. Basically, I would
>> like to have the same functionality that you get from R's vectors,
>> where binary operations with scalars are automatically interpreted as
>> elementwise operations. See the following code and error message:
>>
>> ###########################################
>> VectorScalar  Rcpp::NumericVector xV(x);
>> xV = xV - 1;
>> return(xV);
>> ',plugin="Rcpp")
>> VectorScalar(rnorm(100))
>>
>> file3165a3be.cpp: In function 'SEXPREC* file3165a3be(SEXPREC*)':
>> file3165a3be.cpp:32: warning: ISO C++ says that these are ambiguous,
>> even though the worst conversion for the first is better than the
>> worst conversion for the second:
>> ##########################################
>>
>> Thank you very much for your help,
>>
>> -- 
>> Cedric Ginestet
>> Centre for Neuroimaging Sciences (L3.04)
>> NIHR Biomedical Research Centre
>> Department of Neuroimaging
>> Institute of Psychiatry, Box P089
>> King's College London
>> De Crespigny Park
>> London
>> SE5 8AF
>> Tel: (+44) 20-3228-3052
>> Fax: (+44) 20-3228-2116
>> Email: cedric.ginestet at kcl.ac.uk
>>
>>
>>


More information about the Rcpp-devel mailing list