For robustness, adding a check that phi is nonsingular in the preproccesing loop. This algorithm works for the textbook example, but when I try on arbitrary H matrices created by function regularLDPCCodeConstructor, phi always comes out as a matrix of zeros (i.e. nonsingular).