add contract to Matrix constructor. close #14