compute matrix