Initializes matrices