parse matrix