Rf_ScalarComplex.Rd
x | an |
---|
A SEXP
object, namely a length one complex
vector.
SEXP Rf_ScalarComplex(Rcomplex x);
In Rinternals.h.
INLINE_FUN SEXP ScalarComplex(Rcomplex x) { SEXP ans = allocVector(CPLXSXP, 1); SET_SCALAR_CVAL(ans, x); return ans; }
In Rinlinedfuns.h.
# Convert a C complex number to an R length one complex vector scalar_complex <- inline::cfunction(NULL, 'double real = 1.; double imaginary = 2.; Rcomplex x; x.r = real; x.i = imaginary; SEXP y; y = PROTECT(Rf_ScalarComplex(x)); UNPROTECT(1); return y; 'double real = 1.; double imaginary = 2.; Rcomplex x; x.r = real; x.i = imaginary; SEXP y; y = PROTECT(Rf_ScalarComplex(x)); UNPROTECT(1); return y; ') scalar_complex()#> [1] 1+2i