Added auxiliary functions

Added functions for basis orthogonalization, distance calculation,
sampling