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

#include <RcppEigen.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

// gauss_hermite_quadrature
List gauss_hermite_quadrature(int n);
RcppExport SEXP _factorana_gauss_hermite_quadrature(SEXP nSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< int >::type n(nSEXP);
    rcpp_result_gen = Rcpp::wrap(gauss_hermite_quadrature(n));
    return rcpp_result_gen;
END_RCPP
}
// initialize_factor_model_cpp
SEXP initialize_factor_model_cpp(List model_system, SEXP data, int n_quad, Nullable<NumericVector> init_params);
RcppExport SEXP _factorana_initialize_factor_model_cpp(SEXP model_systemSEXP, SEXP dataSEXP, SEXP n_quadSEXP, SEXP init_paramsSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< List >::type model_system(model_systemSEXP);
    Rcpp::traits::input_parameter< SEXP >::type data(dataSEXP);
    Rcpp::traits::input_parameter< int >::type n_quad(n_quadSEXP);
    Rcpp::traits::input_parameter< Nullable<NumericVector> >::type init_params(init_paramsSEXP);
    rcpp_result_gen = Rcpp::wrap(initialize_factor_model_cpp(model_system, data, n_quad, init_params));
    return rcpp_result_gen;
END_RCPP
}
// evaluate_likelihood_cpp
List evaluate_likelihood_cpp(SEXP fm_ptr, NumericVector params, bool compute_gradient, bool compute_hessian);
RcppExport SEXP _factorana_evaluate_likelihood_cpp(SEXP fm_ptrSEXP, SEXP paramsSEXP, SEXP compute_gradientSEXP, SEXP compute_hessianSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< SEXP >::type fm_ptr(fm_ptrSEXP);
    Rcpp::traits::input_parameter< NumericVector >::type params(paramsSEXP);
    Rcpp::traits::input_parameter< bool >::type compute_gradient(compute_gradientSEXP);
    Rcpp::traits::input_parameter< bool >::type compute_hessian(compute_hessianSEXP);
    rcpp_result_gen = Rcpp::wrap(evaluate_likelihood_cpp(fm_ptr, params, compute_gradient, compute_hessian));
    return rcpp_result_gen;
END_RCPP
}
// evaluate_loglik_only_cpp
double evaluate_loglik_only_cpp(SEXP fm_ptr, NumericVector params);
RcppExport SEXP _factorana_evaluate_loglik_only_cpp(SEXP fm_ptrSEXP, SEXP paramsSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< SEXP >::type fm_ptr(fm_ptrSEXP);
    Rcpp::traits::input_parameter< NumericVector >::type params(paramsSEXP);
    rcpp_result_gen = Rcpp::wrap(evaluate_loglik_only_cpp(fm_ptr, params));
    return rcpp_result_gen;
END_RCPP
}
// get_parameter_info_cpp
List get_parameter_info_cpp(SEXP fm_ptr);
RcppExport SEXP _factorana_get_parameter_info_cpp(SEXP fm_ptrSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< SEXP >::type fm_ptr(fm_ptrSEXP);
    rcpp_result_gen = Rcpp::wrap(get_parameter_info_cpp(fm_ptr));
    return rcpp_result_gen;
END_RCPP
}
// extract_free_params_cpp
NumericVector extract_free_params_cpp(SEXP fm_ptr, NumericVector full_params);
RcppExport SEXP _factorana_extract_free_params_cpp(SEXP fm_ptrSEXP, SEXP full_paramsSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< SEXP >::type fm_ptr(fm_ptrSEXP);
    Rcpp::traits::input_parameter< NumericVector >::type full_params(full_paramsSEXP);
    rcpp_result_gen = Rcpp::wrap(extract_free_params_cpp(fm_ptr, full_params));
    return rcpp_result_gen;
END_RCPP
}
// set_observation_weights_cpp
void set_observation_weights_cpp(SEXP fm_ptr, NumericVector weights);
RcppExport SEXP _factorana_set_observation_weights_cpp(SEXP fm_ptrSEXP, SEXP weightsSEXP) {
BEGIN_RCPP
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< SEXP >::type fm_ptr(fm_ptrSEXP);
    Rcpp::traits::input_parameter< NumericVector >::type weights(weightsSEXP);
    set_observation_weights_cpp(fm_ptr, weights);
    return R_NilValue;
END_RCPP
}
// set_adaptive_quadrature_cpp
void set_adaptive_quadrature_cpp(SEXP fm_ptr, NumericMatrix factor_scores, NumericMatrix factor_ses, NumericVector factor_vars, double threshold, int max_quad, bool verbose);
RcppExport SEXP _factorana_set_adaptive_quadrature_cpp(SEXP fm_ptrSEXP, SEXP factor_scoresSEXP, SEXP factor_sesSEXP, SEXP factor_varsSEXP, SEXP thresholdSEXP, SEXP max_quadSEXP, SEXP verboseSEXP) {
BEGIN_RCPP
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< SEXP >::type fm_ptr(fm_ptrSEXP);
    Rcpp::traits::input_parameter< NumericMatrix >::type factor_scores(factor_scoresSEXP);
    Rcpp::traits::input_parameter< NumericMatrix >::type factor_ses(factor_sesSEXP);
    Rcpp::traits::input_parameter< NumericVector >::type factor_vars(factor_varsSEXP);
    Rcpp::traits::input_parameter< double >::type threshold(thresholdSEXP);
    Rcpp::traits::input_parameter< int >::type max_quad(max_quadSEXP);
    Rcpp::traits::input_parameter< bool >::type verbose(verboseSEXP);
    set_adaptive_quadrature_cpp(fm_ptr, factor_scores, factor_ses, factor_vars, threshold, max_quad, verbose);
    return R_NilValue;
END_RCPP
}
// disable_adaptive_quadrature_cpp
void disable_adaptive_quadrature_cpp(SEXP fm_ptr);
RcppExport SEXP _factorana_disable_adaptive_quadrature_cpp(SEXP fm_ptrSEXP) {
BEGIN_RCPP
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< SEXP >::type fm_ptr(fm_ptrSEXP);
    disable_adaptive_quadrature_cpp(fm_ptr);
    return R_NilValue;
END_RCPP
}
// evaluate_factorscore_likelihood_cpp
List evaluate_factorscore_likelihood_cpp(SEXP fm_ptr, int iobs, NumericVector factor_values, NumericVector model_params, bool compute_gradient, bool compute_hessian, bool include_prior);
RcppExport SEXP _factorana_evaluate_factorscore_likelihood_cpp(SEXP fm_ptrSEXP, SEXP iobsSEXP, SEXP factor_valuesSEXP, SEXP model_paramsSEXP, SEXP compute_gradientSEXP, SEXP compute_hessianSEXP, SEXP include_priorSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< SEXP >::type fm_ptr(fm_ptrSEXP);
    Rcpp::traits::input_parameter< int >::type iobs(iobsSEXP);
    Rcpp::traits::input_parameter< NumericVector >::type factor_values(factor_valuesSEXP);
    Rcpp::traits::input_parameter< NumericVector >::type model_params(model_paramsSEXP);
    Rcpp::traits::input_parameter< bool >::type compute_gradient(compute_gradientSEXP);
    Rcpp::traits::input_parameter< bool >::type compute_hessian(compute_hessianSEXP);
    Rcpp::traits::input_parameter< bool >::type include_prior(include_priorSEXP);
    rcpp_result_gen = Rcpp::wrap(evaluate_factorscore_likelihood_cpp(fm_ptr, iobs, factor_values, model_params, compute_gradient, compute_hessian, include_prior));
    return rcpp_result_gen;
END_RCPP
}

RcppExport SEXP _rcpp_module_boot_factorana_module();

static const R_CallMethodDef CallEntries[] = {
    {"_factorana_gauss_hermite_quadrature", (DL_FUNC) &_factorana_gauss_hermite_quadrature, 1},
    {"_factorana_initialize_factor_model_cpp", (DL_FUNC) &_factorana_initialize_factor_model_cpp, 4},
    {"_factorana_evaluate_likelihood_cpp", (DL_FUNC) &_factorana_evaluate_likelihood_cpp, 4},
    {"_factorana_evaluate_loglik_only_cpp", (DL_FUNC) &_factorana_evaluate_loglik_only_cpp, 2},
    {"_factorana_get_parameter_info_cpp", (DL_FUNC) &_factorana_get_parameter_info_cpp, 1},
    {"_factorana_extract_free_params_cpp", (DL_FUNC) &_factorana_extract_free_params_cpp, 2},
    {"_factorana_set_observation_weights_cpp", (DL_FUNC) &_factorana_set_observation_weights_cpp, 2},
    {"_factorana_set_adaptive_quadrature_cpp", (DL_FUNC) &_factorana_set_adaptive_quadrature_cpp, 7},
    {"_factorana_disable_adaptive_quadrature_cpp", (DL_FUNC) &_factorana_disable_adaptive_quadrature_cpp, 1},
    {"_factorana_evaluate_factorscore_likelihood_cpp", (DL_FUNC) &_factorana_evaluate_factorscore_likelihood_cpp, 7},
    {"_rcpp_module_boot_factorana_module", (DL_FUNC) &_rcpp_module_boot_factorana_module, 0},
    {NULL, NULL, 0}
};

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