Skip to content

Commit

Permalink
add error-checking, better show.size for 0-based indexing in dev/symb…
Browse files Browse the repository at this point in the history
…olicMatrix.R
  • Loading branch information
john-d-fox committed Aug 10, 2024
1 parent d26fe1d commit bbef242
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion dev/symbolicMatrix.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ symbolicMatrix <- function(
x
}

if (is.numeric(nrow) && zero.based[1]){
stop("zero-based indexing not available for numeric 'nrow'")
}
if (is.numeric(ncol) && zero.based[2]){
stop("zero-based indexing not available for numeric 'ncol'")
}

if (isTRUE(transpose)) transpose <- "\\top"
if (!missing(exponent) && !isFALSE(transpose)){
exponent <- paste0("{", exponent, "^", transpose, "}")
Expand Down Expand Up @@ -220,7 +227,13 @@ symbolicMatrix <- function(
}

mat.result <- paste0(result, "\\end{", matrix, "}",
if (show.size) paste0("_{(", nrow, " \\times ", ncol, ")}" ),
if (show.size) paste0("_{(",
nrow,
if (zero.based[1] && !end.at.n.minus.1[1]) " + 1",
" \\times ",
ncol,
if (zero.based[2] && !end.at.n.minus.1[2]) " + 1",
")}" ),
if (!missing(exponent)) paste0("^{", exponent, "}"),
if (!isFALSE(transpose)) paste0("^", transpose),
"\n")
Expand Down

0 comments on commit bbef242

Please sign in to comment.