Error in `(function (object, problem = "", C = NULL, S = NULL, M = NULL, b = NULL, m = NULL, p = NULL, i = 1L, j = 1L, zero_diagonal = FALSE, r = 1L, Z = NULL, rcond = FALSE, tolerance = NULL, iteration_limit = NULL, final = TRUE, alpha = NULL, ...)  {     if (!is.null(C) || !is.null(M) || (!is.null(m) && !is.null(p))) {         object <- canonize.clsp(object, problem, C, S, M, NULL, b, m, p, i, j, zero_diagonal)     }     else if (is.null(object$A))          stop("At least one of C, M, m, or p must be provided.")     if (nrow(object$A) != nrow(object$b))          stop(sprintf(paste0("The matrix A and vector b must have the same number ", "of rows: A has %d, b has %d"), nrow(object$A), nrow(object$b)))     if (r < 1L)          stop("Number of refinement iterations r must be ≥ 1.")     if (!is.null(Z))          object$Z <- Z     else if (is.null(object$Z))          object$Z <- diag(ncol(object$A))     if (!is.null(tolerance))          object$tolerance <- tolerance     if (!is.null(iteration_limit))          object$iteration_limit <- iteration_limit     if (!isTRUE(all.equal(object$Z, t(object$Z), tolerance = object$tolerance)) || !isTRUE(all.equal(object$Z %*% object$Z, object$Z, tolerance = object$tolerance)) || nrow(object$Z) != ncol(object$A))          stop(sprintf(paste0("Matrix Z must be symmetric, idempotent and match ", "the number of columns in A: expected (%d,%d), ", "got (%d,%d)"), ncol(object$A), ncol(object$A), nrow(object$Z), ncol(object$Z)))     for (n_iter in seq_len(if (nrow(object$A) > object$C_idx[1]) r else 1L)) {         if (n_iter > 1L) {             res <- object$b - object$A %*% object$zhat             nrmse_prev <- .nrmse.r2(object, res = res)             Q <- diag(as.numeric(-sign(res[(object$C_idx[1] + 1):nrow(object$A), , drop = FALSE])))             object <- canonize.clsp(object, problem, C, S, M, Q, b, m, p, i, j, zero_diagonal)             Z_delta <- ncol(object$A) - nrow(object$Z)             if (Z_delta > 0L) {                 object$Z <- rbind(cbind(object$Z, matrix(0, nrow(object$Z), Z_delta)), cbind(matrix(0, Z_delta, ncol(object$Z)), diag(Z_delta)))             }         }         object$zhat <- (MASS::ginv(object$Z %*% crossprod(object$A) %*% object$Z, tol = if (is.null(rcond))              sqrt(.Machine$double.eps)         else if (isTRUE(rcond))              object$tolerance         else rcond) %*% object$Z %*% t(object$A)) %*% object$b         object$nrmse <- .nrmse.r2(object, res = object$b - object$A %*% object$zhat)         object$r <- n_iter         if (n_iter > 1L && (abs(object$nrmse - nrmse_prev) < object$tolerance || n_iter > object$iteration_limit))              break     }     if (!all(is.finite(object$zhat))) {         object$zhat <- NA_real_         stop("Pseudoinverse estimate zhat failed")     }     if (!is.null(final))          object$final <- isTRUE(final)     if (!is.null(alpha))          object$alpha <- max(0, min(1, as.numeric(alpha)))     if (isTRUE(object$final)) {         A_csc <- as(Matrix::Matrix(object$A, sparse = TRUE), "dgCMatrix")         z_cvx <- CVXR::Variable(ncol(A_csc))         d_cvx <- z_cvx - as.numeric(object$zhat)         if (isTRUE(all.equal(object$alpha, 0))) {             f_obj <- CVXR::norm1(d_cvx)             s_cvx <- "ECOS"         }         else if (isTRUE(all.equal(object$alpha, 1))) {             f_obj <- CVXR::sum_squares(d_cvx)             s_cvx <- "OSQP"         }         else {             f_obj <- (1 - object$alpha) * CVXR::norm1(d_cvx) + object$alpha * CVXR::sum_squares(d_cvx)             s_cvx <- "SCS"         }         c_cvx <- list(A_csc %*% z_cvx == as.numeric(object$b))         p_cvx <- CVXR::Problem(CVXR::Minimize(f_obj), c_cvx)         dots <- list(...)         dots$rcond <- NULL         solution <- try(do.call(p_cvx$solve, c(list(solver = s_cvx, verbose = FALSE), dots)), silent = TRUE)         if (inherits(solution, "try-error") || is.null(z_cvx$value)) {             warning(sprintf("Step 2 infeasible (%s); falling back", p_cvx@status), call. = FALSE)             object$z <- object$zhat         }         else {             object$z <- as.numeric(z_cvx$value)             object$nrmse <- .nrmse.r2(object)         }     }     else {         object$z <- object$zhat     }     object$x <- matrix(object$z[1:object$C_idx[2], , drop = FALSE], nrow = if (!is.null(m))          m     else object$C_idx[2], ncol = if (!is.null(p))          p     else 1)     object$y <- (if (ncol(object$A) > object$C_idx[2])          object$z[(object$C_idx[2] + 1):length(object$z), , drop = FALSE]     else matrix(numeric(0), ncol = 1))     object$kappaC <- kappa(object$A[1:object$C_idx[1], , drop = FALSE])     object$kappaB <- kappa(object$A %*% MASS::ginv(object$A[1:object$C_idx[1], , drop = FALSE]))     object$kappaA <- kappa(object$A)     if (nrow(object$A) > object$C_idx[1]) {         object$r2_partial <- .nrmse.r2(object, r2 = TRUE, partial = TRUE)         object$nrmse_partial <- .nrmse.r2(object, partial = TRUE)     }     b_norm <- sqrt(sum(object$b^2))     dz <- if (isTRUE(all.equal(b_norm, 0)))          Inf     else object$kappaA * sqrt(sum((object$b - object$A %*% matrix(object$z, ncol = 1))^2))/b_norm     object$z_lower <- object$z * (1 - dz)     object$z_upper <- object$z * (1 + dz)     object$x_lower <- matrix(object$z_lower[1:object$C_idx[2], , drop = FALSE], nrow = if (!is.null(m))          m     else object$C_idx[2], ncol = if (!is.null(p))          p     else 1)     object$x_upper <- matrix(object$z_upper[1:object$C_idx[2], , drop = FALSE], nrow = if (!is.null(m))          m     else object$C_idx[2], ncol = if (!is.null(p))          p     else 1)     object$y_lower <- (if (ncol(object$A) > object$C_idx[2])          object$z_lower[(object$C_idx[2] + 1):length(object$z), , drop = FALSE]     else matrix(numeric(0), ncol = 1))     object$y_upper <- (if (ncol(object$A) > object$C_idx[2])          object$z_upper[(object$C_idx[2] + 1):length(object$z), , drop = FALSE]     else matrix(numeric(0), ncol = 1))     object })(list(A = NULL, C_idx = c(NA_integer_, NA_integer_), b = NULL, Z = NULL, tolerance = 1.49011611938477e-08, iteration_limit = 50L, r = 0L, zhat = NULL, final = TRUE, alpha = 1, z = NULL, x = NULL, y = NULL, kappaC = NA_real_, kappaB = NA_real_, kappaA = NA_real_, rmsa = NA_real_, rmsa_i = NULL, rmsa_dkappaC = NULL, rmsa_dkappaB = NULL, rmsa_dkappaA = NULL, rmsa_dnrmse = NULL, rmsa_dzhat = NULL, rmsa_dz = NULL, rmsa_dx = NULL, r2_partial = NA_real_, nrmse = NA_real_, nrmse_partial = NA_real_, nrmse_ttest = NULL,      z_lower = NULL, z_upper = NULL, x_lower = NULL, x_upper = NULL, y_lower = NULL, y_upper = NULL, seed = 123456789L, distribution = function (n, mean = 0, sd = 1)      .Call(C_rnorm, n, mean, sd)), tolerance = 1.49011611938477e-08, final = TRUE, alpha = 1, problem = "ap", C = structure(c(0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1), dim = c(4L, 4L)), S = structure(c(1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1), dim = c(8L,  12L)), M = structure(c(1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1), dim = 3:4), b = structure(c(3801, 3800, 7031, 7410, 0, 1.24370555229162e+298, 0, 0, 0, 0, 0), dim = c(11L, 1L)), m = 2L, p = 2L, i = 1L, j = 1L, zero_diagonal = FALSE, r = 1L, Z = NULL, rcond = FALSE, iteration_limit = 50L)`: Pseudoinverse estimate zhat failed