// 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

// fit_ml_cpp
Rcpp::List fit_ml_cpp(const arma::mat& R, const int n_fac, arma::vec start, const double lower);
RcppExport SEXP _EFAtools_fit_ml_cpp(SEXP RSEXP, SEXP n_facSEXP, SEXP startSEXP, SEXP lowerSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< const arma::mat& >::type R(RSEXP);
    Rcpp::traits::input_parameter< const int >::type n_fac(n_facSEXP);
    Rcpp::traits::input_parameter< arma::vec >::type start(startSEXP);
    Rcpp::traits::input_parameter< const double >::type lower(lowerSEXP);
    rcpp_result_gen = Rcpp::wrap(fit_ml_cpp(R, n_fac, start, lower));
    return rcpp_result_gen;
END_RCPP
}
// error_ml
double error_ml(arma::vec psi, const arma::mat& R, const int n_fac);
RcppExport SEXP _EFAtools_error_ml(SEXP psiSEXP, SEXP RSEXP, SEXP n_facSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< arma::vec >::type psi(psiSEXP);
    Rcpp::traits::input_parameter< const arma::mat& >::type R(RSEXP);
    Rcpp::traits::input_parameter< const int >::type n_fac(n_facSEXP);
    rcpp_result_gen = Rcpp::wrap(error_ml(psi, R, n_fac));
    return rcpp_result_gen;
END_RCPP
}
// grad_ml
arma::vec grad_ml(arma::vec psi, const arma::mat& R, const int n_fac);
RcppExport SEXP _EFAtools_grad_ml(SEXP psiSEXP, SEXP RSEXP, SEXP n_facSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< arma::vec >::type psi(psiSEXP);
    Rcpp::traits::input_parameter< const arma::mat& >::type R(RSEXP);
    Rcpp::traits::input_parameter< const int >::type n_fac(n_facSEXP);
    rcpp_result_gen = Rcpp::wrap(grad_ml(psi, R, n_fac));
    return rcpp_result_gen;
END_RCPP
}
// fit_uls_cpp
Rcpp::List fit_uls_cpp(const arma::mat& R, const int n_fac, arma::vec start, const double lower);
RcppExport SEXP _EFAtools_fit_uls_cpp(SEXP RSEXP, SEXP n_facSEXP, SEXP startSEXP, SEXP lowerSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< const arma::mat& >::type R(RSEXP);
    Rcpp::traits::input_parameter< const int >::type n_fac(n_facSEXP);
    Rcpp::traits::input_parameter< arma::vec >::type start(startSEXP);
    Rcpp::traits::input_parameter< const double >::type lower(lowerSEXP);
    rcpp_result_gen = Rcpp::wrap(fit_uls_cpp(R, n_fac, start, lower));
    return rcpp_result_gen;
END_RCPP
}
// uls_residuals
double uls_residuals(arma::vec psi, const arma::mat& R, const int n_fac);
RcppExport SEXP _EFAtools_uls_residuals(SEXP psiSEXP, SEXP RSEXP, SEXP n_facSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< arma::vec >::type psi(psiSEXP);
    Rcpp::traits::input_parameter< const arma::mat& >::type R(RSEXP);
    Rcpp::traits::input_parameter< const int >::type n_fac(n_facSEXP);
    rcpp_result_gen = Rcpp::wrap(uls_residuals(psi, R, n_fac));
    return rcpp_result_gen;
END_RCPP
}
// grad_uls
arma::vec grad_uls(arma::vec psi, const arma::mat& R, const int n_fac);
RcppExport SEXP _EFAtools_grad_uls(SEXP psiSEXP, SEXP RSEXP, SEXP n_facSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< arma::vec >::type psi(psiSEXP);
    Rcpp::traits::input_parameter< const arma::mat& >::type R(RSEXP);
    Rcpp::traits::input_parameter< const int >::type n_fac(n_facSEXP);
    rcpp_result_gen = Rcpp::wrap(grad_uls(psi, R, n_fac));
    return rcpp_result_gen;
END_RCPP
}
// fit_dwls_cpp
Rcpp::List fit_dwls_cpp(const arma::mat& R, const int n_fac, const arma::mat& W);
RcppExport SEXP _EFAtools_fit_dwls_cpp(SEXP RSEXP, SEXP n_facSEXP, SEXP WSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< const arma::mat& >::type R(RSEXP);
    Rcpp::traits::input_parameter< const int >::type n_fac(n_facSEXP);
    Rcpp::traits::input_parameter< const arma::mat& >::type W(WSEXP);
    rcpp_result_gen = Rcpp::wrap(fit_dwls_cpp(R, n_fac, W));
    return rcpp_result_gen;
END_RCPP
}
// dwls_residuals
double dwls_residuals(arma::vec par, const arma::mat& R, const int n_fac, const arma::mat& W);
RcppExport SEXP _EFAtools_dwls_residuals(SEXP parSEXP, SEXP RSEXP, SEXP n_facSEXP, SEXP WSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< arma::vec >::type par(parSEXP);
    Rcpp::traits::input_parameter< const arma::mat& >::type R(RSEXP);
    Rcpp::traits::input_parameter< const int >::type n_fac(n_facSEXP);
    Rcpp::traits::input_parameter< const arma::mat& >::type W(WSEXP);
    rcpp_result_gen = Rcpp::wrap(dwls_residuals(par, R, n_fac, W));
    return rcpp_result_gen;
END_RCPP
}
// grad_dwls
arma::vec grad_dwls(arma::vec par, const arma::mat& R, const int n_fac, const arma::mat& W);
RcppExport SEXP _EFAtools_grad_dwls(SEXP parSEXP, SEXP RSEXP, SEXP n_facSEXP, SEXP WSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< arma::vec >::type par(parSEXP);
    Rcpp::traits::input_parameter< const arma::mat& >::type R(RSEXP);
    Rcpp::traits::input_parameter< const int >::type n_fac(n_facSEXP);
    Rcpp::traits::input_parameter< const arma::mat& >::type W(WSEXP);
    rcpp_result_gen = Rcpp::wrap(grad_dwls(par, R, n_fac, W));
    return rcpp_result_gen;
END_RCPP
}
// factor_corres
Rcpp::List factor_corres(NumericMatrix x, NumericMatrix y, double thresh);
RcppExport SEXP _EFAtools_factor_corres(SEXP xSEXP, SEXP ySEXP, SEXP threshSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< NumericMatrix >::type x(xSEXP);
    Rcpp::traits::input_parameter< NumericMatrix >::type y(ySEXP);
    Rcpp::traits::input_parameter< double >::type thresh(threshSEXP);
    rcpp_result_gen = Rcpp::wrap(factor_corres(x, y, thresh));
    return rcpp_result_gen;
END_RCPP
}
// oblique_procrustes
Rcpp::List oblique_procrustes(const arma::mat& A, const arma::mat& B, Rcpp::Nullable<Rcpp::NumericMatrix> S_r, Rcpp::Nullable<Rcpp::NumericMatrix> T_init_r, double eps, int maxit, int max_line_search, double step0, bool normalize, int random_starts, int screen_keep, int triage_maxit, double triage_improve_tol);
RcppExport SEXP _EFAtools_oblique_procrustes(SEXP ASEXP, SEXP BSEXP, SEXP S_rSEXP, SEXP T_init_rSEXP, SEXP epsSEXP, SEXP maxitSEXP, SEXP max_line_searchSEXP, SEXP step0SEXP, SEXP normalizeSEXP, SEXP random_startsSEXP, SEXP screen_keepSEXP, SEXP triage_maxitSEXP, SEXP triage_improve_tolSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< const arma::mat& >::type A(ASEXP);
    Rcpp::traits::input_parameter< const arma::mat& >::type B(BSEXP);
    Rcpp::traits::input_parameter< Rcpp::Nullable<Rcpp::NumericMatrix> >::type S_r(S_rSEXP);
    Rcpp::traits::input_parameter< Rcpp::Nullable<Rcpp::NumericMatrix> >::type T_init_r(T_init_rSEXP);
    Rcpp::traits::input_parameter< double >::type eps(epsSEXP);
    Rcpp::traits::input_parameter< int >::type maxit(maxitSEXP);
    Rcpp::traits::input_parameter< int >::type max_line_search(max_line_searchSEXP);
    Rcpp::traits::input_parameter< double >::type step0(step0SEXP);
    Rcpp::traits::input_parameter< bool >::type normalize(normalizeSEXP);
    Rcpp::traits::input_parameter< int >::type random_starts(random_startsSEXP);
    Rcpp::traits::input_parameter< int >::type screen_keep(screen_keepSEXP);
    Rcpp::traits::input_parameter< int >::type triage_maxit(triage_maxitSEXP);
    Rcpp::traits::input_parameter< double >::type triage_improve_tol(triage_improve_tolSEXP);
    rcpp_result_gen = Rcpp::wrap(oblique_procrustes(A, B, S_r, T_init_r, eps, maxit, max_line_search, step0, normalize, random_starts, screen_keep, triage_maxit, triage_improve_tol));
    return rcpp_result_gen;
END_RCPP
}
// oblique_procrustes_batch
Rcpp::List oblique_procrustes_batch(const arma::cube& A, const arma::mat& B, double eps, int maxit, int max_line_search, double step0, bool normalize, int random_starts, int screen_keep, int triage_maxit, double triage_improve_tol);
RcppExport SEXP _EFAtools_oblique_procrustes_batch(SEXP ASEXP, SEXP BSEXP, SEXP epsSEXP, SEXP maxitSEXP, SEXP max_line_searchSEXP, SEXP step0SEXP, SEXP normalizeSEXP, SEXP random_startsSEXP, SEXP screen_keepSEXP, SEXP triage_maxitSEXP, SEXP triage_improve_tolSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< const arma::cube& >::type A(ASEXP);
    Rcpp::traits::input_parameter< const arma::mat& >::type B(BSEXP);
    Rcpp::traits::input_parameter< double >::type eps(epsSEXP);
    Rcpp::traits::input_parameter< int >::type maxit(maxitSEXP);
    Rcpp::traits::input_parameter< int >::type max_line_search(max_line_searchSEXP);
    Rcpp::traits::input_parameter< double >::type step0(step0SEXP);
    Rcpp::traits::input_parameter< bool >::type normalize(normalizeSEXP);
    Rcpp::traits::input_parameter< int >::type random_starts(random_startsSEXP);
    Rcpp::traits::input_parameter< int >::type screen_keep(screen_keepSEXP);
    Rcpp::traits::input_parameter< int >::type triage_maxit(triage_maxitSEXP);
    Rcpp::traits::input_parameter< double >::type triage_improve_tol(triage_improve_tolSEXP);
    rcpp_result_gen = Rcpp::wrap(oblique_procrustes_batch(A, B, eps, maxit, max_line_search, step0, normalize, random_starts, screen_keep, triage_maxit, triage_improve_tol));
    return rcpp_result_gen;
END_RCPP
}
// paf_iter
Rcpp::List paf_iter(arma::vec h2, double criterion, arma::mat R, const int n_fac, bool abs_eig, int crit_type, int max_iter);
RcppExport SEXP _EFAtools_paf_iter(SEXP h2SEXP, SEXP criterionSEXP, SEXP RSEXP, SEXP n_facSEXP, SEXP abs_eigSEXP, SEXP crit_typeSEXP, SEXP max_iterSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< arma::vec >::type h2(h2SEXP);
    Rcpp::traits::input_parameter< double >::type criterion(criterionSEXP);
    Rcpp::traits::input_parameter< arma::mat >::type R(RSEXP);
    Rcpp::traits::input_parameter< const int >::type n_fac(n_facSEXP);
    Rcpp::traits::input_parameter< bool >::type abs_eig(abs_eigSEXP);
    Rcpp::traits::input_parameter< int >::type crit_type(crit_typeSEXP);
    Rcpp::traits::input_parameter< int >::type max_iter(max_iterSEXP);
    rcpp_result_gen = Rcpp::wrap(paf_iter(h2, criterion, R, n_fac, abs_eig, crit_type, max_iter));
    return rcpp_result_gen;
END_RCPP
}
// parallel_sim
arma::mat parallel_sim(const int n_datasets, const int n_vars, const int N, const int eigen_type, const int maxit);
RcppExport SEXP _EFAtools_parallel_sim(SEXP n_datasetsSEXP, SEXP n_varsSEXP, SEXP NSEXP, SEXP eigen_typeSEXP, SEXP maxitSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< const int >::type n_datasets(n_datasetsSEXP);
    Rcpp::traits::input_parameter< const int >::type n_vars(n_varsSEXP);
    Rcpp::traits::input_parameter< const int >::type N(NSEXP);
    Rcpp::traits::input_parameter< const int >::type eigen_type(eigen_typeSEXP);
    Rcpp::traits::input_parameter< const int >::type maxit(maxitSEXP);
    rcpp_result_gen = Rcpp::wrap(parallel_sim(n_datasets, n_vars, N, eigen_type, maxit));
    return rcpp_result_gen;
END_RCPP
}
// polychoric_cpp
Rcpp::List polychoric_cpp(Rcpp::IntegerMatrix x, std::string acov, bool nearest_pd);
RcppExport SEXP _EFAtools_polychoric_cpp(SEXP xSEXP, SEXP acovSEXP, SEXP nearest_pdSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< Rcpp::IntegerMatrix >::type x(xSEXP);
    Rcpp::traits::input_parameter< std::string >::type acov(acovSEXP);
    Rcpp::traits::input_parameter< bool >::type nearest_pd(nearest_pdSEXP);
    rcpp_result_gen = Rcpp::wrap(polychoric_cpp(x, acov, nearest_pd));
    return rcpp_result_gen;
END_RCPP
}
// bvn_rect_cpp
Rcpp::NumericVector bvn_rect_cpp(Rcpp::NumericVector a0, Rcpp::NumericVector a1, Rcpp::NumericVector b0, Rcpp::NumericVector b1, Rcpp::NumericVector rho);
RcppExport SEXP _EFAtools_bvn_rect_cpp(SEXP a0SEXP, SEXP a1SEXP, SEXP b0SEXP, SEXP b1SEXP, SEXP rhoSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< Rcpp::NumericVector >::type a0(a0SEXP);
    Rcpp::traits::input_parameter< Rcpp::NumericVector >::type a1(a1SEXP);
    Rcpp::traits::input_parameter< Rcpp::NumericVector >::type b0(b0SEXP);
    Rcpp::traits::input_parameter< Rcpp::NumericVector >::type b1(b1SEXP);
    Rcpp::traits::input_parameter< Rcpp::NumericVector >::type rho(rhoSEXP);
    rcpp_result_gen = Rcpp::wrap(bvn_rect_cpp(a0, a1, b0, b1, rho));
    return rcpp_result_gen;
END_RCPP
}
// rotate_cf_orth
Rcpp::List rotate_cf_orth(const arma::mat& L, double kappa, double eps, bool normalize, int random_starts, int maxit, int max_line_search, double step0, int screen_keep, int triage_maxit, double triage_improve_tol);
RcppExport SEXP _EFAtools_rotate_cf_orth(SEXP LSEXP, SEXP kappaSEXP, SEXP epsSEXP, SEXP normalizeSEXP, SEXP random_startsSEXP, SEXP maxitSEXP, SEXP max_line_searchSEXP, SEXP step0SEXP, SEXP screen_keepSEXP, SEXP triage_maxitSEXP, SEXP triage_improve_tolSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< const arma::mat& >::type L(LSEXP);
    Rcpp::traits::input_parameter< double >::type kappa(kappaSEXP);
    Rcpp::traits::input_parameter< double >::type eps(epsSEXP);
    Rcpp::traits::input_parameter< bool >::type normalize(normalizeSEXP);
    Rcpp::traits::input_parameter< int >::type random_starts(random_startsSEXP);
    Rcpp::traits::input_parameter< int >::type maxit(maxitSEXP);
    Rcpp::traits::input_parameter< int >::type max_line_search(max_line_searchSEXP);
    Rcpp::traits::input_parameter< double >::type step0(step0SEXP);
    Rcpp::traits::input_parameter< int >::type screen_keep(screen_keepSEXP);
    Rcpp::traits::input_parameter< int >::type triage_maxit(triage_maxitSEXP);
    Rcpp::traits::input_parameter< double >::type triage_improve_tol(triage_improve_tolSEXP);
    rcpp_result_gen = Rcpp::wrap(rotate_cf_orth(L, kappa, eps, normalize, random_starts, maxit, max_line_search, step0, screen_keep, triage_maxit, triage_improve_tol));
    return rcpp_result_gen;
END_RCPP
}
// rotate_oblimin
Rcpp::List rotate_oblimin(const arma::mat& L, double gam, double eps, bool normalize, int random_starts, int maxit, int max_line_search, double step0, int screen_keep, int triage_maxit, double triage_improve_tol);
RcppExport SEXP _EFAtools_rotate_oblimin(SEXP LSEXP, SEXP gamSEXP, SEXP epsSEXP, SEXP normalizeSEXP, SEXP random_startsSEXP, SEXP maxitSEXP, SEXP max_line_searchSEXP, SEXP step0SEXP, SEXP screen_keepSEXP, SEXP triage_maxitSEXP, SEXP triage_improve_tolSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< const arma::mat& >::type L(LSEXP);
    Rcpp::traits::input_parameter< double >::type gam(gamSEXP);
    Rcpp::traits::input_parameter< double >::type eps(epsSEXP);
    Rcpp::traits::input_parameter< bool >::type normalize(normalizeSEXP);
    Rcpp::traits::input_parameter< int >::type random_starts(random_startsSEXP);
    Rcpp::traits::input_parameter< int >::type maxit(maxitSEXP);
    Rcpp::traits::input_parameter< int >::type max_line_search(max_line_searchSEXP);
    Rcpp::traits::input_parameter< double >::type step0(step0SEXP);
    Rcpp::traits::input_parameter< int >::type screen_keep(screen_keepSEXP);
    Rcpp::traits::input_parameter< int >::type triage_maxit(triage_maxitSEXP);
    Rcpp::traits::input_parameter< double >::type triage_improve_tol(triage_improve_tolSEXP);
    rcpp_result_gen = Rcpp::wrap(rotate_oblimin(L, gam, eps, normalize, random_starts, maxit, max_line_search, step0, screen_keep, triage_maxit, triage_improve_tol));
    return rcpp_result_gen;
END_RCPP
}
// rotate_geomin_orth
Rcpp::List rotate_geomin_orth(const arma::mat& L, double delta, double eps, bool normalize, int random_starts, int maxit, int max_line_search, double step0, int screen_keep, int triage_maxit, double triage_improve_tol);
RcppExport SEXP _EFAtools_rotate_geomin_orth(SEXP LSEXP, SEXP deltaSEXP, SEXP epsSEXP, SEXP normalizeSEXP, SEXP random_startsSEXP, SEXP maxitSEXP, SEXP max_line_searchSEXP, SEXP step0SEXP, SEXP screen_keepSEXP, SEXP triage_maxitSEXP, SEXP triage_improve_tolSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< const arma::mat& >::type L(LSEXP);
    Rcpp::traits::input_parameter< double >::type delta(deltaSEXP);
    Rcpp::traits::input_parameter< double >::type eps(epsSEXP);
    Rcpp::traits::input_parameter< bool >::type normalize(normalizeSEXP);
    Rcpp::traits::input_parameter< int >::type random_starts(random_startsSEXP);
    Rcpp::traits::input_parameter< int >::type maxit(maxitSEXP);
    Rcpp::traits::input_parameter< int >::type max_line_search(max_line_searchSEXP);
    Rcpp::traits::input_parameter< double >::type step0(step0SEXP);
    Rcpp::traits::input_parameter< int >::type screen_keep(screen_keepSEXP);
    Rcpp::traits::input_parameter< int >::type triage_maxit(triage_maxitSEXP);
    Rcpp::traits::input_parameter< double >::type triage_improve_tol(triage_improve_tolSEXP);
    rcpp_result_gen = Rcpp::wrap(rotate_geomin_orth(L, delta, eps, normalize, random_starts, maxit, max_line_search, step0, screen_keep, triage_maxit, triage_improve_tol));
    return rcpp_result_gen;
END_RCPP
}
// rotate_geomin_oblq
Rcpp::List rotate_geomin_oblq(const arma::mat& L, double delta, double eps, bool normalize, int random_starts, int maxit, int max_line_search, double step0, int screen_keep, int triage_maxit, double triage_improve_tol);
RcppExport SEXP _EFAtools_rotate_geomin_oblq(SEXP LSEXP, SEXP deltaSEXP, SEXP epsSEXP, SEXP normalizeSEXP, SEXP random_startsSEXP, SEXP maxitSEXP, SEXP max_line_searchSEXP, SEXP step0SEXP, SEXP screen_keepSEXP, SEXP triage_maxitSEXP, SEXP triage_improve_tolSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< const arma::mat& >::type L(LSEXP);
    Rcpp::traits::input_parameter< double >::type delta(deltaSEXP);
    Rcpp::traits::input_parameter< double >::type eps(epsSEXP);
    Rcpp::traits::input_parameter< bool >::type normalize(normalizeSEXP);
    Rcpp::traits::input_parameter< int >::type random_starts(random_startsSEXP);
    Rcpp::traits::input_parameter< int >::type maxit(maxitSEXP);
    Rcpp::traits::input_parameter< int >::type max_line_search(max_line_searchSEXP);
    Rcpp::traits::input_parameter< double >::type step0(step0SEXP);
    Rcpp::traits::input_parameter< int >::type screen_keep(screen_keepSEXP);
    Rcpp::traits::input_parameter< int >::type triage_maxit(triage_maxitSEXP);
    Rcpp::traits::input_parameter< double >::type triage_improve_tol(triage_improve_tolSEXP);
    rcpp_result_gen = Rcpp::wrap(rotate_geomin_oblq(L, delta, eps, normalize, random_starts, maxit, max_line_search, step0, screen_keep, triage_maxit, triage_improve_tol));
    return rcpp_result_gen;
END_RCPP
}
// rotate_bentler_orth
Rcpp::List rotate_bentler_orth(const arma::mat& L, double eps, bool normalize, int random_starts, int maxit, int max_line_search, double step0, int screen_keep, int triage_maxit, double triage_improve_tol);
RcppExport SEXP _EFAtools_rotate_bentler_orth(SEXP LSEXP, SEXP epsSEXP, SEXP normalizeSEXP, SEXP random_startsSEXP, SEXP maxitSEXP, SEXP max_line_searchSEXP, SEXP step0SEXP, SEXP screen_keepSEXP, SEXP triage_maxitSEXP, SEXP triage_improve_tolSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< const arma::mat& >::type L(LSEXP);
    Rcpp::traits::input_parameter< double >::type eps(epsSEXP);
    Rcpp::traits::input_parameter< bool >::type normalize(normalizeSEXP);
    Rcpp::traits::input_parameter< int >::type random_starts(random_startsSEXP);
    Rcpp::traits::input_parameter< int >::type maxit(maxitSEXP);
    Rcpp::traits::input_parameter< int >::type max_line_search(max_line_searchSEXP);
    Rcpp::traits::input_parameter< double >::type step0(step0SEXP);
    Rcpp::traits::input_parameter< int >::type screen_keep(screen_keepSEXP);
    Rcpp::traits::input_parameter< int >::type triage_maxit(triage_maxitSEXP);
    Rcpp::traits::input_parameter< double >::type triage_improve_tol(triage_improve_tolSEXP);
    rcpp_result_gen = Rcpp::wrap(rotate_bentler_orth(L, eps, normalize, random_starts, maxit, max_line_search, step0, screen_keep, triage_maxit, triage_improve_tol));
    return rcpp_result_gen;
END_RCPP
}
// rotate_bentler_oblq
Rcpp::List rotate_bentler_oblq(const arma::mat& L, double eps, bool normalize, int random_starts, int maxit, int max_line_search, double step0, int screen_keep, int triage_maxit, double triage_improve_tol);
RcppExport SEXP _EFAtools_rotate_bentler_oblq(SEXP LSEXP, SEXP epsSEXP, SEXP normalizeSEXP, SEXP random_startsSEXP, SEXP maxitSEXP, SEXP max_line_searchSEXP, SEXP step0SEXP, SEXP screen_keepSEXP, SEXP triage_maxitSEXP, SEXP triage_improve_tolSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< const arma::mat& >::type L(LSEXP);
    Rcpp::traits::input_parameter< double >::type eps(epsSEXP);
    Rcpp::traits::input_parameter< bool >::type normalize(normalizeSEXP);
    Rcpp::traits::input_parameter< int >::type random_starts(random_startsSEXP);
    Rcpp::traits::input_parameter< int >::type maxit(maxitSEXP);
    Rcpp::traits::input_parameter< int >::type max_line_search(max_line_searchSEXP);
    Rcpp::traits::input_parameter< double >::type step0(step0SEXP);
    Rcpp::traits::input_parameter< int >::type screen_keep(screen_keepSEXP);
    Rcpp::traits::input_parameter< int >::type triage_maxit(triage_maxitSEXP);
    Rcpp::traits::input_parameter< double >::type triage_improve_tol(triage_improve_tolSEXP);
    rcpp_result_gen = Rcpp::wrap(rotate_bentler_oblq(L, eps, normalize, random_starts, maxit, max_line_search, step0, screen_keep, triage_maxit, triage_improve_tol));
    return rcpp_result_gen;
END_RCPP
}
// rotate_bifactor_orth
Rcpp::List rotate_bifactor_orth(const arma::mat& L, double eps, bool normalize, int random_starts, int maxit, int max_line_search, double step0, int screen_keep, int triage_maxit, double triage_improve_tol);
RcppExport SEXP _EFAtools_rotate_bifactor_orth(SEXP LSEXP, SEXP epsSEXP, SEXP normalizeSEXP, SEXP random_startsSEXP, SEXP maxitSEXP, SEXP max_line_searchSEXP, SEXP step0SEXP, SEXP screen_keepSEXP, SEXP triage_maxitSEXP, SEXP triage_improve_tolSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< const arma::mat& >::type L(LSEXP);
    Rcpp::traits::input_parameter< double >::type eps(epsSEXP);
    Rcpp::traits::input_parameter< bool >::type normalize(normalizeSEXP);
    Rcpp::traits::input_parameter< int >::type random_starts(random_startsSEXP);
    Rcpp::traits::input_parameter< int >::type maxit(maxitSEXP);
    Rcpp::traits::input_parameter< int >::type max_line_search(max_line_searchSEXP);
    Rcpp::traits::input_parameter< double >::type step0(step0SEXP);
    Rcpp::traits::input_parameter< int >::type screen_keep(screen_keepSEXP);
    Rcpp::traits::input_parameter< int >::type triage_maxit(triage_maxitSEXP);
    Rcpp::traits::input_parameter< double >::type triage_improve_tol(triage_improve_tolSEXP);
    rcpp_result_gen = Rcpp::wrap(rotate_bifactor_orth(L, eps, normalize, random_starts, maxit, max_line_search, step0, screen_keep, triage_maxit, triage_improve_tol));
    return rcpp_result_gen;
END_RCPP
}
// rotate_bifactor_oblq
Rcpp::List rotate_bifactor_oblq(const arma::mat& L, double eps, bool normalize, int random_starts, int maxit, int max_line_search, double step0, int screen_keep, int triage_maxit, double triage_improve_tol);
RcppExport SEXP _EFAtools_rotate_bifactor_oblq(SEXP LSEXP, SEXP epsSEXP, SEXP normalizeSEXP, SEXP random_startsSEXP, SEXP maxitSEXP, SEXP max_line_searchSEXP, SEXP step0SEXP, SEXP screen_keepSEXP, SEXP triage_maxitSEXP, SEXP triage_improve_tolSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< const arma::mat& >::type L(LSEXP);
    Rcpp::traits::input_parameter< double >::type eps(epsSEXP);
    Rcpp::traits::input_parameter< bool >::type normalize(normalizeSEXP);
    Rcpp::traits::input_parameter< int >::type random_starts(random_startsSEXP);
    Rcpp::traits::input_parameter< int >::type maxit(maxitSEXP);
    Rcpp::traits::input_parameter< int >::type max_line_search(max_line_searchSEXP);
    Rcpp::traits::input_parameter< double >::type step0(step0SEXP);
    Rcpp::traits::input_parameter< int >::type screen_keep(screen_keepSEXP);
    Rcpp::traits::input_parameter< int >::type triage_maxit(triage_maxitSEXP);
    Rcpp::traits::input_parameter< double >::type triage_improve_tol(triage_improve_tolSEXP);
    rcpp_result_gen = Rcpp::wrap(rotate_bifactor_oblq(L, eps, normalize, random_starts, maxit, max_line_search, step0, screen_keep, triage_maxit, triage_improve_tol));
    return rcpp_result_gen;
END_RCPP
}
// rotate_simplimax_oblq
Rcpp::List rotate_simplimax_oblq(const arma::mat& L, int k, double eps, bool normalize, int random_starts, int maxit, int max_line_search, double step0);
RcppExport SEXP _EFAtools_rotate_simplimax_oblq(SEXP LSEXP, SEXP kSEXP, SEXP epsSEXP, SEXP normalizeSEXP, SEXP random_startsSEXP, SEXP maxitSEXP, SEXP max_line_searchSEXP, SEXP step0SEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< const arma::mat& >::type L(LSEXP);
    Rcpp::traits::input_parameter< int >::type k(kSEXP);
    Rcpp::traits::input_parameter< double >::type eps(epsSEXP);
    Rcpp::traits::input_parameter< bool >::type normalize(normalizeSEXP);
    Rcpp::traits::input_parameter< int >::type random_starts(random_startsSEXP);
    Rcpp::traits::input_parameter< int >::type maxit(maxitSEXP);
    Rcpp::traits::input_parameter< int >::type max_line_search(max_line_searchSEXP);
    Rcpp::traits::input_parameter< double >::type step0(step0SEXP);
    rcpp_result_gen = Rcpp::wrap(rotate_simplimax_oblq(L, k, eps, normalize, random_starts, maxit, max_line_search, step0));
    return rcpp_result_gen;
END_RCPP
}
// rotation_se_jacobian
Rcpp::List rotation_se_jacobian(const arma::mat& A, const arma::mat& T_init, std::string method, double param, bool normalize, bool oblique, double eps, int general_col);
RcppExport SEXP _EFAtools_rotation_se_jacobian(SEXP ASEXP, SEXP T_initSEXP, SEXP methodSEXP, SEXP paramSEXP, SEXP normalizeSEXP, SEXP obliqueSEXP, SEXP epsSEXP, SEXP general_colSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< const arma::mat& >::type A(ASEXP);
    Rcpp::traits::input_parameter< const arma::mat& >::type T_init(T_initSEXP);
    Rcpp::traits::input_parameter< std::string >::type method(methodSEXP);
    Rcpp::traits::input_parameter< double >::type param(paramSEXP);
    Rcpp::traits::input_parameter< bool >::type normalize(normalizeSEXP);
    Rcpp::traits::input_parameter< bool >::type oblique(obliqueSEXP);
    Rcpp::traits::input_parameter< double >::type eps(epsSEXP);
    Rcpp::traits::input_parameter< int >::type general_col(general_colSEXP);
    rcpp_result_gen = Rcpp::wrap(rotation_se_jacobian(A, T_init, method, param, normalize, oblique, eps, general_col));
    return rcpp_result_gen;
END_RCPP
}
// simulate_cfm_mvn
arma::mat simulate_cfm_mvn(const arma::mat& R, const int N, const double tol);
RcppExport SEXP _EFAtools_simulate_cfm_mvn(SEXP RSEXP, SEXP NSEXP, SEXP tolSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< const arma::mat& >::type R(RSEXP);
    Rcpp::traits::input_parameter< const int >::type N(NSEXP);
    Rcpp::traits::input_parameter< const double >::type tol(tolSEXP);
    rcpp_result_gen = Rcpp::wrap(simulate_cfm_mvn(R, N, tol));
    return rcpp_result_gen;
END_RCPP
}
// simulate_cfm_eigen
arma::vec simulate_cfm_eigen(const int nf, const int N, const arma::mat& Lambda, const arma::vec& Psi, const int nreps);
RcppExport SEXP _EFAtools_simulate_cfm_eigen(SEXP nfSEXP, SEXP NSEXP, SEXP LambdaSEXP, SEXP PsiSEXP, SEXP nrepsSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< const int >::type nf(nfSEXP);
    Rcpp::traits::input_parameter< const int >::type N(NSEXP);
    Rcpp::traits::input_parameter< const arma::mat& >::type Lambda(LambdaSEXP);
    Rcpp::traits::input_parameter< const arma::vec& >::type Psi(PsiSEXP);
    Rcpp::traits::input_parameter< const int >::type nreps(nrepsSEXP);
    rcpp_result_gen = Rcpp::wrap(simulate_cfm_eigen(nf, N, Lambda, Psi, nreps));
    return rcpp_result_gen;
END_RCPP
}

static const R_CallMethodDef CallEntries[] = {
    {"_EFAtools_fit_ml_cpp", (DL_FUNC) &_EFAtools_fit_ml_cpp, 4},
    {"_EFAtools_error_ml", (DL_FUNC) &_EFAtools_error_ml, 3},
    {"_EFAtools_grad_ml", (DL_FUNC) &_EFAtools_grad_ml, 3},
    {"_EFAtools_fit_uls_cpp", (DL_FUNC) &_EFAtools_fit_uls_cpp, 4},
    {"_EFAtools_uls_residuals", (DL_FUNC) &_EFAtools_uls_residuals, 3},
    {"_EFAtools_grad_uls", (DL_FUNC) &_EFAtools_grad_uls, 3},
    {"_EFAtools_fit_dwls_cpp", (DL_FUNC) &_EFAtools_fit_dwls_cpp, 3},
    {"_EFAtools_dwls_residuals", (DL_FUNC) &_EFAtools_dwls_residuals, 4},
    {"_EFAtools_grad_dwls", (DL_FUNC) &_EFAtools_grad_dwls, 4},
    {"_EFAtools_factor_corres", (DL_FUNC) &_EFAtools_factor_corres, 3},
    {"_EFAtools_oblique_procrustes", (DL_FUNC) &_EFAtools_oblique_procrustes, 13},
    {"_EFAtools_oblique_procrustes_batch", (DL_FUNC) &_EFAtools_oblique_procrustes_batch, 11},
    {"_EFAtools_paf_iter", (DL_FUNC) &_EFAtools_paf_iter, 7},
    {"_EFAtools_parallel_sim", (DL_FUNC) &_EFAtools_parallel_sim, 5},
    {"_EFAtools_polychoric_cpp", (DL_FUNC) &_EFAtools_polychoric_cpp, 3},
    {"_EFAtools_bvn_rect_cpp", (DL_FUNC) &_EFAtools_bvn_rect_cpp, 5},
    {"_EFAtools_rotate_cf_orth", (DL_FUNC) &_EFAtools_rotate_cf_orth, 11},
    {"_EFAtools_rotate_oblimin", (DL_FUNC) &_EFAtools_rotate_oblimin, 11},
    {"_EFAtools_rotate_geomin_orth", (DL_FUNC) &_EFAtools_rotate_geomin_orth, 11},
    {"_EFAtools_rotate_geomin_oblq", (DL_FUNC) &_EFAtools_rotate_geomin_oblq, 11},
    {"_EFAtools_rotate_bentler_orth", (DL_FUNC) &_EFAtools_rotate_bentler_orth, 10},
    {"_EFAtools_rotate_bentler_oblq", (DL_FUNC) &_EFAtools_rotate_bentler_oblq, 10},
    {"_EFAtools_rotate_bifactor_orth", (DL_FUNC) &_EFAtools_rotate_bifactor_orth, 10},
    {"_EFAtools_rotate_bifactor_oblq", (DL_FUNC) &_EFAtools_rotate_bifactor_oblq, 10},
    {"_EFAtools_rotate_simplimax_oblq", (DL_FUNC) &_EFAtools_rotate_simplimax_oblq, 8},
    {"_EFAtools_rotation_se_jacobian", (DL_FUNC) &_EFAtools_rotation_se_jacobian, 8},
    {"_EFAtools_simulate_cfm_mvn", (DL_FUNC) &_EFAtools_simulate_cfm_mvn, 3},
    {"_EFAtools_simulate_cfm_eigen", (DL_FUNC) &_EFAtools_simulate_cfm_eigen, 5},
    {NULL, NULL, 0}
};

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