From saptarshi.guha at gmail.com  Mon May 20 19:35:35 2013
From: saptarshi.guha at gmail.com (Saptarshi Guha)
Date: Mon, 20 May 2013 10:35:35 -0700
Subject: [Rd] Accessing i'th element of a vector without using a macro
In-Reply-To: <CADwqtCNDS3yCT39c0OLqkeu_9x9xSPjeRkp8psSmm99LsMjE9Q@mail.gmail.com>
References: <CAJDot1oyZXenjk=zgj28Oj2BqBTdM+UmjN6TMi9TJNz0DDGS=Q@mail.gmail.com>
	<CADwqtCNDS3yCT39c0OLqkeu_9x9xSPjeRkp8psSmm99LsMjE9Q@mail.gmail.com>
Message-ID: <CAJDot1qRHSRbHeQPjUJ6cfJn9xz86-ut7WdiXpw5Dj8uD07okw@mail.gmail.com>

Exactly, that is what i use. I intend to do the operation using an FFI
library(i't s just a proof of concept, and there well might be
performance hits)
If such a function doesn't exist in libR.so, then i can write one.

Regards
Saptarshi


On Mon, May 20, 2013 at 10:03 AM, Gabriel Becker <gmbecker at ucdavis.edu> wrote:
> Saptarshi,
>
> When I need to repeatedly access data from a an R vector in C I typically
> just create a pointer to the data and just use that.
>
> double *xdat = REAL(x);
> xdat[i]; //repeat as necessary
>
> This is also displayed in 5.9.4 of the R extensions manual.
>
> Is there a reason this wouldn't work for your usecase? What exactly is it
> that you want to do?
>
> ~G
>
>
>
>
> On Mon, May 20, 2013 at 9:56 AM, Saptarshi Guha <saptarshi.guha at gmail.com>
> wrote:
>>
>> Hello,
>>
>> I have a double vector, x. I can access the i'th element as
>>
>> REAL(x)[i]
>>
>> Is there a function for this? I know i can write my own, but was
>> seeing if one already exists. I did check Rinternals.h but didn't see
>> one.
>>
>> Cheers
>> Saptarshi
>>
>> ______________________________________________
>> R-devel at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>
>
>
> --
> Gabriel Becker
> Graduate Student
> Statistics Department
> University of California, Davis



[Rd] Accessing i'th element of a vector without using a macro
Saptarshi Guha