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

// efficient_matrix_mult
arma::mat efficient_matrix_mult(const arma::mat& A, const arma::mat& B);
RcppExport SEXP _lgspline_efficient_matrix_mult(SEXP ASEXP, SEXP BSEXP) {
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_result_gen = Rcpp::wrap(efficient_matrix_mult(A, B));
    return rcpp_result_gen;
END_RCPP
}
// gramMatrix
arma::mat gramMatrix(const arma::mat& X);
RcppExport SEXP _lgspline_gramMatrix(SEXP XSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< const arma::mat& >::type X(XSEXP);
    rcpp_result_gen = Rcpp::wrap(gramMatrix(X));
    return rcpp_result_gen;
END_RCPP
}
// armaInv
arma::mat armaInv(const arma::mat& x);
RcppExport SEXP _lgspline_armaInv(SEXP xSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< const arma::mat& >::type x(xSEXP);
    rcpp_result_gen = Rcpp::wrap(armaInv(x));
    return rcpp_result_gen;
END_RCPP
}
// GAmult
Rcpp::List GAmult(const Rcpp::List& G, const arma::mat& A, int K, int nc, int nca);
RcppExport SEXP _lgspline_GAmult(SEXP GSEXP, SEXP ASEXP, SEXP KSEXP, SEXP ncSEXP, SEXP ncaSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< const Rcpp::List& >::type G(GSEXP);
    Rcpp::traits::input_parameter< const arma::mat& >::type A(ASEXP);
    Rcpp::traits::input_parameter< int >::type K(KSEXP);
    Rcpp::traits::input_parameter< int >::type nc(ncSEXP);
    Rcpp::traits::input_parameter< int >::type nca(ncaSEXP);
    rcpp_result_gen = Rcpp::wrap(GAmult(G, A, K, nc, nca));
    return rcpp_result_gen;
END_RCPP
}
// compute_trace_correction
double compute_trace_correction(const Rcpp::List& G, const arma::mat& A, const Rcpp::List& GXX, const arma::mat& AGAInv, int nc, int K);
RcppExport SEXP _lgspline_compute_trace_correction(SEXP GSEXP, SEXP ASEXP, SEXP GXXSEXP, SEXP AGAInvSEXP, SEXP ncSEXP, SEXP KSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< const Rcpp::List& >::type G(GSEXP);
    Rcpp::traits::input_parameter< const arma::mat& >::type A(ASEXP);
    Rcpp::traits::input_parameter< const Rcpp::List& >::type GXX(GXXSEXP);
    Rcpp::traits::input_parameter< const arma::mat& >::type AGAInv(AGAInvSEXP);
    Rcpp::traits::input_parameter< int >::type nc(ncSEXP);
    Rcpp::traits::input_parameter< int >::type K(KSEXP);
    rcpp_result_gen = Rcpp::wrap(compute_trace_correction(G, A, GXX, AGAInv, nc, K));
    return rcpp_result_gen;
END_RCPP
}
// AGAmult
arma::mat AGAmult(const Rcpp::List& G, const arma::mat& A, int K, int nc, int nca);
RcppExport SEXP _lgspline_AGAmult(SEXP GSEXP, SEXP ASEXP, SEXP KSEXP, SEXP ncSEXP, SEXP ncaSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< const Rcpp::List& >::type G(GSEXP);
    Rcpp::traits::input_parameter< const arma::mat& >::type A(ASEXP);
    Rcpp::traits::input_parameter< int >::type K(KSEXP);
    Rcpp::traits::input_parameter< int >::type nc(ncSEXP);
    Rcpp::traits::input_parameter< int >::type nca(ncaSEXP);
    rcpp_result_gen = Rcpp::wrap(AGAmult(G, A, K, nc, nca));
    return rcpp_result_gen;
END_RCPP
}
// AGAmult_chunk
arma::mat AGAmult_chunk(const Rcpp::List& G_chunk, const arma::mat& A, int chunk_start, int chunk_end, int nc);
RcppExport SEXP _lgspline_AGAmult_chunk(SEXP G_chunkSEXP, SEXP ASEXP, SEXP chunk_startSEXP, SEXP chunk_endSEXP, SEXP ncSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< const Rcpp::List& >::type G_chunk(G_chunkSEXP);
    Rcpp::traits::input_parameter< const arma::mat& >::type A(ASEXP);
    Rcpp::traits::input_parameter< int >::type chunk_start(chunk_startSEXP);
    Rcpp::traits::input_parameter< int >::type chunk_end(chunk_endSEXP);
    Rcpp::traits::input_parameter< int >::type nc(ncSEXP);
    rcpp_result_gen = Rcpp::wrap(AGAmult_chunk(G_chunk, A, chunk_start, chunk_end, nc));
    return rcpp_result_gen;
END_RCPP
}
// compute_AGXy
arma::vec compute_AGXy(const Rcpp::List& G, const arma::mat& A, const Rcpp::List& Xy, int nc, int K, int start, int end);
RcppExport SEXP _lgspline_compute_AGXy(SEXP GSEXP, SEXP ASEXP, SEXP XySEXP, SEXP ncSEXP, SEXP KSEXP, SEXP startSEXP, SEXP endSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< const Rcpp::List& >::type G(GSEXP);
    Rcpp::traits::input_parameter< const arma::mat& >::type A(ASEXP);
    Rcpp::traits::input_parameter< const Rcpp::List& >::type Xy(XySEXP);
    Rcpp::traits::input_parameter< int >::type nc(ncSEXP);
    Rcpp::traits::input_parameter< int >::type K(KSEXP);
    Rcpp::traits::input_parameter< int >::type start(startSEXP);
    Rcpp::traits::input_parameter< int >::type end(endSEXP);
    rcpp_result_gen = Rcpp::wrap(compute_AGXy(G, A, Xy, nc, K, start, end));
    return rcpp_result_gen;
END_RCPP
}
// compute_result_blocks
arma::vec compute_result_blocks(const Rcpp::List& G, const Rcpp::List& Ghalf, const arma::mat& A, const arma::vec& AAGAInvAGXy, int nc, int start, int end);
RcppExport SEXP _lgspline_compute_result_blocks(SEXP GSEXP, SEXP GhalfSEXP, SEXP ASEXP, SEXP AAGAInvAGXySEXP, SEXP ncSEXP, SEXP startSEXP, SEXP endSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< const Rcpp::List& >::type G(GSEXP);
    Rcpp::traits::input_parameter< const Rcpp::List& >::type Ghalf(GhalfSEXP);
    Rcpp::traits::input_parameter< const arma::mat& >::type A(ASEXP);
    Rcpp::traits::input_parameter< const arma::vec& >::type AAGAInvAGXy(AAGAInvAGXySEXP);
    Rcpp::traits::input_parameter< int >::type nc(ncSEXP);
    Rcpp::traits::input_parameter< int >::type start(startSEXP);
    Rcpp::traits::input_parameter< int >::type end(endSEXP);
    rcpp_result_gen = Rcpp::wrap(compute_result_blocks(G, Ghalf, A, AAGAInvAGXy, nc, start, end));
    return rcpp_result_gen;
END_RCPP
}
// matmult_block_diagonal_cpp
Rcpp::List matmult_block_diagonal_cpp(const Rcpp::List& A, const Rcpp::List& B, int K);
RcppExport SEXP _lgspline_matmult_block_diagonal_cpp(SEXP ASEXP, SEXP BSEXP, SEXP KSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< const Rcpp::List& >::type A(ASEXP);
    Rcpp::traits::input_parameter< const Rcpp::List& >::type B(BSEXP);
    Rcpp::traits::input_parameter< int >::type K(KSEXP);
    rcpp_result_gen = Rcpp::wrap(matmult_block_diagonal_cpp(A, B, K));
    return rcpp_result_gen;
END_RCPP
}
// vectorproduct_block_diagonal
Rcpp::List vectorproduct_block_diagonal(const Rcpp::List& A, const Rcpp::List& b, int K);
RcppExport SEXP _lgspline_vectorproduct_block_diagonal(SEXP ASEXP, SEXP bSEXP, SEXP KSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< const Rcpp::List& >::type A(ASEXP);
    Rcpp::traits::input_parameter< const Rcpp::List& >::type b(bSEXP);
    Rcpp::traits::input_parameter< int >::type K(KSEXP);
    rcpp_result_gen = Rcpp::wrap(vectorproduct_block_diagonal(A, b, K));
    return rcpp_result_gen;
END_RCPP
}
// matadd_block_diagonal
Rcpp::List matadd_block_diagonal(const Rcpp::List& A, const Rcpp::List& B, int K);
RcppExport SEXP _lgspline_matadd_block_diagonal(SEXP ASEXP, SEXP BSEXP, SEXP KSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< const Rcpp::List& >::type A(ASEXP);
    Rcpp::traits::input_parameter< const Rcpp::List& >::type B(BSEXP);
    Rcpp::traits::input_parameter< int >::type K(KSEXP);
    rcpp_result_gen = Rcpp::wrap(matadd_block_diagonal(A, B, K));
    return rcpp_result_gen;
END_RCPP
}
// compute_dW_dlambda
double compute_dW_dlambda(const Rcpp::List& G, const arma::mat& A, const Rcpp::List& GXX, const Rcpp::List& Ghalf, const Rcpp::List& dG_dlambda, const Rcpp::List& dGhalf_dlambda, const arma::mat& AGAInv, int nc, int K);
RcppExport SEXP _lgspline_compute_dW_dlambda(SEXP GSEXP, SEXP ASEXP, SEXP GXXSEXP, SEXP GhalfSEXP, SEXP dG_dlambdaSEXP, SEXP dGhalf_dlambdaSEXP, SEXP AGAInvSEXP, SEXP ncSEXP, SEXP KSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< const Rcpp::List& >::type G(GSEXP);
    Rcpp::traits::input_parameter< const arma::mat& >::type A(ASEXP);
    Rcpp::traits::input_parameter< const Rcpp::List& >::type GXX(GXXSEXP);
    Rcpp::traits::input_parameter< const Rcpp::List& >::type Ghalf(GhalfSEXP);
    Rcpp::traits::input_parameter< const Rcpp::List& >::type dG_dlambda(dG_dlambdaSEXP);
    Rcpp::traits::input_parameter< const Rcpp::List& >::type dGhalf_dlambda(dGhalf_dlambdaSEXP);
    Rcpp::traits::input_parameter< const arma::mat& >::type AGAInv(AGAInvSEXP);
    Rcpp::traits::input_parameter< int >::type nc(ncSEXP);
    Rcpp::traits::input_parameter< int >::type K(KSEXP);
    rcpp_result_gen = Rcpp::wrap(compute_dW_dlambda(G, A, GXX, Ghalf, dG_dlambda, dGhalf_dlambda, AGAInv, nc, K));
    return rcpp_result_gen;
END_RCPP
}
// compute_GhalfXy_temp
arma::vec compute_GhalfXy_temp(const Rcpp::List& G, const Rcpp::List& Ghalf, const arma::mat& A, const arma::mat& AGAInv, const Rcpp::List& Xy, int nc, int K);
RcppExport SEXP _lgspline_compute_GhalfXy_temp(SEXP GSEXP, SEXP GhalfSEXP, SEXP ASEXP, SEXP AGAInvSEXP, SEXP XySEXP, SEXP ncSEXP, SEXP KSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< const Rcpp::List& >::type G(GSEXP);
    Rcpp::traits::input_parameter< const Rcpp::List& >::type Ghalf(GhalfSEXP);
    Rcpp::traits::input_parameter< const arma::mat& >::type A(ASEXP);
    Rcpp::traits::input_parameter< const arma::mat& >::type AGAInv(AGAInvSEXP);
    Rcpp::traits::input_parameter< const Rcpp::List& >::type Xy(XySEXP);
    Rcpp::traits::input_parameter< int >::type nc(ncSEXP);
    Rcpp::traits::input_parameter< int >::type K(KSEXP);
    rcpp_result_gen = Rcpp::wrap(compute_GhalfXy_temp(G, Ghalf, A, AGAInv, Xy, nc, K));
    return rcpp_result_gen;
END_RCPP
}
// matmult_U
arma::mat matmult_U(const arma::mat& U, const Rcpp::List& G, int nc, int K);
RcppExport SEXP _lgspline_matmult_U(SEXP USEXP, SEXP GSEXP, SEXP ncSEXP, SEXP KSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< const arma::mat& >::type U(USEXP);
    Rcpp::traits::input_parameter< const Rcpp::List& >::type G(GSEXP);
    Rcpp::traits::input_parameter< int >::type nc(ncSEXP);
    Rcpp::traits::input_parameter< int >::type K(KSEXP);
    rcpp_result_gen = Rcpp::wrap(matmult_U(U, G, nc, K));
    return rcpp_result_gen;
END_RCPP
}

static const R_CallMethodDef CallEntries[] = {
    {"_lgspline_efficient_matrix_mult", (DL_FUNC) &_lgspline_efficient_matrix_mult, 2},
    {"_lgspline_gramMatrix", (DL_FUNC) &_lgspline_gramMatrix, 1},
    {"_lgspline_armaInv", (DL_FUNC) &_lgspline_armaInv, 1},
    {"_lgspline_GAmult", (DL_FUNC) &_lgspline_GAmult, 5},
    {"_lgspline_compute_trace_correction", (DL_FUNC) &_lgspline_compute_trace_correction, 6},
    {"_lgspline_AGAmult", (DL_FUNC) &_lgspline_AGAmult, 5},
    {"_lgspline_AGAmult_chunk", (DL_FUNC) &_lgspline_AGAmult_chunk, 5},
    {"_lgspline_compute_AGXy", (DL_FUNC) &_lgspline_compute_AGXy, 7},
    {"_lgspline_compute_result_blocks", (DL_FUNC) &_lgspline_compute_result_blocks, 7},
    {"_lgspline_matmult_block_diagonal_cpp", (DL_FUNC) &_lgspline_matmult_block_diagonal_cpp, 3},
    {"_lgspline_vectorproduct_block_diagonal", (DL_FUNC) &_lgspline_vectorproduct_block_diagonal, 3},
    {"_lgspline_matadd_block_diagonal", (DL_FUNC) &_lgspline_matadd_block_diagonal, 3},
    {"_lgspline_compute_dW_dlambda", (DL_FUNC) &_lgspline_compute_dW_dlambda, 9},
    {"_lgspline_compute_GhalfXy_temp", (DL_FUNC) &_lgspline_compute_GhalfXy_temp, 7},
    {"_lgspline_matmult_U", (DL_FUNC) &_lgspline_matmult_U, 4},
    {NULL, NULL, 0}
};

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