use matrix computation method in perceptrain function