Add library code

Add code in Library/Algebra and Library/Algorithms for math and other
utility classes.