Extract diagonal terms from a variety of matrix types
Details
Insists that input matrix is square. Uses the 'diagonal'
attribute when available and has specialised handling of ff
,
big.matrix
, dgCMatrix
matrices. Does not check that row and
column names are identical for those matrix classes (unlike the base
diag
function, but always uses rownames.
Examples
m=fill_in_sparse_score_mat(letters[1:5])
diagonal(m)
#> a b c d e
#> 0 0 0 0 0