symMatrix.RdCreate a Symmetric Matrix.
symMatrix( data = NA, nrow = NULL, byrow = FALSE,
upper = FALSE )an optional data vector.
the desired number of rows and columns.
logical. If 'FALSE' (the default) the matrix is filled by columns, otherwise the matrix is filled by rows.
logical. If 'FALSE' (the default) the lower triangular part of the matrix (including the diagonal) is filled, otherwise the upper triangular part of the matrix is filled.
a symmetric matrix.
# fill the lower triangular part by columns
symMatrix( 1:10, 4 )
#> [,1] [,2] [,3] [,4]
#> [1,] 1 2 3 4
#> [2,] 2 5 6 7
#> [3,] 3 6 8 9
#> [4,] 4 7 9 10
# fill the upper triangular part by columns
symMatrix( 1:10, 4, upper = TRUE )
#> [,1] [,2] [,3] [,4]
#> [1,] 1 2 4 7
#> [2,] 2 3 5 8
#> [3,] 4 5 6 9
#> [4,] 7 8 9 10
# fill the lower triangular part by rows
symMatrix( 1:10, 4, byrow = FALSE )
#> [,1] [,2] [,3] [,4]
#> [1,] 1 2 3 4
#> [2,] 2 5 6 7
#> [3,] 3 6 8 9
#> [4,] 4 7 9 10