Making matrix from scratch