Skip to content

Commit

Permalink
Use Rf_error
Browse files Browse the repository at this point in the history
  • Loading branch information
mattfidler committed May 27, 2024
1 parent 170ed35 commit dee3b28
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion R/rxSymInv.R
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ rxSymInvC2 <- function(mat1, diag.xform = c("sqrt", "log", "identity"),
matExpr <- sprintf(" if (theta_n >= -1){\n SEXP ret = PROTECT(Rf_allocMatrix(REALSXP, %s, %s));for (int i = 0; i < %s; i++){REAL(ret)[i]=0;}\n", d, d, d * d)
vecExpr <- sprintf(" UNPROTECT(1);\n return(ret);\n } else {\n SEXP ret = PROTECT(Rf_allocVector(REALSXP, %s));for(int i = 0; i < %s; i++){REAL(ret)[i]=0;}\n%s\n UNPROTECT(1);\n return(ret);\n }", d, d, diag)
src <- sprintf(
" int theta_n = INTEGER(tn)[0];\n %s\nif (theta_n == -2){\n SEXP ret = PROTECT(Rf_allocVector(INTSXP, 1));\n INTEGER(ret)[0] = %s;\n UNPROTECT(1);\n return ret;\n }\n else if (theta_n < %s || theta_n > %s){\n error(\"d(Omega^-1) derivative outside bounds\");\n }\n else if (Rf_length(theta) != %s){\n error(\"requires vector with %s arguments\");\n }\n%s\n%s\n%s",
" int theta_n = INTEGER(tn)[0];\n %s\nif (theta_n == -2){\n SEXP ret = PROTECT(Rf_allocVector(INTSXP, 1));\n INTEGER(ret)[0] = %s;\n UNPROTECT(1);\n return ret;\n }\n else if (theta_n < %s || theta_n > %s){\n Rf_error(\"d(Omega^-1) derivative outside bounds\");\n }\n else if (Rf_length(theta) != %s){\n Rf_error(\"requires vector with %s arguments\");\n }\n%s\n%s\n%s",
mat2, length(vars), min(diags) - 1, length(vars), length(vars), length(vars),
paste0(matExpr, omega0), omega1, paste0(omega1p, "\n", vecExpr)
)
Expand Down

0 comments on commit dee3b28

Please sign in to comment.