Skip to content

Commit

Permalink
remove const #43
Browse files Browse the repository at this point in the history
  • Loading branch information
adamwang15 committed Aug 9, 2024
1 parent 0e5ec95 commit 5a0d30f
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 14 deletions.
4 changes: 2 additions & 2 deletions inst/include/bsvarSIGNs_RcppExports.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,11 +277,11 @@ namespace bsvarSIGNs {
return Rcpp::as<arma::field<arma::mat> >(rcpp_result_gen);
}

inline arma::colvec zero_restrictions(const arma::field<arma::mat>& Z, const arma::colvec vec_structural) {
inline arma::colvec zero_restrictions(const arma::field<arma::mat>& Z, arma::vec vec_structural) {
typedef SEXP(*Ptr_zero_restrictions)(SEXP,SEXP);
static Ptr_zero_restrictions p_zero_restrictions = NULL;
if (p_zero_restrictions == NULL) {
validateSignature("arma::colvec(*zero_restrictions)(const arma::field<arma::mat>&,const arma::colvec)");
validateSignature("arma::colvec(*zero_restrictions)(const arma::field<arma::mat>&,arma::vec)");
p_zero_restrictions = (Ptr_zero_restrictions)R_GetCCallable("bsvarSIGNs", "_bsvarSIGNs_zero_restrictions");
}
RObject rcpp_result_gen;
Expand Down
6 changes: 3 additions & 3 deletions src/RcppExports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -463,12 +463,12 @@ RcppExport SEXP _bsvarSIGNs_ZIRF(SEXP ZSEXP, SEXP irf_0SEXP) {
return rcpp_result_gen;
}
// zero_restrictions
arma::colvec zero_restrictions(const arma::field<arma::mat>& Z, const arma::colvec vec_structural);
arma::colvec zero_restrictions(const arma::field<arma::mat>& Z, arma::vec vec_structural);
static SEXP _bsvarSIGNs_zero_restrictions_try(SEXP ZSEXP, SEXP vec_structuralSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::traits::input_parameter< const arma::field<arma::mat>& >::type Z(ZSEXP);
Rcpp::traits::input_parameter< const arma::colvec >::type vec_structural(vec_structuralSEXP);
Rcpp::traits::input_parameter< arma::vec >::type vec_structural(vec_structuralSEXP);
rcpp_result_gen = Rcpp::wrap(zero_restrictions(Z, vec_structural));
return rcpp_result_gen;
END_RCPP_RETURN_ERROR
Expand Down Expand Up @@ -1058,7 +1058,7 @@ static int _bsvarSIGNs_RcppExport_validate(const char* sig) {
signatures.insert("bool(*match_sign_narrative)(const arma::mat&,const arma::mat&,const arma::cube&)");
signatures.insert("double(*weight_narrative)(const int&,arma::mat,const arma::cube&)");
signatures.insert("arma::field<arma::mat>(*ZIRF)(const arma::field<arma::mat>&,const arma::mat&)");
signatures.insert("arma::colvec(*zero_restrictions)(const arma::field<arma::mat>&,const arma::colvec)");
signatures.insert("arma::colvec(*zero_restrictions)(const arma::field<arma::mat>&,arma::vec)");
signatures.insert("arma::colvec(*g_fh)(const arma::field<arma::mat>&,const arma::mat&,const arma::mat&)");
signatures.insert("arma::colvec(*g_fh_vec)(const arma::field<arma::mat>&,const arma::colvec)");
signatures.insert("double(*log_volume_element)(const arma::field<arma::mat>&,const arma::mat&,const arma::mat&)");
Expand Down
10 changes: 6 additions & 4 deletions src/restrictions_zero.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ arma::field<arma::mat> ZIRF(

arma::field<arma::mat> ZIRF(Z.n_elem);

for (int j=0; j<Z.n_elem; j++) {
for (int j = 0; j < Z.n_elem; j++) {
ZIRF(j) = Z(j) * irf_0;
}

Expand All @@ -31,15 +31,17 @@ arma::field<arma::mat> ZIRF(
// [[Rcpp::export]]
arma::colvec zero_restrictions(
const arma::field<arma::mat>& Z,
const arma::colvec vec_structural
arma::vec vec_structural
) {
int N = Z(0).n_cols;
mat A0 = reshape(vec_structural.rows(0, N*N-1), N, N);

mat A0 = vec_structural.rows(0, N * N - 1);
A0 = reshape(A0, N, N);

arma::field<arma::mat> ZF = ZIRF(Z, inv(A0.t()));

colvec z;
for (int j=0; j<ZF.n_elem; j++) {
for (int j = 0; j < ZF.n_elem; j++) {
z = join_vert(z, ZF(j).col(j));
}

Expand Down
6 changes: 4 additions & 2 deletions src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,12 @@ bool match_sign(
// [[Rcpp:interface(cpp)]]
arma::mat Df(
const std::function<arma::vec(const arma::vec&)>& f,
const arma::vec& x,
const double h = 1e-10
const arma::vec& x
)
{

double h = 1e-10;

colvec f_x = f(x);

int n = x.n_elem;
Expand Down
5 changes: 2 additions & 3 deletions src/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ bool match_sign(
);

arma::mat Df(
const std::function<arma::colvec(const arma::colvec&)>& f,
const arma::colvec& x,
double h = 1e-10
const std::function<arma::vec(const arma::vec&)>& f,
const arma::vec& x
);

arma::mat metropolis(
Expand Down

0 comments on commit 5a0d30f

Please sign in to comment.