| 1 | /* |
| 2 | * Native routines registration, as per "Writing R extensions" and |
| 3 | * definition of native interfaces to two routines exported by |
| 4 | * package expint. |
| 5 | * |
| 6 | * This is derived from code in packages zoo and xts. |
| 7 | * |
| 8 | * Copyright (C) 2016 Vincent Goulet |
| 9 | * Copyright (C) 2010 Jeffrey A. Ryan jeff.a.ryan @ gmail.com |
| 10 | * |
| 11 | * This program is free software; you can redistribute it and/or |
| 12 | * modify it under the terms of the GNU General Public License as |
| 13 | * published by the Free Software Foundation; either version 3 of the |
| 14 | * License, or (at your option) any later version. |
| 15 | * |
| 16 | * This program is distributed in the hope that it will be useful, |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 19 | * General Public License for more details. |
| 20 | * |
| 21 | * You should have received a copy of the GNU General Public License |
| 22 | * along with this program; if not, write to the Free Software |
| 23 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
| 24 | * 02110-1301, USA. |
| 25 | * |
| 26 | * AUTHOR: Vincent Goulet <[email protected]> |
| 27 | */ |
| 28 | |
| 29 | #include <Rinternals.h> |
| 30 | #include <R_ext/Rdynload.h> |
| 31 | #include <expintAPI.h> /* this is actually optional */ |
| 32 | #include "pkg.h" |
| 33 | |
| 34 | /* This package uses the .External interface between R and C */ |
| 35 | static const R_ExternalMethodDef ExternalEntries[] = { |
| 36 | {"pkg_do_foo", (DL_FUNC) &pkg_do_foo, -1}, |
| 37 | {"pkg_do_bar", (DL_FUNC) &pkg_do_bar, -1}, |
| 38 | {NULL, NULL, 0} |
| 39 | }; |
| 40 | |
| 41 | /* Routine registration and native interfaces definitions. We prefix |
| 42 | * names with pkg_ to avoid name clashes with expintAPI.h. */ |
| 43 | void R_init_pkg(DllInfo *dll) |
| 44 | { |
| 45 | R_registerRoutines(dll, NULL, NULL, NULL, ExternalEntries); |
| 46 | |
| 47 | /* native interfaces to routines from package expint */ |
| 48 | pkg_expint_E1 = (double(*)(double,int)) R_GetCCallable("expint", "expint_E1"); |
| 49 | pkg_gamma_inc = (double(*)(double,double)) R_GetCCallable("expint", "gamma_inc"); |
| 50 | } |
| 51 | |
| 52 | /* Declaration of interfaces to routines from package expint */ |
| 53 | double(*pkg_expint_E1)(double,int); |
| 54 | double(*pkg_gamma_inc)(double,double); |