Skip to contents

stm_constant() creates a matrix of a specified size where all elements are the same constant value. If no constant value is provided, one is randomly selected from the range -5 to 9.

Usage

stm_constant(k = NULL, nrows = 1, ncols = nrows, digits = NULL)

Arguments

k

The constant value to fill the matrix. If NULL, a random value is selected from the range -5 to 9.

nrows

The number of rows in the matrix. Must be at least 1.

ncols

The number of columns in the matrix. Must be at least 1.

digits

Optional. The number of decimal places to round the matrix values. Default is NULL.

Value

A matrix filled with the constant value k.

Details

This function creates a matrix of the specified size, and all elements are filled with the constant value k. If no value is specified, one is randomly selected from the range -5 to 9.

Examples

stm_constant(k = 3, nrows = 4)
#>      [,1] [,2] [,3] [,4]
#> [1,]    3    3    3    3
#> [2,]    3    3    3    3
#> [3,]    3    3    3    3
#> [4,]    3    3    3    3
stm_constant(nrows = 3, ncols = 5)
#>      [,1] [,2] [,3] [,4] [,5]
#> [1,]    7    7    7    7    7
#> [2,]    7    7    7    7    7
#> [3,]    7    7    7    7    7