Create a parameter that represents a matrix object.

numeric_matrix_parameter(
  name,
  value,
  lower_limit = .Machine$double.xmin,
  upper_limit = .Machine$double.xmax,
  symmetric = FALSE
)

binary_matrix_parameter(name, value, symmetric = FALSE)

Arguments

name

character name of parameter.

value

matrix object.

lower_limit

numeric values denoting the minimum acceptable value in the matrix. Defaults to the smallest possible number on the system.

upper_limit

numeric values denoting the maximum acceptable value in the matrix. Defaults to the smallest possible number on the system.

symmetric

logical must the must be matrix be symmetric? Defaults to FALSE.

Value

MiscParameter object.

Examples

# create matrix
m <- matrix(runif(9), ncol = 3)
colnames(m) <- letters[1:3]
rownames(m) <- letters[1:3]

# create a numeric matrix parameter
p1 <- numeric_matrix_parameter("m", m)
print(p1) # print it
#> <environment: 0x55c3dd8e53c0>
#> attr(,"class")
#> [1] "MiscParameter" "MiscParameter" "Parameter"     "pproto"       
#> [5] "proto"         "environment"  
p1$get() # get value
#>           a         b          c
#> a 0.9639887 0.7706323 0.92975210
#> b 0.7216369 0.8443418 0.03378785
#> c 0.0269171 0.3865605 0.38969615
p1$id # get id
#> id: 52a71310-6441-488a-a2d7-db70e105dea3
p1$validate(m[, -1]) # check if parameter can be updated
#> [1] FALSE
#> attr(,"msg")
#> [1] "ncol(m) not equal to ncol(value)"
p1$set(m + 1) # set parameter to new values
p1$print() # print it again
#> [1] "m"

# create a binary matrix parameter
m <- matrix(round(runif(9)), ncol = 3)
colnames(m) <- letters[1:3]
rownames(m) <- letters[1:3]

# create a binary matrix parameter
p2 <- binary_matrix_parameter("m", m)
print(p2) # print it
#> <environment: 0x55c3dc13f840>
#> attr(,"class")
#> [1] "MiscParameter" "MiscParameter" "Parameter"     "pproto"       
#> [5] "proto"         "environment"  
p2$get() # get value
#>   a b c
#> a 0 0 0
#> b 0 0 1
#> c 0 0 0
p2$id # get id
#> id: 06322189-d2ed-4142-bb8e-965d66a7e34f
p2$validate(m[, -1]) # check if parameter can be updated
#> [1] FALSE
#> attr(,"msg")
#> [1] "ncol(m) not equal to ncol(value)"
p2$set(m + 1) # set parameter to new values
p2$print() # print it again
#> [1] "m"