Skip to content

Commit

Permalink
delete not used utils
Browse files Browse the repository at this point in the history
  • Loading branch information
adamwang15 committed Jan 25, 2024
1 parent bd71d3b commit b2cdf55
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 67 deletions.
4 changes: 0 additions & 4 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

matnrnd_cpp <- function(M, U, V) {
.Call(`_bsvarSIGNs_matnrnd_cpp`, M, U, V)
}

# Register entry points for exported C++ functions
methods::setLoadAction(function(ns) {
.Call(`_bsvarSIGNs_RcppExport_registerCCallable`)
Expand Down
14 changes: 0 additions & 14 deletions src/RcppExports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,6 @@ RcppExport SEXP _bsvarSIGNs_bsvar_sign_cpp(SEXP SSEXP, SEXP YSEXP, SEXP XSEXP, S
UNPROTECT(1);
return rcpp_result_gen;
}
// matnrnd_cpp
arma::mat matnrnd_cpp(const arma::mat& M, const arma::mat& U, const arma::mat& V);
RcppExport SEXP _bsvarSIGNs_matnrnd_cpp(SEXP MSEXP, SEXP USEXP, SEXP VSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< const arma::mat& >::type M(MSEXP);
Rcpp::traits::input_parameter< const arma::mat& >::type U(USEXP);
Rcpp::traits::input_parameter< const arma::mat& >::type V(VSEXP);
rcpp_result_gen = Rcpp::wrap(matnrnd_cpp(M, U, V));
return rcpp_result_gen;
END_RCPP
}

// validate (ensure exported C++ functions exist before calling them)
static int _bsvarSIGNs_RcppExport_validate(const char* sig) {
Expand All @@ -87,7 +74,6 @@ RcppExport SEXP _bsvarSIGNs_RcppExport_registerCCallable() {

static const R_CallMethodDef CallEntries[] = {
{"_bsvarSIGNs_bsvar_sign_cpp", (DL_FUNC) &_bsvarSIGNs_bsvar_sign_cpp, 8},
{"_bsvarSIGNs_matnrnd_cpp", (DL_FUNC) &_bsvarSIGNs_matnrnd_cpp, 3},
{"_bsvarSIGNs_RcppExport_registerCCallable", (DL_FUNC) &_bsvarSIGNs_RcppExport_registerCCallable, 0},
{NULL, NULL, 0}
};
Expand Down
Binary file modified src/bsvarSIGNs.so
Binary file not shown.
36 changes: 0 additions & 36 deletions src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,11 @@

using namespace arma;

// Random draw from matrix normal MN(M, U, V)
// [[Rcpp:interface(cpp)]]
// [[Rcpp::export]]
arma::mat matnrnd_cpp(const arma::mat& M,
const arma::mat& U,
const arma::mat& V) {
// vec(A*B*C) = kron(A,C')*vec(B)
// a = chol(A) => a'*a = A, i.e. a' is lower triangular

mat X = mat(size(M), fill::randn);
return M + chol(U).t() * X * chol(V);
}


// [[Rcpp:interface(cpp)]]
arma::mat mvnrnd_inverse_cpp(const arma::mat& mu, const arma::mat& inv_Sigma) {
mat q = chol(inv_Sigma);
mat z = mat(size(mu), fill::randn);
return mu + inv(q) * z;
}


// log determinant given Cholesky decomposition of some matrix
double log_det_lower_cpp(const arma::mat& L) {
return 2 * sum(log(diagvec(L)));
}

arma::mat inv_chol_cpp(const arma::mat& L) {
return solve(trimatu(L.t()), solve(trimatl(L), eye(size(L))));
}

double log_mvnpdf_cpp(const arma::mat& x,
const arma::mat& mu,
const arma::mat& inv_Sigma,
const arma::mat& L) {
double log_det = log_det_lower_cpp(L);
double log_const = -0.5 * (x.n_rows * log(2 * datum::pi) + log_det);
mat z = x - mu;
return log_const - 0.5 * as_scalar(z.t() * inv_Sigma * z);
}

// QR decomposition, where the diagonal elements of R are positive
// [[Rcpp:interface(cpp)]]
arma::mat qr_sign_cpp(const arma::mat& A) {
Expand Down
13 changes: 0 additions & 13 deletions src/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,8 @@

#include <RcppArmadillo.h>

arma::mat matnrnd_cpp(const arma::mat& M,
const arma::mat& U,
const arma::mat& V);

arma::mat mvnrnd_inverse_cpp(const arma::mat& mu, const arma::mat& inv_Sigma);

double log_det_lower_cpp(const arma::mat& L);

arma::mat inv_chol_cpp(const arma::mat& L);

double log_mvnpdf_cpp(const arma::mat& x,
const arma::mat& mu,
const arma::mat& inv_Sigma,
const arma::mat& L);

arma::mat qr_sign_cpp(const arma::mat& A);

#endif // _UTILS_H_

0 comments on commit b2cdf55

Please sign in to comment.