search for: set_typeof

Displaying 4 results from an estimated 4 matches for "set_typeof".

Did you mean: set_type
2008 Feb 19
1
level of mutability for the type of a SEXP
Dear list, I am writing C code to interface with R, and I would like to know the level of mutability for the type of a SEXP. I see that there is a macro/function TYPEOF(), and that it can be used as an l-value, as well as a macro/function SET_TYPEOF(). My question is "should the type be considered immutable, or it can it change after the SEXP has been created and used for a while ?". I understand that a call to TYPEOF will not perform any conversion, and my question is only about being sure that once the type of a given SEXP is set...
2008 Apr 05
2
Adding a Matrix Exponentiation Operator
...eger")); e = asInteger(y); if (e < -1) error(_("exponent must be >= -1")); else if (e == 1) return x; else if (e == -1) { /* return matrix inverse via solve() */ SEXP p1, p2, inv; PROTECT(p1 = p2 = allocList(2)); SET_TYPEOF(p1, LANGSXP); CAR(p2) = install("solve.default"); p2 = CDR(p2); CAR(p2) = x; inv = eval(p1, rho); UNPROTECT(1); return inv; } PROTECT(matrix = allocVector(mode, nrows * ncols)); PROTECT(tmp = allocVector(mode, nrows * ncols));...
2008 Mar 29
0
"Writing R Extensions": bad example with CAR / CDR as lvalues (PR#11054)
...e even better. Just in case you want to use it as example, here is my code. I hope it is correct in your expert eyes. /* Remove the variable with name s from the environment ev, i.e. construct the call: rm( list=s, envir=ev ) */ SEXP call; PROTECT( call = Rf_allocList( 3 ) ); SET_TYPEOF( call, LANGSXP ); SETCAR( call, install( "rm" ) ); SETCAR( CDR(call), allocVector( STRSXP, 1 ) ); SET_STRING_ELT( CAR( CDR(call) ), 0, mkChar( s ) ); SET_TAG( CDR(call), install("list") ); SETCAR( CDDR(call), ev ); SET_TAG( CDDR(call), install(&quot...
2008 Mar 31
1
(PR#11054) "Writing R Extensions": bad example with CAR /
...u want to use it as example, here is my code. I hope it is > correct in your expert eyes. > > /* Remove the variable with name s from the environment ev, > i.e. construct the call: rm( list=s, envir=ev ) */ > > SEXP call; > PROTECT( call = Rf_allocList( 3 ) ); > SET_TYPEOF( call, LANGSXP ); > > SETCAR( call, install( "rm" ) ); > > SETCAR( CDR(call), allocVector( STRSXP, 1 ) ); > SET_STRING_ELT( CAR( CDR(call) ), 0, mkChar( s ) ); > SET_TAG( CDR(call), install("list") ); > > SETCAR( CDDR(call), ev ); > SET_TAG...