implemented all functions but lgamma