I have rewritten all the function being consistent with the notation of the manuscript. I also wrote a united test that can be compared with the Mathematica notebook