From 80be0d77f9875256ee3cde0471a7e4bca876893a Mon Sep 17 00:00:00 2001
From: Benjamin Auder <benjamin.auder@somewhere>
Date: Tue, 29 May 2018 15:18:15 +0200
Subject: [PATCH] fit CRAN rules

---
 pkg/DESCRIPTION         |  6 +++---
 pkg/R/A_NAMESPACE.R     |  2 +-
 pkg/src/morpheus_init.c | 25 +++++++++++++++++++++++++
 3 files changed, 29 insertions(+), 4 deletions(-)
 create mode 100644 pkg/src/morpheus_init.c

diff --git a/pkg/DESCRIPTION b/pkg/DESCRIPTION
index 5999b58..98c76d7 100644
--- a/pkg/DESCRIPTION
+++ b/pkg/DESCRIPTION
@@ -1,10 +1,10 @@
 Package: morpheus
 Title: Estimate Parameters of Mixtures of Logistic Regressions
-Description: Mixture of lOgistic Regressions Parameters (H)Estimation with
-    (U)Spectral methods. The main methods take d-dimensional inputs and a vector
+Description: Mixture of logistic regressions parameters (H)estimation with
+    (U)spectral methods. The main methods take d-dimensional inputs and a vector
     of binary outputs, and return parameters according to the GLMs mixture model
     (General Linear Model). For more details see chapter 3 in the PhD thesis of
-		Mor-Absa Loum: http://www.theses.fr/s156435
+		Mor-Absa Loum: http://www.theses.fr/s156435.
 Version: 0.2-0
 Author: Benjamin Auder <Benjamin.Auder@math.u-psud.fr> [aut,cre],
     Mor-Absa Loum <Mor-Absa.Loum@math.u-psud.fr> [aut]
diff --git a/pkg/R/A_NAMESPACE.R b/pkg/R/A_NAMESPACE.R
index 0a45138..ab9ea34 100644
--- a/pkg/R/A_NAMESPACE.R
+++ b/pkg/R/A_NAMESPACE.R
@@ -1,6 +1,6 @@
 #' @include utils.R
 #'
-#' @useDynLib morpheus
+#' @useDynLib morpheus, .registration = TRUE
 #'
 #' @importFrom jointDiag ajd
 #' @importFrom stats rbinom rmultinom rnorm pnorm runif integrate sd
diff --git a/pkg/src/morpheus_init.c b/pkg/src/morpheus_init.c
new file mode 100644
index 0000000..0777777
--- /dev/null
+++ b/pkg/src/morpheus_init.c
@@ -0,0 +1,25 @@
+#include <stdlib.h> // for NULL
+#include <R_ext/Rdynload.h>
+
+/* FIXME: 
+   Check these declarations against the C/Fortran source code.
+*/
+
+/* .C calls */
+extern void hungarianAlgorithm(void *, void *, void *);
+extern void Moments_M2(void *, void *, void *, void *, void *);
+extern void Moments_M3(void *, void *, void *, void *, void *);
+
+static const R_CMethodDef CEntries[] = {
+    {"hungarianAlgorithm", (DL_FUNC) &hungarianAlgorithm, 3},
+    {"Moments_M2",         (DL_FUNC) &Moments_M2,         5},
+    {"Moments_M3",         (DL_FUNC) &Moments_M3,         5},
+    {NULL, NULL, 0}
+};
+
+void R_init_morpheus(DllInfo *dll)
+{
+    R_registerRoutines(dll, CEntries, NULL, NULL, NULL);
+    R_useDynamicSymbols(dll, FALSE);
+}
+
-- 
2.44.0