// Generated by using Rcpp::compileAttributes() -> do not edit by hand
// Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

#include <RcppArmadillo.h>
#include <Rcpp.h>

using namespace Rcpp;

#ifdef RCPP_USE_GLOBAL_ROSTREAM
Rcpp::Rostream<true>&  Rcpp::Rcout = Rcpp::Rcpp_cout_get();
Rcpp::Rostream<false>& Rcpp::Rcerr = Rcpp::Rcpp_cerr_get();
#endif

// bwp_project_gaussians_rcpp
Rcpp::List bwp_project_gaussians_rcpp(const arma::mat& M, const arma::cube& Sigma, const int d, const int max_iter, const double step_init, const double tol_grad, const double tol_obj, const double eps, const bool verbose, const double armijo_c, const double armijo_beta, const int ls_max, const double ls_min_step);
RcppExport SEXP _maotai_bwp_project_gaussians_rcpp(SEXP MSEXP, SEXP SigmaSEXP, SEXP dSEXP, SEXP max_iterSEXP, SEXP step_initSEXP, SEXP tol_gradSEXP, SEXP tol_objSEXP, SEXP epsSEXP, SEXP verboseSEXP, SEXP armijo_cSEXP, SEXP armijo_betaSEXP, SEXP ls_maxSEXP, SEXP ls_min_stepSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< const arma::mat& >::type M(MSEXP);
    Rcpp::traits::input_parameter< const arma::cube& >::type Sigma(SigmaSEXP);
    Rcpp::traits::input_parameter< const int >::type d(dSEXP);
    Rcpp::traits::input_parameter< const int >::type max_iter(max_iterSEXP);
    Rcpp::traits::input_parameter< const double >::type step_init(step_initSEXP);
    Rcpp::traits::input_parameter< const double >::type tol_grad(tol_gradSEXP);
    Rcpp::traits::input_parameter< const double >::type tol_obj(tol_objSEXP);
    Rcpp::traits::input_parameter< const double >::type eps(epsSEXP);
    Rcpp::traits::input_parameter< const bool >::type verbose(verboseSEXP);
    Rcpp::traits::input_parameter< const double >::type armijo_c(armijo_cSEXP);
    Rcpp::traits::input_parameter< const double >::type armijo_beta(armijo_betaSEXP);
    Rcpp::traits::input_parameter< const int >::type ls_max(ls_maxSEXP);
    Rcpp::traits::input_parameter< const double >::type ls_min_step(ls_min_stepSEXP);
    rcpp_result_gen = Rcpp::wrap(bwp_project_gaussians_rcpp(M, Sigma, d, max_iter, step_init, tol_grad, tol_obj, eps, verbose, armijo_c, armijo_beta, ls_max, ls_min_step));
    return rcpp_result_gen;
END_RCPP
}
// sphere_dist
double sphere_dist(arma::rowvec vecx, arma::rowvec vecy);
RcppExport SEXP _maotai_sphere_dist(SEXP vecxSEXP, SEXP vecySEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< arma::rowvec >::type vecx(vecxSEXP);
    Rcpp::traits::input_parameter< arma::rowvec >::type vecy(vecySEXP);
    rcpp_result_gen = Rcpp::wrap(sphere_dist(vecx, vecy));
    return rcpp_result_gen;
END_RCPP
}
// cpp_WL_normalise
arma::mat cpp_WL_normalise(arma::mat& X);
RcppExport SEXP _maotai_cpp_WL_normalise(SEXP XSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< arma::mat& >::type X(XSEXP);
    rcpp_result_gen = Rcpp::wrap(cpp_WL_normalise(X));
    return rcpp_result_gen;
END_RCPP
}
// cpp_WL_weighted_mean
arma::rowvec cpp_WL_weighted_mean(arma::mat& X, arma::vec& weights);
RcppExport SEXP _maotai_cpp_WL_weighted_mean(SEXP XSEXP, SEXP weightsSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< arma::mat& >::type X(XSEXP);
    Rcpp::traits::input_parameter< arma::vec& >::type weights(weightsSEXP);
    rcpp_result_gen = Rcpp::wrap(cpp_WL_weighted_mean(X, weights));
    return rcpp_result_gen;
END_RCPP
}
// compute_SSR
double compute_SSR(arma::mat& D, arma::mat& Delta);
RcppExport SEXP _maotai_compute_SSR(SEXP DSEXP, SEXP DeltaSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< arma::mat& >::type D(DSEXP);
    Rcpp::traits::input_parameter< arma::mat& >::type Delta(DeltaSEXP);
    rcpp_result_gen = Rcpp::wrap(compute_SSR(D, Delta));
    return rcpp_result_gen;
END_RCPP
}
// compute_stress
double compute_stress(arma::mat& D, arma::mat& Dhat);
RcppExport SEXP _maotai_compute_stress(SEXP DSEXP, SEXP DhatSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< arma::mat& >::type D(DSEXP);
    Rcpp::traits::input_parameter< arma::mat& >::type Dhat(DhatSEXP);
    rcpp_result_gen = Rcpp::wrap(compute_stress(D, Dhat));
    return rcpp_result_gen;
END_RCPP
}
// main_bmds
Rcpp::List main_bmds(arma::mat D, arma::mat X0, double sigg0, double a, double alpha, int maxiter, double constant, bool verbose, arma::vec betas);
RcppExport SEXP _maotai_main_bmds(SEXP DSEXP, SEXP X0SEXP, SEXP sigg0SEXP, SEXP aSEXP, SEXP alphaSEXP, SEXP maxiterSEXP, SEXP constantSEXP, SEXP verboseSEXP, SEXP betasSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< arma::mat >::type D(DSEXP);
    Rcpp::traits::input_parameter< arma::mat >::type X0(X0SEXP);
    Rcpp::traits::input_parameter< double >::type sigg0(sigg0SEXP);
    Rcpp::traits::input_parameter< double >::type a(aSEXP);
    Rcpp::traits::input_parameter< double >::type alpha(alphaSEXP);
    Rcpp::traits::input_parameter< int >::type maxiter(maxiterSEXP);
    Rcpp::traits::input_parameter< double >::type constant(constantSEXP);
    Rcpp::traits::input_parameter< bool >::type verbose(verboseSEXP);
    Rcpp::traits::input_parameter< arma::vec >::type betas(betasSEXP);
    rcpp_result_gen = Rcpp::wrap(main_bmds(D, X0, sigg0, a, alpha, maxiter, constant, verbose, betas));
    return rcpp_result_gen;
END_RCPP
}
// caml_frechet_mean
Rcpp::List caml_frechet_mean(const Rcpp::List& Y_list_R, const arma::vec& w, int maxit, double tol, double step0, double c1, double beta, bool verbose);
RcppExport SEXP _maotai_caml_frechet_mean(SEXP Y_list_RSEXP, SEXP wSEXP, SEXP maxitSEXP, SEXP tolSEXP, SEXP step0SEXP, SEXP c1SEXP, SEXP betaSEXP, SEXP verboseSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< const Rcpp::List& >::type Y_list_R(Y_list_RSEXP);
    Rcpp::traits::input_parameter< const arma::vec& >::type w(wSEXP);
    Rcpp::traits::input_parameter< int >::type maxit(maxitSEXP);
    Rcpp::traits::input_parameter< double >::type tol(tolSEXP);
    Rcpp::traits::input_parameter< double >::type step0(step0SEXP);
    Rcpp::traits::input_parameter< double >::type c1(c1SEXP);
    Rcpp::traits::input_parameter< double >::type beta(betaSEXP);
    Rcpp::traits::input_parameter< bool >::type verbose(verboseSEXP);
    rcpp_result_gen = Rcpp::wrap(caml_frechet_mean(Y_list_R, w, maxit, tol, step0, c1, beta, verbose));
    return rcpp_result_gen;
END_RCPP
}
// aux_shortestpath
Rcpp::NumericMatrix aux_shortestpath(NumericMatrix& wmat);
RcppExport SEXP _maotai_aux_shortestpath(SEXP wmatSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< NumericMatrix& >::type wmat(wmatSEXP);
    rcpp_result_gen = Rcpp::wrap(aux_shortestpath(wmat));
    return rcpp_result_gen;
END_RCPP
}
// cppsub_2007Wang
arma::mat cppsub_2007Wang(arma::mat V0, int mm, int d, arma::mat Spu, arma::mat Stu, int maxiter, double eps);
RcppExport SEXP _maotai_cppsub_2007Wang(SEXP V0SEXP, SEXP mmSEXP, SEXP dSEXP, SEXP SpuSEXP, SEXP StuSEXP, SEXP maxiterSEXP, SEXP epsSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< arma::mat >::type V0(V0SEXP);
    Rcpp::traits::input_parameter< int >::type mm(mmSEXP);
    Rcpp::traits::input_parameter< int >::type d(dSEXP);
    Rcpp::traits::input_parameter< arma::mat >::type Spu(SpuSEXP);
    Rcpp::traits::input_parameter< arma::mat >::type Stu(StuSEXP);
    Rcpp::traits::input_parameter< int >::type maxiter(maxiterSEXP);
    Rcpp::traits::input_parameter< double >::type eps(epsSEXP);
    rcpp_result_gen = Rcpp::wrap(cppsub_2007Wang(V0, mm, d, Spu, Stu, maxiter, eps));
    return rcpp_result_gen;
END_RCPP
}
// gradF
arma::mat gradF(Function func, arma::mat xnow, double h);
RcppExport SEXP _maotai_gradF(SEXP funcSEXP, SEXP xnowSEXP, SEXP hSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< Function >::type func(funcSEXP);
    Rcpp::traits::input_parameter< arma::mat >::type xnow(xnowSEXP);
    Rcpp::traits::input_parameter< double >::type h(hSEXP);
    rcpp_result_gen = Rcpp::wrap(gradF(func, xnow, h));
    return rcpp_result_gen;
END_RCPP
}
// dat2centers
arma::vec dat2centers(arma::rowvec data, arma::mat& centers);
RcppExport SEXP _maotai_dat2centers(SEXP dataSEXP, SEXP centersSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< arma::rowvec >::type data(dataSEXP);
    Rcpp::traits::input_parameter< arma::mat& >::type centers(centersSEXP);
    rcpp_result_gen = Rcpp::wrap(dat2centers(data, centers));
    return rcpp_result_gen;
END_RCPP
}
// cpp_sylvester
arma::mat cpp_sylvester(arma::mat A, arma::mat B, arma::mat C);
RcppExport SEXP _maotai_cpp_sylvester(SEXP ASEXP, SEXP BSEXP, SEXP CSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< arma::mat >::type A(ASEXP);
    Rcpp::traits::input_parameter< arma::mat >::type B(BSEXP);
    Rcpp::traits::input_parameter< arma::mat >::type C(CSEXP);
    rcpp_result_gen = Rcpp::wrap(cpp_sylvester(A, B, C));
    return rcpp_result_gen;
END_RCPP
}
// solve_lyapunov
arma::mat solve_lyapunov(arma::mat A, arma::mat B, arma::mat C);
RcppExport SEXP _maotai_solve_lyapunov(SEXP ASEXP, SEXP BSEXP, SEXP CSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< arma::mat >::type A(ASEXP);
    Rcpp::traits::input_parameter< arma::mat >::type B(BSEXP);
    Rcpp::traits::input_parameter< arma::mat >::type C(CSEXP);
    rcpp_result_gen = Rcpp::wrap(solve_lyapunov(A, B, C));
    return rcpp_result_gen;
END_RCPP
}
// cpp_weiszfeld
arma::rowvec cpp_weiszfeld(arma::mat X, double abstol, int maxiter, arma::rowvec xinit, arma::vec weights, double epsnum);
RcppExport SEXP _maotai_cpp_weiszfeld(SEXP XSEXP, SEXP abstolSEXP, SEXP maxiterSEXP, SEXP xinitSEXP, SEXP weightsSEXP, SEXP epsnumSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< arma::mat >::type X(XSEXP);
    Rcpp::traits::input_parameter< double >::type abstol(abstolSEXP);
    Rcpp::traits::input_parameter< int >::type maxiter(maxiterSEXP);
    Rcpp::traits::input_parameter< arma::rowvec >::type xinit(xinitSEXP);
    Rcpp::traits::input_parameter< arma::vec >::type weights(weightsSEXP);
    Rcpp::traits::input_parameter< double >::type epsnum(epsnumSEXP);
    rcpp_result_gen = Rcpp::wrap(cpp_weiszfeld(X, abstol, maxiter, xinit, weights, epsnum));
    return rcpp_result_gen;
END_RCPP
}
// cpp_kmeans
Rcpp::List cpp_kmeans(arma::mat data, int k);
RcppExport SEXP _maotai_cpp_kmeans(SEXP dataSEXP, SEXP kSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< arma::mat >::type data(dataSEXP);
    Rcpp::traits::input_parameter< int >::type k(kSEXP);
    rcpp_result_gen = Rcpp::wrap(cpp_kmeans(data, k));
    return rcpp_result_gen;
END_RCPP
}
// emds_gamma0
double emds_gamma0(arma::mat dmat);
RcppExport SEXP _maotai_emds_gamma0(SEXP dmatSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< arma::mat >::type dmat(dmatSEXP);
    rcpp_result_gen = Rcpp::wrap(emds_gamma0(dmat));
    return rcpp_result_gen;
END_RCPP
}
// cpp_pairwise_L2
Rcpp::List cpp_pairwise_L2(arma::mat muA, arma::mat muB, arma::cube covA, arma::cube covB);
RcppExport SEXP _maotai_cpp_pairwise_L2(SEXP muASEXP, SEXP muBSEXP, SEXP covASEXP, SEXP covBSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< arma::mat >::type muA(muASEXP);
    Rcpp::traits::input_parameter< arma::mat >::type muB(muBSEXP);
    Rcpp::traits::input_parameter< arma::cube >::type covA(covASEXP);
    Rcpp::traits::input_parameter< arma::cube >::type covB(covBSEXP);
    rcpp_result_gen = Rcpp::wrap(cpp_pairwise_L2(muA, muB, covA, covB));
    return rcpp_result_gen;
END_RCPP
}
// integrate_1d
double integrate_1d(arma::vec& tseq, arma::vec& fval);
RcppExport SEXP _maotai_integrate_1d(SEXP tseqSEXP, SEXP fvalSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< arma::vec& >::type tseq(tseqSEXP);
    Rcpp::traits::input_parameter< arma::vec& >::type fval(fvalSEXP);
    rcpp_result_gen = Rcpp::wrap(integrate_1d(tseq, fval));
    return rcpp_result_gen;
END_RCPP
}
// cpp_pdist
arma::mat cpp_pdist(arma::mat X);
RcppExport SEXP _maotai_cpp_pdist(SEXP XSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< arma::mat >::type X(XSEXP);
    rcpp_result_gen = Rcpp::wrap(cpp_pdist(X));
    return rcpp_result_gen;
END_RCPP
}
// cpp_geigen
Rcpp::List cpp_geigen(arma::mat& A, arma::mat& B);
RcppExport SEXP _maotai_cpp_geigen(SEXP ASEXP, SEXP BSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< arma::mat& >::type A(ASEXP);
    Rcpp::traits::input_parameter< arma::mat& >::type B(BSEXP);
    rcpp_result_gen = Rcpp::wrap(cpp_geigen(A, B));
    return rcpp_result_gen;
END_RCPP
}
// cpp_triangle
bool cpp_triangle(arma::mat& D);
RcppExport SEXP _maotai_cpp_triangle(SEXP DSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< arma::mat& >::type D(DSEXP);
    rcpp_result_gen = Rcpp::wrap(cpp_triangle(D));
    return rcpp_result_gen;
END_RCPP
}
// cpp_metricdepth
arma::vec cpp_metricdepth(arma::mat& D);
RcppExport SEXP _maotai_cpp_metricdepth(SEXP DSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< arma::mat& >::type D(DSEXP);
    rcpp_result_gen = Rcpp::wrap(cpp_metricdepth(D));
    return rcpp_result_gen;
END_RCPP
}
// cpp_dist_ks
arma::mat cpp_dist_ks(const arma::mat& F);
RcppExport SEXP _maotai_cpp_dist_ks(SEXP FSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< const arma::mat& >::type F(FSEXP);
    rcpp_result_gen = Rcpp::wrap(cpp_dist_ks(F));
    return rcpp_result_gen;
END_RCPP
}
// cpp_dist_lp
arma::mat cpp_dist_lp(const arma::vec& t, const arma::mat& F, double p);
RcppExport SEXP _maotai_cpp_dist_lp(SEXP tSEXP, SEXP FSEXP, SEXP pSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< const arma::vec& >::type t(tSEXP);
    Rcpp::traits::input_parameter< const arma::mat& >::type F(FSEXP);
    Rcpp::traits::input_parameter< double >::type p(pSEXP);
    rcpp_result_gen = Rcpp::wrap(cpp_dist_lp(t, F, p));
    return rcpp_result_gen;
END_RCPP
}
// cpp_dist_wasserstein
arma::mat cpp_dist_wasserstein(const arma::vec& q, const arma::mat& Q, double p);
RcppExport SEXP _maotai_cpp_dist_wasserstein(SEXP qSEXP, SEXP QSEXP, SEXP pSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< const arma::vec& >::type q(qSEXP);
    Rcpp::traits::input_parameter< const arma::mat& >::type Q(QSEXP);
    Rcpp::traits::input_parameter< double >::type p(pSEXP);
    rcpp_result_gen = Rcpp::wrap(cpp_dist_wasserstein(q, Q, p));
    return rcpp_result_gen;
END_RCPP
}
// lp_ecdf_distance
double lp_ecdf_distance(const arma::vec& x, const arma::vec& y, double p);
RcppExport SEXP _maotai_lp_ecdf_distance(SEXP xSEXP, SEXP ySEXP, SEXP pSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< const arma::vec& >::type x(xSEXP);
    Rcpp::traits::input_parameter< const arma::vec& >::type y(ySEXP);
    Rcpp::traits::input_parameter< double >::type p(pSEXP);
    rcpp_result_gen = Rcpp::wrap(lp_ecdf_distance(x, y, p));
    return rcpp_result_gen;
END_RCPP
}
// ks_ecdf_distance
double ks_ecdf_distance(const arma::vec& x, const arma::vec& y);
RcppExport SEXP _maotai_ks_ecdf_distance(SEXP xSEXP, SEXP ySEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< const arma::vec& >::type x(xSEXP);
    Rcpp::traits::input_parameter< const arma::vec& >::type y(ySEXP);
    rcpp_result_gen = Rcpp::wrap(ks_ecdf_distance(x, y));
    return rcpp_result_gen;
END_RCPP
}
// lp_ecdf_distance_matrix
arma::mat lp_ecdf_distance_matrix(const arma::field<arma::vec>& samples, double p);
RcppExport SEXP _maotai_lp_ecdf_distance_matrix(SEXP samplesSEXP, SEXP pSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< const arma::field<arma::vec>& >::type samples(samplesSEXP);
    Rcpp::traits::input_parameter< double >::type p(pSEXP);
    rcpp_result_gen = Rcpp::wrap(lp_ecdf_distance_matrix(samples, p));
    return rcpp_result_gen;
END_RCPP
}
// lp_ecdf_distance_to_reference
arma::vec lp_ecdf_distance_to_reference(const arma::field<arma::vec>& samples, const arma::vec& reference, double p);
RcppExport SEXP _maotai_lp_ecdf_distance_to_reference(SEXP samplesSEXP, SEXP referenceSEXP, SEXP pSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< const arma::field<arma::vec>& >::type samples(samplesSEXP);
    Rcpp::traits::input_parameter< const arma::vec& >::type reference(referenceSEXP);
    Rcpp::traits::input_parameter< double >::type p(pSEXP);
    rcpp_result_gen = Rcpp::wrap(lp_ecdf_distance_to_reference(samples, reference, p));
    return rcpp_result_gen;
END_RCPP
}
// wasserstein_p_unweighted
double wasserstein_p_unweighted(const arma::vec& x, const arma::vec& y, double p);
RcppExport SEXP _maotai_wasserstein_p_unweighted(SEXP xSEXP, SEXP ySEXP, SEXP pSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< const arma::vec& >::type x(xSEXP);
    Rcpp::traits::input_parameter< const arma::vec& >::type y(ySEXP);
    Rcpp::traits::input_parameter< double >::type p(pSEXP);
    rcpp_result_gen = Rcpp::wrap(wasserstein_p_unweighted(x, y, p));
    return rcpp_result_gen;
END_RCPP
}
// wasserstein_p_weighted
double wasserstein_p_weighted(const arma::vec& x, arma::vec wx, const arma::vec& y, arma::vec wy, double p);
RcppExport SEXP _maotai_wasserstein_p_weighted(SEXP xSEXP, SEXP wxSEXP, SEXP ySEXP, SEXP wySEXP, SEXP pSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< const arma::vec& >::type x(xSEXP);
    Rcpp::traits::input_parameter< arma::vec >::type wx(wxSEXP);
    Rcpp::traits::input_parameter< const arma::vec& >::type y(ySEXP);
    Rcpp::traits::input_parameter< arma::vec >::type wy(wySEXP);
    Rcpp::traits::input_parameter< double >::type p(pSEXP);
    rcpp_result_gen = Rcpp::wrap(wasserstein_p_weighted(x, wx, y, wy, p));
    return rcpp_result_gen;
END_RCPP
}
// wasserstein_p_distance_matrix
arma::mat wasserstein_p_distance_matrix(const arma::field<arma::vec>& samples, double p);
RcppExport SEXP _maotai_wasserstein_p_distance_matrix(SEXP samplesSEXP, SEXP pSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< const arma::field<arma::vec>& >::type samples(samplesSEXP);
    Rcpp::traits::input_parameter< double >::type p(pSEXP);
    rcpp_result_gen = Rcpp::wrap(wasserstein_p_distance_matrix(samples, p));
    return rcpp_result_gen;
END_RCPP
}
// cpp_mmds
arma::mat cpp_mmds(arma::mat& D, int ndim, int maxiter, double abstol);
RcppExport SEXP _maotai_cpp_mmds(SEXP DSEXP, SEXP ndimSEXP, SEXP maxiterSEXP, SEXP abstolSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< arma::mat& >::type D(DSEXP);
    Rcpp::traits::input_parameter< int >::type ndim(ndimSEXP);
    Rcpp::traits::input_parameter< int >::type maxiter(maxiterSEXP);
    Rcpp::traits::input_parameter< double >::type abstol(abstolSEXP);
    rcpp_result_gen = Rcpp::wrap(cpp_mmds(D, ndim, maxiter, abstol));
    return rcpp_result_gen;
END_RCPP
}
// src_smacof
Rcpp::List src_smacof(arma::mat& D, arma::mat& W, int ndim, int maxiter, double abstol, bool use_gutman);
RcppExport SEXP _maotai_src_smacof(SEXP DSEXP, SEXP WSEXP, SEXP ndimSEXP, SEXP maxiterSEXP, SEXP abstolSEXP, SEXP use_gutmanSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< arma::mat& >::type D(DSEXP);
    Rcpp::traits::input_parameter< arma::mat& >::type W(WSEXP);
    Rcpp::traits::input_parameter< int >::type ndim(ndimSEXP);
    Rcpp::traits::input_parameter< int >::type maxiter(maxiterSEXP);
    Rcpp::traits::input_parameter< double >::type abstol(abstolSEXP);
    Rcpp::traits::input_parameter< bool >::type use_gutman(use_gutmanSEXP);
    rcpp_result_gen = Rcpp::wrap(src_smacof(D, W, ndim, maxiter, abstol, use_gutman));
    return rcpp_result_gen;
END_RCPP
}
// eval_gaussian
double eval_gaussian(arma::vec x, arma::vec mu, arma::mat cov);
RcppExport SEXP _maotai_eval_gaussian(SEXP xSEXP, SEXP muSEXP, SEXP covSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< arma::vec >::type x(xSEXP);
    Rcpp::traits::input_parameter< arma::vec >::type mu(muSEXP);
    Rcpp::traits::input_parameter< arma::mat >::type cov(covSEXP);
    rcpp_result_gen = Rcpp::wrap(eval_gaussian(x, mu, cov));
    return rcpp_result_gen;
END_RCPP
}
// eval_gaussian_data
arma::vec eval_gaussian_data(arma::mat X, arma::vec mu, arma::mat cov);
RcppExport SEXP _maotai_eval_gaussian_data(SEXP XSEXP, SEXP muSEXP, SEXP covSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< arma::mat >::type X(XSEXP);
    Rcpp::traits::input_parameter< arma::vec >::type mu(muSEXP);
    Rcpp::traits::input_parameter< arma::mat >::type cov(covSEXP);
    rcpp_result_gen = Rcpp::wrap(eval_gaussian_data(X, mu, cov));
    return rcpp_result_gen;
END_RCPP
}
// eval_gmm_data
arma::vec eval_gmm_data(arma::mat X, arma::mat mus, arma::cube covs, arma::vec weight);
RcppExport SEXP _maotai_eval_gmm_data(SEXP XSEXP, SEXP musSEXP, SEXP covsSEXP, SEXP weightSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< arma::mat >::type X(XSEXP);
    Rcpp::traits::input_parameter< arma::mat >::type mus(musSEXP);
    Rcpp::traits::input_parameter< arma::cube >::type covs(covsSEXP);
    Rcpp::traits::input_parameter< arma::vec >::type weight(weightSEXP);
    rcpp_result_gen = Rcpp::wrap(eval_gmm_data(X, mus, covs, weight));
    return rcpp_result_gen;
END_RCPP
}
// eval_gmm
double eval_gmm(arma::vec x, arma::mat mus, arma::cube covs, arma::vec weight);
RcppExport SEXP _maotai_eval_gmm(SEXP xSEXP, SEXP musSEXP, SEXP covsSEXP, SEXP weightSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< arma::vec >::type x(xSEXP);
    Rcpp::traits::input_parameter< arma::mat >::type mus(musSEXP);
    Rcpp::traits::input_parameter< arma::cube >::type covs(covsSEXP);
    Rcpp::traits::input_parameter< arma::vec >::type weight(weightSEXP);
    rcpp_result_gen = Rcpp::wrap(eval_gmm(x, mus, covs, weight));
    return rcpp_result_gen;
END_RCPP
}
// src_construct_by_knn
arma::sp_umat src_construct_by_knn(arma::umat& nn_idx, bool intersection);
RcppExport SEXP _maotai_src_construct_by_knn(SEXP nn_idxSEXP, SEXP intersectionSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< arma::umat& >::type nn_idx(nn_idxSEXP);
    Rcpp::traits::input_parameter< bool >::type intersection(intersectionSEXP);
    rcpp_result_gen = Rcpp::wrap(src_construct_by_knn(nn_idx, intersection));
    return rcpp_result_gen;
END_RCPP
}
// src_gaussbary_2002R
Rcpp::List src_gaussbary_2002R(arma::cube& array3d, arma::vec& weight, int maxiter, double abstol);
RcppExport SEXP _maotai_src_gaussbary_2002R(SEXP array3dSEXP, SEXP weightSEXP, SEXP maxiterSEXP, SEXP abstolSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< arma::cube& >::type array3d(array3dSEXP);
    Rcpp::traits::input_parameter< arma::vec& >::type weight(weightSEXP);
    Rcpp::traits::input_parameter< int >::type maxiter(maxiterSEXP);
    Rcpp::traits::input_parameter< double >::type abstol(abstolSEXP);
    rcpp_result_gen = Rcpp::wrap(src_gaussbary_2002R(array3d, weight, maxiter, abstol));
    return rcpp_result_gen;
END_RCPP
}
// src_gaussbary_2016A
Rcpp::List src_gaussbary_2016A(arma::cube& array3d, arma::vec& weight, int maxiter, double abstol);
RcppExport SEXP _maotai_src_gaussbary_2016A(SEXP array3dSEXP, SEXP weightSEXP, SEXP maxiterSEXP, SEXP abstolSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< arma::cube& >::type array3d(array3dSEXP);
    Rcpp::traits::input_parameter< arma::vec& >::type weight(weightSEXP);
    Rcpp::traits::input_parameter< int >::type maxiter(maxiterSEXP);
    Rcpp::traits::input_parameter< double >::type abstol(abstolSEXP);
    rcpp_result_gen = Rcpp::wrap(src_gaussbary_2016A(array3d, weight, maxiter, abstol));
    return rcpp_result_gen;
END_RCPP
}
// src_cov2corr
arma::mat src_cov2corr(arma::mat& covmat);
RcppExport SEXP _maotai_src_cov2corr(SEXP covmatSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< arma::mat& >::type covmat(covmatSEXP);
    rcpp_result_gen = Rcpp::wrap(src_cov2corr(covmat));
    return rcpp_result_gen;
END_RCPP
}
// src_leida
Rcpp::List src_leida(const arma::mat& phase);
RcppExport SEXP _maotai_src_leida(SEXP phaseSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< const arma::mat& >::type phase(phaseSEXP);
    rcpp_result_gen = Rcpp::wrap(src_leida(phase));
    return rcpp_result_gen;
END_RCPP
}

static const R_CallMethodDef CallEntries[] = {
    {"_maotai_bwp_project_gaussians_rcpp", (DL_FUNC) &_maotai_bwp_project_gaussians_rcpp, 13},
    {"_maotai_sphere_dist", (DL_FUNC) &_maotai_sphere_dist, 2},
    {"_maotai_cpp_WL_normalise", (DL_FUNC) &_maotai_cpp_WL_normalise, 1},
    {"_maotai_cpp_WL_weighted_mean", (DL_FUNC) &_maotai_cpp_WL_weighted_mean, 2},
    {"_maotai_compute_SSR", (DL_FUNC) &_maotai_compute_SSR, 2},
    {"_maotai_compute_stress", (DL_FUNC) &_maotai_compute_stress, 2},
    {"_maotai_main_bmds", (DL_FUNC) &_maotai_main_bmds, 9},
    {"_maotai_caml_frechet_mean", (DL_FUNC) &_maotai_caml_frechet_mean, 8},
    {"_maotai_aux_shortestpath", (DL_FUNC) &_maotai_aux_shortestpath, 1},
    {"_maotai_cppsub_2007Wang", (DL_FUNC) &_maotai_cppsub_2007Wang, 7},
    {"_maotai_gradF", (DL_FUNC) &_maotai_gradF, 3},
    {"_maotai_dat2centers", (DL_FUNC) &_maotai_dat2centers, 2},
    {"_maotai_cpp_sylvester", (DL_FUNC) &_maotai_cpp_sylvester, 3},
    {"_maotai_solve_lyapunov", (DL_FUNC) &_maotai_solve_lyapunov, 3},
    {"_maotai_cpp_weiszfeld", (DL_FUNC) &_maotai_cpp_weiszfeld, 6},
    {"_maotai_cpp_kmeans", (DL_FUNC) &_maotai_cpp_kmeans, 2},
    {"_maotai_emds_gamma0", (DL_FUNC) &_maotai_emds_gamma0, 1},
    {"_maotai_cpp_pairwise_L2", (DL_FUNC) &_maotai_cpp_pairwise_L2, 4},
    {"_maotai_integrate_1d", (DL_FUNC) &_maotai_integrate_1d, 2},
    {"_maotai_cpp_pdist", (DL_FUNC) &_maotai_cpp_pdist, 1},
    {"_maotai_cpp_geigen", (DL_FUNC) &_maotai_cpp_geigen, 2},
    {"_maotai_cpp_triangle", (DL_FUNC) &_maotai_cpp_triangle, 1},
    {"_maotai_cpp_metricdepth", (DL_FUNC) &_maotai_cpp_metricdepth, 1},
    {"_maotai_cpp_dist_ks", (DL_FUNC) &_maotai_cpp_dist_ks, 1},
    {"_maotai_cpp_dist_lp", (DL_FUNC) &_maotai_cpp_dist_lp, 3},
    {"_maotai_cpp_dist_wasserstein", (DL_FUNC) &_maotai_cpp_dist_wasserstein, 3},
    {"_maotai_lp_ecdf_distance", (DL_FUNC) &_maotai_lp_ecdf_distance, 3},
    {"_maotai_ks_ecdf_distance", (DL_FUNC) &_maotai_ks_ecdf_distance, 2},
    {"_maotai_lp_ecdf_distance_matrix", (DL_FUNC) &_maotai_lp_ecdf_distance_matrix, 2},
    {"_maotai_lp_ecdf_distance_to_reference", (DL_FUNC) &_maotai_lp_ecdf_distance_to_reference, 3},
    {"_maotai_wasserstein_p_unweighted", (DL_FUNC) &_maotai_wasserstein_p_unweighted, 3},
    {"_maotai_wasserstein_p_weighted", (DL_FUNC) &_maotai_wasserstein_p_weighted, 5},
    {"_maotai_wasserstein_p_distance_matrix", (DL_FUNC) &_maotai_wasserstein_p_distance_matrix, 2},
    {"_maotai_cpp_mmds", (DL_FUNC) &_maotai_cpp_mmds, 4},
    {"_maotai_src_smacof", (DL_FUNC) &_maotai_src_smacof, 6},
    {"_maotai_eval_gaussian", (DL_FUNC) &_maotai_eval_gaussian, 3},
    {"_maotai_eval_gaussian_data", (DL_FUNC) &_maotai_eval_gaussian_data, 3},
    {"_maotai_eval_gmm_data", (DL_FUNC) &_maotai_eval_gmm_data, 4},
    {"_maotai_eval_gmm", (DL_FUNC) &_maotai_eval_gmm, 4},
    {"_maotai_src_construct_by_knn", (DL_FUNC) &_maotai_src_construct_by_knn, 2},
    {"_maotai_src_gaussbary_2002R", (DL_FUNC) &_maotai_src_gaussbary_2002R, 4},
    {"_maotai_src_gaussbary_2016A", (DL_FUNC) &_maotai_src_gaussbary_2016A, 4},
    {"_maotai_src_cov2corr", (DL_FUNC) &_maotai_src_cov2corr, 1},
    {"_maotai_src_leida", (DL_FUNC) &_maotai_src_leida, 1},
    {NULL, NULL, 0}
};

RcppExport void R_init_maotai(DllInfo *dll) {
    R_registerRoutines(dll, NULL, CallEntries, NULL, NULL);
    R_useDynamicSymbols(dll, FALSE);
}
