matrix solution