to_named_triplet function

Convert a matrix or list of matrices between named form and indexed form