Created separate function to compute average precision and rank

also added parfor to a couple of functions