helper function to center a numeric matrix within a (larger) target matrix size
center_matrix(output_dim, mat, default_value = NA_real_, drop_zeros = TRUE)
an expanded matrix of size output_dim
with the input matrix mat
centered
within it.
the desired dimensions of the output matrix
the 2D numeric matrix containing values to be centered in the output matrix
the value that should fill padded rows and columns of the output matrix
if TRUE, all zero-valued rows and columns of mat
will be dropped before
the data are centered within the output matrix. This is useful if the matrix is asymmetric,
but you still want to have it be dead-center in the output.