Fat Matrix Diagonals
fatdiag set
fatdiag(x = 1, steps = NULL, size = NULL, nrow = NULL, ncol = NULL)
fatdiag(x, steps = NULL, size = NULL, on_diagonal = TRUE) <- valuea matrix where the dimensions are integer multiples of size or integer dividors of steps
the required number of steps (block matrices) across the diagonal
the width or height of the matrix being dropped over the diagonal of matrix x
the number of rows
the number of columns
should the operation be applied to the elements on the fat diagonal.
replacement value
Either steps or size is expected to be provided.
fatdiag<-: the set version of fatdiag
fatdiag(12, steps=3)
#> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12]
#> [1,] 1 1 1 1 0 0 0 0 0 0 0 0
#> [2,] 1 1 1 1 0 0 0 0 0 0 0 0
#> [3,] 1 1 1 1 0 0 0 0 0 0 0 0
#> [4,] 1 1 1 1 0 0 0 0 0 0 0 0
#> [5,] 0 0 0 0 1 1 1 1 0 0 0 0
#> [6,] 0 0 0 0 1 1 1 1 0 0 0 0
#> [7,] 0 0 0 0 1 1 1 1 0 0 0 0
#> [8,] 0 0 0 0 1 1 1 1 0 0 0 0
#> [9,] 0 0 0 0 0 0 0 0 1 1 1 1
#> [10,] 0 0 0 0 0 0 0 0 1 1 1 1
#> [11,] 0 0 0 0 0 0 0 0 1 1 1 1
#> [12,] 0 0 0 0 0 0 0 0 1 1 1 1
( m <- matrix(111, nrow=6, ncol=9) )
#> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9]
#> [1,] 111 111 111 111 111 111 111 111 111
#> [2,] 111 111 111 111 111 111 111 111 111
#> [3,] 111 111 111 111 111 111 111 111 111
#> [4,] 111 111 111 111 111 111 111 111 111
#> [5,] 111 111 111 111 111 111 111 111 111
#> [6,] 111 111 111 111 111 111 111 111 111
fatdiag(m, steps=3) <- 5
fatdiag(m, steps=3)
#> [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
fatdiag(12, size=4)
#> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12]
#> [1,] 1 1 1 1 0 0 0 0 0 0 0 0
#> [2,] 1 1 1 1 0 0 0 0 0 0 0 0
#> [3,] 1 1 1 1 0 0 0 0 0 0 0 0
#> [4,] 1 1 1 1 0 0 0 0 0 0 0 0
#> [5,] 0 0 0 0 1 1 1 1 0 0 0 0
#> [6,] 0 0 0 0 1 1 1 1 0 0 0 0
#> [7,] 0 0 0 0 1 1 1 1 0 0 0 0
#> [8,] 0 0 0 0 1 1 1 1 0 0 0 0
#> [9,] 0 0 0 0 0 0 0 0 1 1 1 1
#> [10,] 0 0 0 0 0 0 0 0 1 1 1 1
#> [11,] 0 0 0 0 0 0 0 0 1 1 1 1
#> [12,] 0 0 0 0 0 0 0 0 1 1 1 1
fatdiag(12, size=c(3,4) )
#> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12]
#> [1,] 1 1 1 1 0 0 0 0 0 0 0 0
#> [2,] 1 1 1 1 0 0 0 0 0 0 0 0
#> [3,] 1 1 1 1 0 0 0 0 0 0 0 0
#> [4,] 0 0 0 0 1 1 1 1 0 0 0 0
#> [5,] 0 0 0 0 1 1 1 1 0 0 0 0
#> [6,] 0 0 0 0 1 1 1 1 0 0 0 0
#> [7,] 0 0 0 0 0 0 0 0 1 1 1 1
#> [8,] 0 0 0 0 0 0 0 0 1 1 1 1
#> [9,] 0 0 0 0 0 0 0 0 1 1 1 1