Rf_ScalarComplex: Rf_ScalarComplex

Description Arguments Value Declaration Definition Examples

Description

\Sexpr[results=rd, stage=render]{c3po:::badge('fnp')} \Sexpr[results=rd, stage=render]{c3po:::badge('c2r')} \Sexpr[results=rd, stage=render]{c3po:::badge('prot')}

Converts an Rcomplex x to a SEXP object that represents an R length one complex vector.

Arguments

x

an Rcomplex object.

Value

A SEXP object, namely a length one complex vector.

Declaration

1

In Rinternals.h.

Definition

1
2
3
4
5
6
INLINE_FUN SEXP ScalarComplex(Rcomplex x)
{
  SEXP ans = allocVector(CPLXSXP, 1);
  SET_SCALAR_CVAL(ans, x);
  return ans;
}

In Rinlinedfuns.h.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# 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;
 ')
scalar_complex()

ramiromagno/c3po documentation built on Jan. 5, 2021, 8:01 p.m.