split impl. of matrix in .h and cpp