Skip to content

Commit

Permalink
reduce the number of vector
Browse files Browse the repository at this point in the history
  • Loading branch information
Young Geun Kim committed Dec 13, 2024
1 parent 50da226 commit 2d2599b
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions inst/include/bvhardraw.h
Original file line number Diff line number Diff line change
Expand Up @@ -796,18 +796,21 @@ inline void dl_mn_sparsity(Eigen::VectorXd& group_param, Eigen::VectorXi& grp_ve
for (int i = 0; i < grp_id.size(); i++) {
group_id = grp_vec.array() == grp_id[i];
mn_size = group_id.count();
Eigen::VectorXd mn_coef(mn_size);
Eigen::VectorXd mn_local(mn_size);
// Eigen::VectorXd mn_coef(mn_size);
// Eigen::VectorXd mn_local(mn_size);
Eigen::VectorXd mn_scl(mn_size);
for (int j = 0, k = 0; j < coef_vec.size(); ++j) {
if (group_id[j]) {
mn_coef[k] = coef_vec[j];
mn_local[k++] = global_param * local_param[j];
// mn_coef[k] = coef_vec[j];
// mn_local[k++] = global_param * local_param[j];
mn_scl[k++] = abs(coef_vec[j]) / (global_param * local_param[j]);
}
}
// group_param[i] = sim_gig(1, shape - mn_size, 2 * rate, 2 * (mn_coef.cwiseAbs().array() / mn_local.array()).sum(), rng)[0];
group_param[i] = 1 / gamma_rand(
shape + mn_size,
1 / (rate + (mn_coef.cwiseAbs().array() / mn_local.array()).sum()),
// 1 / (rate + (mn_coef.cwiseAbs().array() / mn_local.array()).sum()),
1 / (rate + mn_scl.sum()),
rng
);
}
Expand Down

0 comments on commit 2d2599b

Please sign in to comment.