Skip to content

Commit

Permalink
fix NA in u vector
Browse files Browse the repository at this point in the history
  • Loading branch information
Jie Ren committed Feb 9, 2025
1 parent 0fa1cec commit 09c68ce
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 0 additions & 2 deletions R/print.regnet.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#' @param x a cv.regnet object.
#' @param digits significant digits in the printout.
#' @param ... other print arguments
#' @usage \method{print}{cv.regnet}(x, digits = max(3, getOption("digits") - 3), \dots)
#' @seealso \code{\link{cv.regnet}}
#' @export
print.cv.regnet=function(x, digits = max(3, getOption("digits") - 3),...){
Expand All @@ -29,7 +28,6 @@ print.cv.regnet=function(x, digits = max(3, getOption("digits") - 3),...){
#' @param x a regnet object.
#' @param digits significant digits in the printout.
#' @param ... other print arguments
#' @usage \method{print}{regnet}(x, digits = max(3, getOption("digits") - 3), \dots)
#' @seealso \code{\link{regnet}}
#' @export
print.regnet=function(x, digits = max(3, getOption("digits") - 3),...){
Expand Down
2 changes: 1 addition & 1 deletion man/print.cv.regnet.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/print.regnet.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 9 additions & 7 deletions src/QR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ arma::vec QRWMR(arma::mat const &x, arma::vec const &y, arma::vec b, bool debugg
u = t/x.col(m);
w = arma::abs(x.col(m))/n;

u.replace(datum::nan, 0);
u.elem(arma::find(x.col(m) == 0)).fill(0);

if (debugging) {
Rcpp::Rcout << "Values of u before NaN replacement for column " << m << ":\n";
u.print(Rcpp::Rcout);
// Rcpp::Rcout << "Values of u before NaN replacement for column " << m << ":\n";
// u.print(Rcpp::Rcout);
u.replace(datum::nan, 0);
}

index = arma::sort_index(u);
Expand Down Expand Up @@ -53,13 +54,14 @@ void QRWMR(arma::mat const &x, arma::vec const &y, arma::vec &b, arma::mat const
t += x.col(m) * b(m);
u = t/x.col(m);

u.elem(arma::find(x.col(m) == 0)).fill(0);

if (debugging) {
Rcpp::Rcout << "Values of u before NaN replacement for column " << m << ":\n";
u.print(Rcpp::Rcout);
// Rcpp::Rcout << "Values of u before NaN replacement for column " << m << ":\n";
// u.print(Rcpp::Rcout);
u.replace(datum::nan, 0);
}

u.replace(datum::nan, 0);

index = arma::sort_index(u);

double SUM = 0;
Expand Down

0 comments on commit 09c68ce

Please sign in to comment.