Implementation of the butterfly hourglass function