## 02/06/2020:
##   all exportClasses() commented as they would export everything as S4 classes,
##   whereas everything is defined as just S3 classes in the code

# Load dynamic library
useDynLib(mixAK, .registration = TRUE)

# Export all names
exportPattern("GLMM_MCMC*")
#exportClasses("GLMM_MCMC", "GLMM_MCMClist")
S3method(fitted, "GLMM_MCMC")
S3method(print, "GLMM_MCMC")
S3method(print, "GLMM_MCMClist")

export("GLMM_longitDA")
export("GLMM_longitDA2")

exportPattern("NMix*")
#exportClasses("NMixEM", "NMixMCMC", "NMixMCMClist")
S3method(print, "NMixEM")
S3method(print, "NMixMCMC")
S3method(print, "NMixMCMClist")

export("NMixCluster")
S3method(NMixCluster, "default")
#S3method(NMixCluster, "NMixMCMC")
S3method(NMixCluster, "GLMM_MCMC")

export("NMixPseudoGOF")
S3method(NMixPseudoGOF, "default")
S3method(NMixPseudoGOF, "NMixMCMC")

export("NMixRelabel")
S3method(NMixRelabel, "default")
S3method(NMixRelabel, "NMixMCMC")
S3method(NMixRelabel, "NMixMCMClist")
S3method(NMixRelabel, "GLMM_MCMC")
S3method(NMixRelabel, "GLMM_MCMClist")

export("NMixSummComp")
S3method(NMixSummComp, "default")
S3method(NMixSummComp, "NMixMCMC")
S3method(NMixSummComp, "GLMM_MCMC")

export("NMixChainComp")
S3method(NMixChainComp, "default")
S3method(NMixChainComp, "NMixMCMC")
S3method(NMixChainComp, "GLMM_MCMC")

export("tracePlots")
S3method(tracePlots, "default")
S3method(tracePlots, "NMixMCMC")
S3method(tracePlots, "NMixMCMClist")
S3method(tracePlots, "GLMM_MCMC")
S3method(tracePlots, "GLMM_MCMClist")

export("NMixPlugCondDensJoint2")
S3method(NMixPlugCondDensJoint2, "default")
S3method(NMixPlugCondDensJoint2, "NMixMCMC")
S3method(NMixPlugCondDensJoint2, "GLMM_MCMC")

export("NMixPlugCondDensMarg")
S3method(NMixPlugCondDensMarg, "default")
S3method(NMixPlugCondDensMarg, "NMixMCMC")
S3method(NMixPlugCondDensMarg, "GLMM_MCMC")

export("NMixPlugDensJoint2")
S3method(NMixPlugDensJoint2, "default")
S3method(NMixPlugDensJoint2, "NMixMCMC")
S3method(NMixPlugDensJoint2, "GLMM_MCMC")

export("NMixPlugDensMarg")
S3method(NMixPlugDensMarg, "default")
S3method(NMixPlugDensMarg, "NMixMCMC")
S3method(NMixPlugDensMarg, "GLMM_MCMC")

export("NMixPredCDFMarg")
S3method(NMixPredCDFMarg, "default")
S3method(NMixPredCDFMarg, "NMixMCMC")
S3method(NMixPredCDFMarg, "GLMM_MCMC")

export("NMixPredCondCDFMarg")
S3method(NMixPredCondCDFMarg, "default")
S3method(NMixPredCondCDFMarg, "NMixMCMC")
S3method(NMixPredCondCDFMarg, "GLMM_MCMC")

export("NMixPredCondDensJoint2")
S3method(NMixPredCondDensJoint2, "default")
S3method(NMixPredCondDensJoint2, "NMixMCMC")
S3method(NMixPredCondDensJoint2, "GLMM_MCMC")

export("NMixPredCondDensMarg")
S3method(NMixPredCondDensMarg, "default")
S3method(NMixPredCondDensMarg, "NMixMCMC")
S3method(NMixPredCondDensMarg, "GLMM_MCMC")

export("NMixPredDensJoint2")
S3method(NMixPredDensJoint2, "default")
S3method(NMixPredDensJoint2, "NMixMCMC")
S3method(NMixPredDensJoint2, "GLMM_MCMC")

export("NMixPredDensMarg")
S3method(NMixPredDensMarg, "default")
S3method(NMixPredDensMarg, "NMixMCMC")
S3method(NMixPredDensMarg, "GLMM_MCMC")

#exportClasses("NMixPlugCondDensJoint2", "NMixPlugCondDensMarg", "NMixPlugDensJoint2", "NMixPlugDensMarg", "NMixPredCDFMarg", "NMixPredCondCDFMarg", "NMixPredCondDensJoint2", "NMixPredCondDensMarg", "NMixPredDensJoint2", "NMixPredDensMarg")
S3method(plot, "NMixPlugCondDensJoint2")
S3method(plot, "NMixPlugCondDensMarg")
S3method(plot, "NMixPlugDensJoint2")
S3method(plot, "NMixPlugDensMarg")
S3method(plot, "NMixPredCDFMarg")
S3method(plot, "NMixPredCondCDFMarg")
S3method(plot, "NMixPredCondDensJoint2")
S3method(plot, "NMixPredCondDensMarg")
S3method(plot, "NMixPredDensJoint2")
S3method(plot, "NMixPredDensMarg")

export("Y2T")
S3method(Y2T, "NMixPlugCondDensJoint2")
S3method(Y2T, "NMixPlugCondDensMarg")
S3method(Y2T, "NMixPlugDensJoint2")
S3method(Y2T, "NMixPlugDensMarg")
S3method(Y2T, "NMixPredCDFMarg")
S3method(Y2T, "NMixPredCondCDFMarg")
S3method(Y2T, "NMixPredCondDensJoint2")
S3method(Y2T, "NMixPredCondDensMarg")
S3method(Y2T, "NMixPredDensJoint2")
S3method(Y2T, "NMixPredDensMarg")

export("summaryDiff")
export("BLA", "BsBasis", "MatMPpinv", "MatSqrt", "SP2Rect", "autolayout", "cbplot", "generatePermutations", "getProfiles", "plotProfiles")
export("dMVN", "rMVN")
export("rcMVN")
export("dMVNmixture", "dMVNmixture2", "rMVNmixture", "rMVNmixture2")
export("rTMVN")
export("rTNorm")
export("dMVT", "rMVT")
export("dWISHART", "rWISHART")
export("rDirichlet")
export("rRotationMatrix")
export("rSamplePair")

# Selective import from other packages
importFrom(splines,  "bs")               ## In: BsBasis
importFrom(mnormt,   "pmnorm")           ## In: NMixPseudoGOF.default
importFrom(parallel, "detectCores", "makeCluster", "parLapply", "stopCluster")      ## In: GLMM_MCMC, NMixMCMC, NMixRelabel.GLMM_MCMClist
#importFrom(lme4, "lmer", "glmer", "fixef", "VarCorr", "ranef", "glmerControl")      ## In: GLMM_MCMCifit
#importClassesFrom(lme4, "glmerMod", "lmerMod", "merMod")
     ### From lme4, we additionally use: vcov, which is defined in the lme4 (1.0-4) NAMESPACE as:
     ###   importFrom(stats, vcov)
     ###   S3method(vcov, merMod)
     ###
     ### Telling importFrom(lme4, "vcov") here causes error: objects `vcov' are not exported by 'namespace:lme4'
     ### I guess that by importing the merMod class, it is no more necessary import vcov explicitely...
     ###
importFrom(fastGHQuad, "gaussHermiteData", "aghQuad")           ## In: fitted.GLMM_MCMC
importFrom(coda, "mcmc", "HPDinterval")                         ## In: NMixCluster.GLMM_MCMC, GLMM_longitDA2

# Import full packages where more functions are used
# as of 3.6: I again import full lme4 since selective import above did not import
# everything needed...
import(colorspace)
import(lme4)

# Selective import from standard packages
# (to make CRAN check happy)
importFrom(graphics, "axis", "image", "layout", "legend", "lines", "matplot", "par", "points", "segments", "title", "plot.default")
importFrom(stats, "binomial", "coef", "dnorm", "formula", "glm", "lm", "median", "optim", "pnorm", "poisson", "quantile", "rgamma", "rnorm", "runif", "sd", "var", "vcov")
importFrom(methods, "is")