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

// gsc_ife_cpp
Rcpp::List gsc_ife_cpp(const arma::mat& Y_co, const arma::mat& Y_tr_pre, int r, const arma::cube& X_co, const arma::cube& X_tr_pre, int max_iter, double tol);
RcppExport SEXP _coresynth_gsc_ife_cpp(SEXP Y_coSEXP, SEXP Y_tr_preSEXP, SEXP rSEXP, SEXP X_coSEXP, SEXP X_tr_preSEXP, SEXP max_iterSEXP, SEXP tolSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< const arma::mat& >::type Y_co(Y_coSEXP);
    Rcpp::traits::input_parameter< const arma::mat& >::type Y_tr_pre(Y_tr_preSEXP);
    Rcpp::traits::input_parameter< int >::type r(rSEXP);
    Rcpp::traits::input_parameter< const arma::cube& >::type X_co(X_coSEXP);
    Rcpp::traits::input_parameter< const arma::cube& >::type X_tr_pre(X_tr_preSEXP);
    Rcpp::traits::input_parameter< int >::type max_iter(max_iterSEXP);
    Rcpp::traits::input_parameter< double >::type tol(tolSEXP);
    rcpp_result_gen = Rcpp::wrap(gsc_ife_cpp(Y_co, Y_tr_pre, r, X_co, X_tr_pre, max_iter, tol));
    return rcpp_result_gen;
END_RCPP
}
// sdid_placebo_cpp
arma::vec sdid_placebo_cpp(const arma::mat& Y_pre, const arma::mat& Y_post, const arma::vec& time_weights, double zeta2);
RcppExport SEXP _coresynth_sdid_placebo_cpp(SEXP Y_preSEXP, SEXP Y_postSEXP, SEXP time_weightsSEXP, SEXP zeta2SEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< const arma::mat& >::type Y_pre(Y_preSEXP);
    Rcpp::traits::input_parameter< const arma::mat& >::type Y_post(Y_postSEXP);
    Rcpp::traits::input_parameter< const arma::vec& >::type time_weights(time_weightsSEXP);
    Rcpp::traits::input_parameter< double >::type zeta2(zeta2SEXP);
    rcpp_result_gen = Rcpp::wrap(sdid_placebo_cpp(Y_pre, Y_post, time_weights, zeta2));
    return rcpp_result_gen;
END_RCPP
}
// scm_placebo_cpp
Rcpp::List scm_placebo_cpp(const arma::mat& Y_pre, const arma::mat& Y_post, int max_iter, double tol);
RcppExport SEXP _coresynth_scm_placebo_cpp(SEXP Y_preSEXP, SEXP Y_postSEXP, SEXP max_iterSEXP, SEXP tolSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< const arma::mat& >::type Y_pre(Y_preSEXP);
    Rcpp::traits::input_parameter< const arma::mat& >::type Y_post(Y_postSEXP);
    Rcpp::traits::input_parameter< int >::type max_iter(max_iterSEXP);
    Rcpp::traits::input_parameter< double >::type tol(tolSEXP);
    rcpp_result_gen = Rcpp::wrap(scm_placebo_cpp(Y_pre, Y_post, max_iter, tol));
    return rcpp_result_gen;
END_RCPP
}
// soft_impute_cpp
arma::mat soft_impute_cpp(const arma::mat& Y, const arma::mat& O, double lambda, int max_iter, double tol);
RcppExport SEXP _coresynth_soft_impute_cpp(SEXP YSEXP, SEXP OSEXP, SEXP lambdaSEXP, SEXP max_iterSEXP, SEXP tolSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< const arma::mat& >::type Y(YSEXP);
    Rcpp::traits::input_parameter< const arma::mat& >::type O(OSEXP);
    Rcpp::traits::input_parameter< double >::type lambda(lambdaSEXP);
    Rcpp::traits::input_parameter< int >::type max_iter(max_iterSEXP);
    Rcpp::traits::input_parameter< double >::type tol(tolSEXP);
    rcpp_result_gen = Rcpp::wrap(soft_impute_cpp(Y, O, lambda, max_iter, tol));
    return rcpp_result_gen;
END_RCPP
}
// proj_simplex
arma::vec proj_simplex(arma::vec y);
RcppExport SEXP _coresynth_proj_simplex(SEXP ySEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< arma::vec >::type y(ySEXP);
    rcpp_result_gen = Rcpp::wrap(proj_simplex(y));
    return rcpp_result_gen;
END_RCPP
}
// solve_simplex_qp
arma::vec solve_simplex_qp(const arma::mat& Q, const arma::vec& c, int max_iter, double tol);
RcppExport SEXP _coresynth_solve_simplex_qp(SEXP QSEXP, SEXP cSEXP, SEXP max_iterSEXP, SEXP tolSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< const arma::mat& >::type Q(QSEXP);
    Rcpp::traits::input_parameter< const arma::vec& >::type c(cSEXP);
    Rcpp::traits::input_parameter< int >::type max_iter(max_iterSEXP);
    Rcpp::traits::input_parameter< double >::type tol(tolSEXP);
    rcpp_result_gen = Rcpp::wrap(solve_simplex_qp(Q, c, max_iter, tol));
    return rcpp_result_gen;
END_RCPP
}
// scm_inner_weights_cpp
arma::vec scm_inner_weights_cpp(const arma::mat& X0, const arma::vec& X1, const arma::vec& V_diag);
RcppExport SEXP _coresynth_scm_inner_weights_cpp(SEXP X0SEXP, SEXP X1SEXP, SEXP V_diagSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< const arma::mat& >::type X0(X0SEXP);
    Rcpp::traits::input_parameter< const arma::vec& >::type X1(X1SEXP);
    Rcpp::traits::input_parameter< const arma::vec& >::type V_diag(V_diagSEXP);
    rcpp_result_gen = Rcpp::wrap(scm_inner_weights_cpp(X0, X1, V_diag));
    return rcpp_result_gen;
END_RCPP
}
// scm_weights_cpp
Rcpp::List scm_weights_cpp(const arma::mat& X0, const arma::vec& X1, const arma::mat& Z0, const arma::vec& Z1, int max_iter, double tol, int t_train);
RcppExport SEXP _coresynth_scm_weights_cpp(SEXP X0SEXP, SEXP X1SEXP, SEXP Z0SEXP, SEXP Z1SEXP, SEXP max_iterSEXP, SEXP tolSEXP, SEXP t_trainSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< const arma::mat& >::type X0(X0SEXP);
    Rcpp::traits::input_parameter< const arma::vec& >::type X1(X1SEXP);
    Rcpp::traits::input_parameter< const arma::mat& >::type Z0(Z0SEXP);
    Rcpp::traits::input_parameter< const arma::vec& >::type Z1(Z1SEXP);
    Rcpp::traits::input_parameter< int >::type max_iter(max_iterSEXP);
    Rcpp::traits::input_parameter< double >::type tol(tolSEXP);
    Rcpp::traits::input_parameter< int >::type t_train(t_trainSEXP);
    rcpp_result_gen = Rcpp::wrap(scm_weights_cpp(X0, X1, Z0, Z1, max_iter, tol, t_train));
    return rcpp_result_gen;
END_RCPP
}
// sdid_unit_weights_cpp
arma::vec sdid_unit_weights_cpp(const arma::mat& Y_pre, const arma::vec& Y_tr_pre, double zeta2);
RcppExport SEXP _coresynth_sdid_unit_weights_cpp(SEXP Y_preSEXP, SEXP Y_tr_preSEXP, SEXP zeta2SEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< const arma::mat& >::type Y_pre(Y_preSEXP);
    Rcpp::traits::input_parameter< const arma::vec& >::type Y_tr_pre(Y_tr_preSEXP);
    Rcpp::traits::input_parameter< double >::type zeta2(zeta2SEXP);
    rcpp_result_gen = Rcpp::wrap(sdid_unit_weights_cpp(Y_pre, Y_tr_pre, zeta2));
    return rcpp_result_gen;
END_RCPP
}
// sdid_time_weights_cpp
arma::vec sdid_time_weights_cpp(const arma::mat& Y_pre_co, const arma::vec& Y_post_target, double zeta_t);
RcppExport SEXP _coresynth_sdid_time_weights_cpp(SEXP Y_pre_coSEXP, SEXP Y_post_targetSEXP, SEXP zeta_tSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< const arma::mat& >::type Y_pre_co(Y_pre_coSEXP);
    Rcpp::traits::input_parameter< const arma::vec& >::type Y_post_target(Y_post_targetSEXP);
    Rcpp::traits::input_parameter< double >::type zeta_t(zeta_tSEXP);
    rcpp_result_gen = Rcpp::wrap(sdid_time_weights_cpp(Y_pre_co, Y_post_target, zeta_t));
    return rcpp_result_gen;
END_RCPP
}
// sdid_estimate_cpp
double sdid_estimate_cpp(const arma::mat& Y_pre_co, const arma::mat& Y_post_co, const arma::vec& Y_pre_tr, const arma::vec& Y_post_tr, const arma::vec& omega, const arma::vec& lambda);
RcppExport SEXP _coresynth_sdid_estimate_cpp(SEXP Y_pre_coSEXP, SEXP Y_post_coSEXP, SEXP Y_pre_trSEXP, SEXP Y_post_trSEXP, SEXP omegaSEXP, SEXP lambdaSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< const arma::mat& >::type Y_pre_co(Y_pre_coSEXP);
    Rcpp::traits::input_parameter< const arma::mat& >::type Y_post_co(Y_post_coSEXP);
    Rcpp::traits::input_parameter< const arma::vec& >::type Y_pre_tr(Y_pre_trSEXP);
    Rcpp::traits::input_parameter< const arma::vec& >::type Y_post_tr(Y_post_trSEXP);
    Rcpp::traits::input_parameter< const arma::vec& >::type omega(omegaSEXP);
    Rcpp::traits::input_parameter< const arma::vec& >::type lambda(lambdaSEXP);
    rcpp_result_gen = Rcpp::wrap(sdid_estimate_cpp(Y_pre_co, Y_post_co, Y_pre_tr, Y_post_tr, omega, lambda));
    return rcpp_result_gen;
END_RCPP
}
// tensor_unfold_cpp
arma::mat tensor_unfold_cpp(const arma::cube& T_cube, int mode);
RcppExport SEXP _coresynth_tensor_unfold_cpp(SEXP T_cubeSEXP, SEXP modeSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< const arma::cube& >::type T_cube(T_cubeSEXP);
    Rcpp::traits::input_parameter< int >::type mode(modeSEXP);
    rcpp_result_gen = Rcpp::wrap(tensor_unfold_cpp(T_cube, mode));
    return rcpp_result_gen;
END_RCPP
}
// si_pcr_cpp
Rcpp::List si_pcr_cpp(const arma::mat& Y_pre_co, const arma::mat& Y_post_co, const arma::mat& Y_pre_tr, int k);
RcppExport SEXP _coresynth_si_pcr_cpp(SEXP Y_pre_coSEXP, SEXP Y_post_coSEXP, SEXP Y_pre_trSEXP, SEXP kSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< const arma::mat& >::type Y_pre_co(Y_pre_coSEXP);
    Rcpp::traits::input_parameter< const arma::mat& >::type Y_post_co(Y_post_coSEXP);
    Rcpp::traits::input_parameter< const arma::mat& >::type Y_pre_tr(Y_pre_trSEXP);
    Rcpp::traits::input_parameter< int >::type k(kSEXP);
    rcpp_result_gen = Rcpp::wrap(si_pcr_cpp(Y_pre_co, Y_post_co, Y_pre_tr, k));
    return rcpp_result_gen;
END_RCPP
}
// kalman_smoother_cpp
Rcpp::List kalman_smoother_cpp(const arma::mat& Y, const arma::mat& W, const arma::mat& A, const arma::vec& C, const arma::mat& Q, const arma::mat& R, const arma::vec& z0, const arma::mat& P0);
RcppExport SEXP _coresynth_kalman_smoother_cpp(SEXP YSEXP, SEXP WSEXP, SEXP ASEXP, SEXP CSEXP, SEXP QSEXP, SEXP RSEXP, SEXP z0SEXP, SEXP P0SEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< const arma::mat& >::type Y(YSEXP);
    Rcpp::traits::input_parameter< const arma::mat& >::type W(WSEXP);
    Rcpp::traits::input_parameter< const arma::mat& >::type A(ASEXP);
    Rcpp::traits::input_parameter< const arma::vec& >::type C(CSEXP);
    Rcpp::traits::input_parameter< const arma::mat& >::type Q(QSEXP);
    Rcpp::traits::input_parameter< const arma::mat& >::type R(RSEXP);
    Rcpp::traits::input_parameter< const arma::vec& >::type z0(z0SEXP);
    Rcpp::traits::input_parameter< const arma::mat& >::type P0(P0SEXP);
    rcpp_result_gen = Rcpp::wrap(kalman_smoother_cpp(Y, W, A, C, Q, R, z0, P0));
    return rcpp_result_gen;
END_RCPP
}

static const R_CallMethodDef CallEntries[] = {
    {"_coresynth_gsc_ife_cpp", (DL_FUNC) &_coresynth_gsc_ife_cpp, 7},
    {"_coresynth_sdid_placebo_cpp", (DL_FUNC) &_coresynth_sdid_placebo_cpp, 4},
    {"_coresynth_scm_placebo_cpp", (DL_FUNC) &_coresynth_scm_placebo_cpp, 4},
    {"_coresynth_soft_impute_cpp", (DL_FUNC) &_coresynth_soft_impute_cpp, 5},
    {"_coresynth_proj_simplex", (DL_FUNC) &_coresynth_proj_simplex, 1},
    {"_coresynth_solve_simplex_qp", (DL_FUNC) &_coresynth_solve_simplex_qp, 4},
    {"_coresynth_scm_inner_weights_cpp", (DL_FUNC) &_coresynth_scm_inner_weights_cpp, 3},
    {"_coresynth_scm_weights_cpp", (DL_FUNC) &_coresynth_scm_weights_cpp, 7},
    {"_coresynth_sdid_unit_weights_cpp", (DL_FUNC) &_coresynth_sdid_unit_weights_cpp, 3},
    {"_coresynth_sdid_time_weights_cpp", (DL_FUNC) &_coresynth_sdid_time_weights_cpp, 3},
    {"_coresynth_sdid_estimate_cpp", (DL_FUNC) &_coresynth_sdid_estimate_cpp, 6},
    {"_coresynth_tensor_unfold_cpp", (DL_FUNC) &_coresynth_tensor_unfold_cpp, 2},
    {"_coresynth_si_pcr_cpp", (DL_FUNC) &_coresynth_si_pcr_cpp, 4},
    {"_coresynth_kalman_smoother_cpp", (DL_FUNC) &_coresynth_kalman_smoother_cpp, 8},
    {NULL, NULL, 0}
};

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