read matrices and arrays