moved to src/math for wider availability