Displaying 20 results from an estimated 600 matches similar to: "not safe to return vector pointer"
2000 Apr 01
1
Bug ? mine or ? in R core
Dear R Gurus,
I would very much appreciate some help with this code snippit
from my RODBC package.
R crashes or exhibits bizarre behaviour when repeatedly fetching
large numbers of rows.
Examples:
> odbcFetchRows(0,max=50000)->xx
> odbcFetchRows(0,max=50000)->xx
> odbcFetchRows(0,max=50000)->xx
> odbcFetchRows(0,max=50000)->xx
> odbcFetchRows(0,max=50000)->xx
3rd
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
2011 Jan 26
2
Dealing with R list objects in C/C++
Hi,
I'd like to construct an R list object in C++, fill it with relevant data, and pass it to an R function which will return a different list object back. I have browsed through all the R manuals, and examples under tests/Embedding, but can't figure out the correct way. Below is my code snippet:
#include <Rinternals.h>
// Rf_initEmbeddedR and other setups already performed
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
2003 Dec 10
0
C++: SET_LENGTH() Over Many Iterations?
In a C++ extension to R (v 1.8.1), I've been experimenting with a
generic "push back" function to tack one value at a time onto the end
of an R vector created within the extension. After calling this
function a certain number of times Rgui.exe (I'm writing in Windows
using Visual Studio .NET 2003) will fail with an Access Violation,
which doesn't happen when I pre-allocate
2004 Jan 09
1
Call and memory
I use a large real matrix, X, in C code that is passed from R and
transposed in place in the C code. I would like to conserve memory and,
if possible, allocate space for only one copy of X -- hence I would like
to pass a pointer to the data in the X object to the C code.
The Writing R Extensions manual says that neither .Call nor .External
copy their arguments. They also say that these
2013 Mar 01
2
[LLVMdev] Interesting post increment situation in DAG combiner
Hal, (and everyone who might care about post increment generation)...
I have an interesting question/observation. Consider this vector loop.
void vec_add_const(unsigned N, short __attribute__ ((aligned (16))) *A,
short __attribute__ ((aligned (16))) val)
{
unsigned i,j;
for (i=0; i<N; i++) {
for (j=0; j<N; j++) {
A[i*N+j] += val;
}
}
}
The
2013 Mar 01
0
[LLVMdev] Interesting post increment situation in DAG combiner
----- Original Message -----
> From: "Sergei Larin" <slarin at codeaurora.org>
> To: "Hal Finkel" <hfinkel at anl.gov>
> Cc: llvmdev at cs.uiuc.edu
> Sent: Friday, March 1, 2013 10:24:39 AM
> Subject: Interesting post increment situation in DAG combiner
>
> Hal, (and everyone who might care about post increment generation)...
Sergei,
Perhaps
2013 Mar 01
1
[LLVMdev] Interesting post increment situation in DAG combiner
Hal,
Here is my patch for the post inc case. I think it is symmetrically applicable to the pre-inc, but I have not tested it for that.
I think you can clearly see my intent here - I simply select the "latest" candidate when multiple are available.
Who else might be interested in this?
Sergei
---
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The
2005 May 17
1
returning an empty list.
I would like to return an empty list from a C function. This I would do as:
if (file.exists()) {
/* do something */
}
else {
SEXP empty_list;
PROTECT(empty_list = NEW_LIST(0));
UNPROTECT(1);
return empty_list;
}
The PROTECT, UNPROTECT lines seemed like overkill to me, but as far as I
understood the documentation this seemed like the correct usage. It
seems like I could
2008 Nov 30
1
Rserve and creating a list of lists
Hello,
I have some code which generates lattice objects. The function
recieves serialized forms of the lattice objects which it then
unserializes and then adds to an ArrayList<REXP>.
REXPRaw rser = new REXPRaw( target ); //target contains the raw
serialized forms of lattice objects
rconn.assign("temp",rser);
REXP ret =
2017 Oct 28
2
Cannot Compute Box's M (Three Days Trying...)
Hey Duncan,
Hard to debug? That's an understatement. Eyes bleeding....
In any case, I tried all your suggestions. To get "integer" for the final column, I had to change the code to get integers instead of strings.
double[] d1 = ((REXPVector) ((RList) tableRead).get(0)).asDoubles();
double[] d2 = ((REXPVector) ((RList) tableRead).get(1)).asDoubles();
double[] d3 = ((REXPVector)
2005 Jul 12
1
allocation of large matrix failing
Hello, this is probably something silly which I am doing, but I cannot
understand why this allocation is not happening.
Here is a my C code which tries to allocate a list of size 333559, and
then a matrix of size 8*333559
I thought I might be running into memory problems, but R is not even
using that much (I start R with
more memory and it stays constant) Also, I start R as I normally do and
I
2013 Apr 01
2
Timing of SET_VECTOR_ELT
Assume a C program invoked by .Call, that returns a list.
Near the top of the program we allocate space for all the list elements. (It is my habit
to use "xyz2" for the name of the R object and "xyz" for the pointer to its contents.)
PROTECT(means2 = allocVector(REALSXP, nvar));
means = REAL(means2);
PROTECT(u2 = allocVector(REALSXP, nvar));
u =
2017 Oct 27
4
Cannot Compute Box's M (Three Days Trying...)
It can't be this hard, right? I really need a shove in the right direction here. Been spinning wheels for three days. Cannot get past the errors.
I'm doing something wrong, obviously, since I can easily compute the Box's M right there in RStudio
But I don't see what is wrong below with the coding equivalent.
The entire code snippet is below. The code fails below on the call to
2017 Oct 29
2
Cannot Compute Box's M (Three Days Trying...)
Thanks Duncan. I can't tell you how helpful all your terrific replies have been.
I think the biggest surprise is that nobody appears to be using Java and R together like I"m trying to do. I suppose it should be a surprise since there are no books on the subject and almost no technical documentation other than a few sites here and there.
-----
I originally had the "int" as the
2017 Oct 28
2
Cannot Compute Box's M (Three Days Trying...)
I'm not sure what you mean. Could you please be more specific?
If I print the string, I get: boxM(boxMVariable[, -5], boxMVariable[, 5])
From this code:
.
.
.
// assign the data to a variable.rConnection.assign("boxMVariable", myDf);
// create a string command with that variable name.String boxVariable = "boxM(boxMVariable[, -5], boxMVariable[, 5])";
2017 Oct 28
2
Cannot Compute Box's M (Three Days Trying...)
Thanks Duncan. Awesome ideas!
I think we're getting closer!
I tried what you suggested and got a possibly better error...
.
.
.
rConnection.assign("boxMVariable", myDf);
String resultBV = "str(boxMVariable)"; // your suggestion.
RESULTING ERROR:
Error in format.default(nam.ob, width = max(ncn), justify = "left") : invalid 'width' argument
(No idea
2003 Nov 18
1
How to return a big treelike list from .Call Interface (protect stack overflow)
I try to create a big treelike list structure using the RDefines/RInternal
macros. The tree carries information at each node (attribute list) and at each
leaf (vector).
My understanding is that for each node I add to the binary tree I have to
call
PROTECT(newnode = NEW_LIST(2));
and cannot UNPROTECT before I return the whole tree. Same story for node
attributes and leaf vectors. However, this
2006 May 08
1
Calling C++ code fom R --How to export C++ "unsigned" integer to R?
Hello all,
Is there a way to export C++ "unsigned" integer to R? (I am trying to parse
files in "BPMAP" format, and some variables are of type unsigned int (first
declared in C++) ).
I know that to export signed integer to R,
I can do the following in C++:
int Some_INTEGER = 5;
int *p_myInt;
SEXP myInt;
PROTECT(myInt=NEW_INTEGER(1));
myInt[0] = Some_INTEGER;