matrix I/O functions