A fast and flexible implementation of Rigid Body Dynamics algorithms and their analytical derivatives