completed matrix assembly (not tested)