Update matrix.h

Fixed some bugs. Using only 1 valarray now.