Fixed class-checking bugs

This commit is contained in:
Waldir Leoncio 2020-05-12 06:47:24 +02:00
parent 35734d94df
commit 26e64fe4be
3 changed files with 4 additions and 4 deletions

View file

@ -6,7 +6,7 @@
#' @param ninds ninds
#' @export
computeRows <- function(rowsFromInd, inds, ninds) {
if (class(inds) != "matrix") inds <- as.matrix(inds)
if (!is(inds, "matrix")) inds <- as.matrix(inds)
if (identical(dim(inds), c(nrow(inds), 1L))) {
# Special treatment for vectors because R has col vectors by default,
# whereas Matlab has row vectors by default.

View file

@ -4,7 +4,7 @@
#' @param x array
#'
isempty <- function(x) {
if (class(x) %in% c("array", "matrix")) {
if (class(x)[1] %in% c("array", "matrix")) {
dim_mat_x <- dim(x)
} else {
dim_mat_x <- dim(matrix(x))

View file

@ -14,7 +14,7 @@ repmat <- function (mx, n) {
# Validation
if (length(n) > 3) warning("Extra dimensions of n ignored")
if (length(n) == 1) n <- rep(n, 2)
if (class(mx) != "matrix") mx <- as.matrix(mx)
if (!is(mx, "matrix")) mx <- as.matrix(mx)
# Replicating cols
out <- mx_col <- matrix(rep(mx, n[2]), nrow(mx))