High-performance binary and nonbinary LDPC codes based on affine permutation matrices