Added a number of functions for g-basis calculation