search for: sexp

Displaying 20 results from an estimated 924 matches for "sexp".

Did you mean: sep
2009 Sep 07
1
Usage of OCaml/R binding.
...types;; > # #require "R";; > # module X = R;; > module X : > sig > external init_r : string array -> int = "init_r" > val init : ?argv:string array -> unit -> int > external terminate : unit -> unit = "end_r" > type sexp = R.sexp > type symbol = string > type arg = [ `Anon of sexp | `Named of sexp * symbol ] > external sexp : string -> sexp = "r_sexp_of_string" > external sexp_of_symbol : symbol -> sexp = "r_sexp_of_symbol" > external set_var : symbol -&g...
2009 Sep 07
1
Usage of OCaml/R binding.
...types;; > # #require "R";; > # module X = R;; > module X : > sig > external init_r : string array -> int = "init_r" > val init : ?argv:string array -> unit -> int > external terminate : unit -> unit = "end_r" > type sexp = R.sexp > type symbol = string > type arg = [ `Anon of sexp | `Named of sexp * symbol ] > external sexp : string -> sexp = "r_sexp_of_string" > external sexp_of_symbol : symbol -> sexp = "r_sexp_of_symbol" > external set_var : symbol -&g...
2013 Aug 27
1
Error in simulation. NAN
...lude <iostream> #include <string> using namespace std; #include <R.h> #include <Rinternals.h> #include <R_ext/Linpack.h> #include <R_ext/Lapack.h> #include <R_ext/BLAS.h> #include "funzioni.h" #define _USE_MATH_DEFINES extern "C" { SEXP Model1_imp11Cpp( SEXP ad_start_r, SEXP ad_end_r, SEXP ad_esp_r, SEXP burnin_r, SEXP thin_r,SEXP iter_1_r,SEXP iter_2_r, SEXP n_j_r,SEXP J_r, SEXP prior_alpha_r,SEXP prior_rho_r,SEXP prior_sigma2_r,SEXP prior_phi_r,SEXP prior_zeta2_r, SEXP sdprop_rho_r,SEXP sdprop_sigma2_r, SEXP s...
2018 Oct 10
1
unlockEnvironment()?
...k.c-21-#define FRAME_LOCK_MASK (1 << 14) ./pkgload/src/unlock.c:22:#define FRAME_IS_LOCKED(e) (ENVFLAGS(e) & FRAME_LOCK_MASK) ./pkgload/src/unlock.c:23:#define UNLOCK_FRAME(e) SET_ENVFLAGS(e, ENVFLAGS(e) & (~FRAME_LOCK_MASK)) ./pkgload/src/unlock.c-24- ./pkgload/src/unlock.c-25-extern SEXP R_TrueValue; ./SOD/src/tmp.cpp-11394-SEXP (ENCLOS)(SEXP x); ./SOD/src/tmp.cpp-11395-SEXP (HASHTAB)(SEXP x); ./SOD/src/tmp.cpp:11396:int (ENVFLAGS)(SEXP x); ./SOD/src/tmp.cpp:11397:void (SET_ENVFLAGS)(SEXP x, int v); ./SOD/src/tmp.cpp-11398-void SET_FRAME(SEXP x, SEXP v); ./SOD/src/tmp.cpp-11399-voi...
2007 Nov 15
1
Nested SEXP functions
...large, so I'm trying to create a brief example. Yet before I do, I thought maybe a conceptual question would be sufficient. Basically, I'm writing up a multidimensional Gaussian likelihood (with spatial covariances and other enhancements). What I'm noticing is that when I have nested SEXP functions I get inconsistent results. Here is what I am essentially trying to accomplish when looking at the Gaussian kernel: l(beta) = (y-X*beta)^T V^{-1} (y-X*beta) Now in order to accomplish this, I wrote various linear algebra subroutines to handle the R objects, we'll call this: SEXP X...
2014 Mar 05
1
[PATCH] Code coverage support proof of concept
...ls.c --- R-devel/src/library/utils/src/utils.c 2012-10-01 17:52:17.000000000 +0200 +++ R-devel-cov/src/library/utils/src/utils.c 2014-03-03 16:24:06.259419131 +0100 @@ -27,6 +27,22 @@ #include "utils.h" /* from src/main/eval.c */ +void do_Rcov_start(int nb_lines, double growth_rate); +SEXP do_Rcov_stop(void); + +SEXP Rcov_start(SEXP args) +{ + do_Rcov_start(asInteger(CADR(args)), asReal(CADDR(args))); + return R_NilValue; /* -Wall */ +} + + +SEXP Rcov_stop(void) +{ + return do_Rcov_stop(); +} + +/* from src/main/eval.c */ SEXP do_Rprof(SEXP args); SEXP Rprof(SEXP args)...
2020 Sep 11
4
Garbage collection of seemingly PROTECTed pairlist
...and then I call Rf_PairToVectorList() at the end to make it into a regular list. I'm getting a strange garbage collection error. My PROTECTed pairlist prlst gets garbage collected away and causes a memory leak error when I try to access it. Here's my code. #include <Rinternals.h> SEXP C_int_mat_nth_row_nrnc(int *int_mat_int, int nr, int nc, int n) { SEXP out = PROTECT(Rf_allocVector(INTSXP, nc)); int *out_int = INTEGER(out); if (n <= 0 | n > nr) { for (int i = 0; i != nc; ++i) { out_int[i] = NA_INTEGER; } } else { for (int i = 0; i != nr; ++i) {...
2014 Jul 07
2
a question about optim.R and optim.c in R
...m.R, after all the prep steps, the main function call call is made via : .External2(C_optim, par, fn1, gr1, method, con, lower, upper). So, it seems to me, to follow what is going on from here, that I should read the optim function in \src\library\stats\src\optim.c where it has this signature : SEXP optim(SEXP call, SEXP op, SEXP args, SEXP rho) I am not sure I follow here : In the .External2 call, we have 7 parameters : par, fn1, gr1, method, con, lower, upper; This does not seem to match the signature of SEXP optim(SEXP call, SEXP op, SEXP args, SEXP rho) However, it seems (from the sour...
2010 Sep 08
0
Correction to vec-subset speed patch
...= RAW(x)[ii]; + break; + default: + errorcall(call, R_MSG_ob_nonsub, type2char(mode)); } + return result; } @@ -210,12 +214,54 @@ return result; } +/* Used in MatrixSubset to set a whole row or column of a matrix to NAs. */ +static void set_row_or_col_to_na (SEXP result, int start, int step, int end, + SEXP call) +{ + int i; + switch (TYPEOF(result)) { + case LGLSXP: + for (i = start; i<end; i += step) + LOGICAL(result)[i] = NA_LOGICAL; + break; + case INTSXP: + for (i = start;...
2007 Jul 10
1
How to preserve data across function calls in a library package
...**after** having called do_kNN_e) i get the aforementioned error. Can anyone provide some pointers (no pun intended) on this? Thanks Saptarshi ANN* book; int* foot; void foo(void){ Rprintf("many times\n"); Rprintf("%p\n",book); Rprintf("%p\n",foot); } SEXP kNN_e(SEXP data, SEXP Nrow, SEXP Ncol,SEXP K,SEXP Eps) { int nrow=asInteger(Nrow); int ncol=asInteger(Ncol); int k=asInteger(K); double eps=asReal(Eps); SEXP ans,distance; SEXP retlist; PROTECT(ans=allocMatrix(INTSXP,nrow,k)); //The 2nd argument gives the number of rows, and...
2007 Jul 10
1
How to preserve data across function calls in a library package
...**after** having called do_kNN_e) i get the aforementioned error. Can anyone provide some pointers (no pun intended) on this? Thanks Saptarshi ANN* book; int* foot; void foo(void){ Rprintf("many times\n"); Rprintf("%p\n",book); Rprintf("%p\n",foot); } SEXP kNN_e(SEXP data, SEXP Nrow, SEXP Ncol,SEXP K,SEXP Eps) { int nrow=asInteger(Nrow); int ncol=asInteger(Ncol); int k=asInteger(K); double eps=asReal(Eps); SEXP ans,distance; SEXP retlist; PROTECT(ans=allocMatrix(INTSXP,nrow,k)); //The 2nd argument gives the number of rows, and...
2005 Aug 22
2
RFC: "loop connections"
...5-08-22 15:54:03.156038200 -0700 @@ -1644,13 +1644,13 @@ return ans; } -/* ------------------- text connections --------------------- */ +/* ------------------- loop connections --------------------- */ /* read a R character vector into a buffer */ static void text_init(Rconnection con, SEXP text) { int i, nlines = length(text), nchars = 0; - Rtextconn this = (Rtextconn)con->private; + Rloopconn this = (Rloopconn)con->private; for(i = 0; i < nlines; i++) nchars += strlen(CHAR(STRING_ELT(text, i))) + 1; @@ -1668,19 +1668,35 @@ this->cur = this->s...
2005 Sep 18
0
Updated rawConnection() patch
Here's an update of my rawConnection() implementation. In addition to providing a raw version of textConnection(), this fixes two existing issues with textConnection(): one is that the current textConnection() implementation carries around unprotected SEXP pointers, the other is a performance problem due to prolific copying of the output buffer as output is accumulated line by line. This new version uses a separate buffer for connection output, which is extended in larger chunks, so that resize operations are less frequent. And the buffer is hidden...
2014 Mar 03
1
reference classes, LAZY_DUPLICATE_OK, and external pointers
...- .Call(merPredDCreate, as(X, "matrix"), Lambdat, LamtUt, Lind, RZX, Ut, Utr, V, VtV, Vtr, Xwts, Zt, beta0, delb, delu, theta, u0) ... } merPredDCreate in turn just copies the relevant bits into a new C++ class object: /* see src/external.cpp */ SEXP merPredDCreate(SEXP Xs, SEXP Lambdat, SEXP LamtUt, SEXP Lind, SEXP RZX, SEXP Ut, SEXP Utr, SEXP V, SEXP VtV, SEXP Vtr, SEXP Xwts, SEXP Zt, SEXP beta0, SEXP delb, SEXP delu, SEXP theta, SEXP u0) { BEGIN_RCPP; mer...
2003 Oct 22
1
Windows RConsole Focus
...here? I tried implementing a quick solution (below) which seemes to work. Regards, James src/gnuwin32/rui.c ------------------ int winconsolefocus() { show(RConsole); return 0; } src/gnuwin32/rui.h ------------------ int winconsolefocus(void); src/gnuwin32/extra.c -------------------- SEXP do_winconsolefocus(SEXP call, SEXP op, SEXP args, SEXP rho) { SEXP ans; Rboolean success = TRUE; winconsolefocus(); PROTECT(ans = allocVector(LGLSXP, 1)); LOGICAL(ans)[0] = success; UNPROTECT(1); return ans; } src/main/names.c ---------------- {"winConsoleFocus&quo...
2009 Mar 19
1
.Internal
...list(maximum = val, objective = f(val, ...)) } else { val <- .Internal(fmin(function(arg) f(arg, ...), lower, upper, tol)) list(minimum = val, objective = f(val, ...)) } } Then I did a search for fmin and i came up with: /* fmin(f, xmin, xmax tol) */ SEXP attribute_hidden do_fmin(SEXP call, SEXP op, SEXP args, SEXP rho) So my question is where do I find the intermediary step between .Internal(fmin(function(arg) f(arg, ...), lower, upper, tol)) and SEXP attribute_hidden do_fmin(SEXP call, SEXP op, SEXP args, SEXP rho) The number of arguments...
2008 Mar 05
1
SEXP size management.
Hi, Trying to decrease the size of a SEXP variable without reassigning values individually in a loop. So far, I've tried using Realloc, as the follow source demonstrates: SEXP dothis() { SEXP Rblah; PROTECT(Rblah = NEW_INTEGER(6)); int* blah = INTEGER(Rblah); blah[0] = 1; blah[1] = 2; blah[2] = 3; Realloc(Rblah, 3, INTEGER);...
1998 Apr 02
1
attributes now inherited
...< 1 || n2 < 1) { ************************************************************************** *** attrib.c Mon Dec 8 02:36:53 1997 --- /net/aster/R/src/main/attrib.c Wed Apr 1 16:43:28 1998 *************** *** 114,119 **** --- 114,141 ---- return installAttrib(vec, name, val); } + SEXP copyMostAttrib(SEXP inp, SEXP ans) + { + /* This is called in the case of binary operations to copy most + attributes from (one of) the input arguments to the output. + Note that the Dim and Names attributes should have been assigned + elsewhere. */ + SEXP s, t, u; + + PR...
2017 Mar 29
3
Transferring ownership of R-managed buffer
I have a use case where I would like to create an SEXP around an existing buffer that is managed by R, thus avoiding a copy operation. If I have something like: void *p = (void*) RAW(PROTECT(Rf_allocVector(RAWSXP, n))); ... additional maniupulation ... SEXP x = somefunc(SXPTYPE, n, p); // ???? Is there a "placement" constructor available?...
2009 May 26
1
passing "..." arguments to a function called by eval()
...ction using "...". The code for my toy package looks like this: ########## R code, in pkg/R directory dTest <- function(x,...){ retVal = .Call("dTestC",x[1],dnorm,...,rho=new.env(),PACKAGE="pkg") return(retVal) } ########## C code, in pkg/src directory SEXP dTestC(SEXP dblX, SEXP funFn, SEXP dots, SEXP rho); /*--------------------------*/ SEXP dTestC(SEXP dblX, SEXP funFn, SEXP dots, SEXP rho){ SEXP retVal; SEXP R_fcall; PROTECT(retVal = NEW_NUMERIC(1)); PROTECT(R_fcall = lang3(funFn, R_NilValue, R_NilValue)); SETCADR(R_fcall, dblX);...