-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathR_wrapper.h
More file actions
52 lines (41 loc) · 1.13 KB
/
R_wrapper.h
File metadata and controls
52 lines (41 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#ifndef __AF_R_WRAPPER_H
#define __AF_R_WRAPPER_H
#include <R.h>
#include <Rdefines.h>
#undef eval // defined in Rinternals.h
#include <arrayfire.h>
#include <af/util.h>
#ifdef __cplusplus
#define EXTERNC extern "C" SEXP
#endif
typedef struct {
float x;
float y;
} afr_cfloat;
typedef struct {
double x;
double y;
} afr_cdouble;
#define IntPtr(x, idx) (INTEGER(x) + idx)
#define RealPtr(x, idx) (REAL(x) + idx)
#define CplxPtr(x, idx) (afr_cdouble *)(COMPLEX(x) + idx)
static inline afr_cfloat GetCfloat(SEXP x, int idx)
{
afr_cdouble tmp = *CplxPtr(x, idx);
afr_cfloat res = {tmp.x, tmp.y};
return res;
}
af_array getPtr(SEXP S);
void getDims(unsigned *ndims,
dim_t dims[4],
SEXP _dims);
SEXP getSEXP(af_array arr);
#define AF_CHECK(fn) do { \
af_err err = fn; \
if (err == AF_SUCCESS) break; \
char *err_msg; \
dim_t len = 0; \
af_get_last_error(&err_msg, &len); \
error_return(err_msg); \
} while(0)
#endif