mat_apply helper to multiply an array of 3-tuples with a matrix