Skip to content

Commit

Permalink
Check dimension of sparse 'U' and 'V' in 'run'
Browse files Browse the repository at this point in the history
  • Loading branch information
stewid committed Mar 9, 2017
1 parent 38482c0 commit 0a75725
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions R/siminf_model.R
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,11 @@ Nt <- function(model) {
dim(model@G)[1]
}

## Number of continuous state variables
Nd <- function(model) {
dim(model@v0)[1]
}

##' @rdname run-methods
##' @export
setMethod("run",
Expand All @@ -432,12 +437,22 @@ setMethod("run",
if (!is.null(U)) {
if (!is(U, "dgCMatrix"))
U <- as(U, "dgCMatrix")

d <- c(Nn(model) * Nc(model), length(model@tspan))
if (!identical(dim(U), d))
stop("Wrong dimension of 'U'")

model@U_sparse = U
}

if (!is.null(V)) {
if (!is(V, "dgCMatrix"))
V <- as(V, "dgCMatrix")

d <- c(Nn(model) * Nd(model), length(model@tspan))
if (!identical(dim(V), d))
stop("Wrong dimension of 'V'")

model@V_sparse = V
}

Expand Down

0 comments on commit 0a75725

Please sign in to comment.