Implement serialization of fixed-size matrices