Fixed bug in matrix library