sp_block_diag.m
Sparse block diagonal matrix from a stack of matrix blocks.
With a single input, the trailing dimensions of the array are collapsed into a block index, the non-zero elements are located with find(), their linear positions are converted into row, column, and block subscripts, and the sparse matrix is assembled with the row and column indices offset by the block number. With several inputs, the row and column counts of the individual matrices are accumulated into offset vectors, the non-zero elements of each block are shifted by the corresponding offsets, and the concatenated triplets are passed to sparse(). Rectangular blocks are supported in both syntaxes; with several inputs, every argument must be a matrix.
Syntax
S=sp_block_diag(A)
S=sp_block_diag(A,B,C,...)
Parameters
A - a floating point array; in the first syntax, the
first two dimensions are matrix dimensions and the
remaining dimensions enumerate the blocks
A,B,C - floating point matrices to be placed on the block
diagonal in the second syntax
Outputs
S - sparse block diagonal matrix
Notes
This function is a Spinach-local replacement for Matlab's spblkdiag function from the Model-Based Calibration toolbox.
See also
clean_up.m, kronm.m, Kernel utilities
Version 2.13, authors: Ilya Kuprov