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

// 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
}
// grad_ml
arma::vec grad_ml(arma::vec psi, 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< 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
}
// error_ml
double error_ml(arma::vec psi, 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< 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
}
// nest_sym
arma::vec nest_sym(const int nf, const int N, arma::mat M, const int nreps);
RcppExport SEXP _EFAtools_nest_sym(SEXP nfSEXP, SEXP NSEXP, SEXP MSEXP, 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< arma::mat >::type M(MSEXP);
    Rcpp::traits::input_parameter< const int >::type nreps(nrepsSEXP);
    rcpp_result_gen = Rcpp::wrap(nest_sym(nf, N, M, nreps));
    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
}
// grad_uls
arma::vec grad_uls(arma::vec psi, 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< 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
}
// uls_residuals
double uls_residuals(arma::vec psi, 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< 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
}

static const R_CallMethodDef CallEntries[] = {
    {"_EFAtools_factor_corres", (DL_FUNC) &_EFAtools_factor_corres, 3},
    {"_EFAtools_grad_ml", (DL_FUNC) &_EFAtools_grad_ml, 3},
    {"_EFAtools_error_ml", (DL_FUNC) &_EFAtools_error_ml, 3},
    {"_EFAtools_nest_sym", (DL_FUNC) &_EFAtools_nest_sym, 4},
    {"_EFAtools_paf_iter", (DL_FUNC) &_EFAtools_paf_iter, 7},
    {"_EFAtools_parallel_sim", (DL_FUNC) &_EFAtools_parallel_sim, 5},
    {"_EFAtools_grad_uls", (DL_FUNC) &_EFAtools_grad_uls, 3},
    {"_EFAtools_uls_residuals", (DL_FUNC) &_EFAtools_uls_residuals, 3},
    {NULL, NULL, 0}
};

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