added a computePvectForRows method for computing the P vector