More complex functions

These functions do not have a simple equivalent in SOFA so are reimplemented either completely standalone or using multiple SOFA functions.