code to read matrix, classes for host and device matrices