Displaying 8 results from an estimated 8 matches for "integer_point".
Did you mean:
integer_pointer
2013 Jun 27
3
Read a text file into R with .Call()
Hi,
I want to read a text file into R with .Call().
So I define some NEW_CHARACTER() to store the chracters read and use SET_STRING_ELT to fill the elements.
e.g.
PROTECT(qNames = NEW_CHARACTER(10000));
char *foo; // This foo holds the string I want.
while(foo = readLine(FN)){
SET_STRING_ELT(qNames, i, mkChar(foo)));
}
In this way, I can get the desired character from qNames. The only problem
2004 Feb 11
1
.Call setAttrib(ans,R_DimSymbol,dim); Crashes.
...n a matrix.
The code does the R interfacing.
This version does it fine.
SEXP ans,dim;
PROTECT(ans = NEW_NUMERIC(count*2));
memcpy(NUMERIC_POINTER(ans),result,count*sizeof(double));
memcpy(&(NUMERIC_POINTER(ans)[count]),occur,count*sizeof(double));
/** PROTECT(dim=NEW_INTEGER(2));
INTEGER_POINTER(dim)[0]=2;
INTEGER_POINTER(dim)[1]=count;
setAttrib(ans,R_DimSymbol,dim);
*/
UNPROTECT(7);
If I uncomment the lines 5 to 8 than all is working fine four small count's (tested 10,20).
But if the result is an array with about 2000 entries R crashes vicious and violently with the lax...
2005 Sep 13
3
NUMERIC_POINTER question
...ot;)
xx at data<-matrix(1:12+0.1,3,4). (data is double)
However it prints
0.0000
if xx at data are integers ( xx at data<-matrix(1:12,3,4) ).
Can anyone explain it to me why?
I thought that NUMERIC_POINTER makes it clear that i expect datatype numeric.
(Why otherwise the distinction with INTEGER_POINTER)
cheers
Eryk
2004 Jan 09
1
Call and memory
...point out the error in my thinking or suggest a way
to accomplish my goal?
My code follows:
"mListTest" <-
function(X,N,k) {
.Call("mList",as.double(X),as.integer(N),as.integer(k));
}
SEXP mList(
SEXP Xi,
SEXP Ni,
SEXP ki
)
{
double *pX=NUMERIC_POINTER(Xi);
int N=INTEGER_POINTER(Ni)[0];
int k=INTEGER_POINTER(ki)[0];
SEXP alist;
SEXP avector;
SEXP nvector;
SEXP rvector;
SEXP kvector;
int n;
int i;
transposeMatrix(pX,N,k);
n=4;
PROTECT(alist=NEW_LIST(n));
PROTECT(avector=NEW_NUMERIC(200));
for (i=0;i<200;i++) {
NUMERIC_POINTER(avector)[i]=pX[i];
}
SE...
2003 Dec 10
0
C++: SET_LENGTH() Over Many Iterations?
...R object too
big to be handled by R within the context of my OS's available memory.
Here's some simple test code I've been running:
<CPP Code>
#define PUSH_BACK_INTEGER(v, x) \
do {\
UNPROTECT_PTR(v);\
SET_LENGTH(v, GET_LENGTH(v) + 1);\
PROTECT(v);\
INTEGER_POINTER(v)[GET_LENGTH(v) - 1] = x;\
}\
while (false)
SEXP R_SimplePushBackTest(SEXP args)
{
SEXP arg1, arg2, int_vect;
PROTECT(arg1 = AS_INTEGER(CADR(args)));
int n_reps = INTEGER_POINTER(arg1)[0];
PROTECT(arg2 = AS_LOGICAL(CADDR(args)));
bool full_alloc = (LOGICAL_POINT...
2005 Apr 14
1
question about "R get vector from C"
...:
/* useCall3.c */
/* Getting an integer vector from C using .Call */
#include <R.h>
#include <Rdefines.h>
SEXP setInt() {
SEXP myint;
int *p_myint;
int len = 5;
PROTECT(myint = NEW_INTEGER(len)); // Allocating storage space
p_myint = INTEGER_POINTER(myint);
p_myint[0] = 7;
UNPROTECT(1);
return myint;
}
then type at the command prompt:
R CMD SHLIB useCall3.c
to get useCall3.so
In windows platform ,how can I create right dll to let dyn.load use
and for .c ,.call ,external ,what are the differece? which one is better for
getting ve...
2003 Dec 12
3
C++: Appending Values onto an R-Vector.
Hi folks. I posted this question a few days ago, but maybe it got lost
because of the code I included with it. I'm having a problem using the
SET_LENGTH() macro in an R extension I'm writing in C++. In a function
within the extension I use SET_LENGTH() to resize R vectors so as to
allow the concatenation of single values onto the vectors -- it's a
"push back" function to
2004 Jun 22
3
[Q] GET_DIM() crash on Windows only
...indoze ******/
PROTECT(vntXdim = GET_DIM(vntX));
#ifdef DEBUG_GETDIM
REprintf("\tgot dimension object\n");
#endif
nX = GET_LENGTH(vntXdim);
#ifdef DEBUG_GETDIM
REprintf("\tgot length from dimension object\n");
#endif
if (nX == 2)
{
int *piXdim = INTEGER_POINTER(vntXdim);
*nrow = piXdim[0];
*ncol = piXdim[1];
}
else
{
*nrow = -1;
*ncol = -1;
}
UNPROTECT(1);
return nX;
}
SEXP getdim(SEXP vntX)
{
SEXP vntOut;
int m, n;
#ifdef DEBUG_GETDIM
REprintf("In getdim(x)...\n");
#endi...