partial matrix implementation