Skip to content

Commit f738265

Browse files
committed
Add back QCLDPCCodeFromGroup method
It was removed between Guava 3.8 and 3.9, with no explanation.
1 parent ae7de4a commit f738265

File tree

3 files changed

+100
-1
lines changed

3 files changed

+100
-1
lines changed

doc/guava.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8297,7 +8297,7 @@ codes may be categorised into two classes:
82978297
<Func Name="QCLDPCCodeFromGroup" Arg=" m j k "/>
82988298

82998299
<Description>
8300-
<C>QCLDCCodeFromGroup</C> produces an <M>(n,j,k)</M> regular
8300+
<C>QCLDPCCodeFromGroup</C> produces an <M>(n,j,k)</M> regular
83018301
quasi-cyclic LDPC code over GF(2) of block length <M>n = mk</M>.
83028302
The term quasi-cyclic in the context of LDPC codes typically
83038303
refers to LDPC codes whose parity-check matrix <M>H</M> has

lib/codegen.gi

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2727,3 +2727,75 @@ function(ax, bx, k)
27272727
return C;
27282728
end);
27292729

2730+
###########################################################################
2731+
##
2732+
#F QCLDPCCodeFromGroup( <m>, <j>, <k> ) . . Regular quasi-cyclic LDPC code
2733+
##
2734+
## Construct a regular (j,k) quasi-cyclic low-density parity-check (LDPC)
2735+
## code over GF(2) based on the multiplicative group of integer modulo m.
2736+
## If m is a prime, the size of the group is equal to Phi(m) = m - 1,
2737+
## otherwise it is equal to Phi(m). For details, refer to the paper by:
2738+
##
2739+
## R. Tanner, D. Sridhara, A. Sridharan, T. Fuja and D. Costello,
2740+
## "LDPC block and convolutional codes based on circulant matrices",
2741+
## IEEE Trans. Inform. Theory, vol. 50, no. 12, pp. 2966--2984, 2004
2742+
##
2743+
## NOTE that j and k must divide Phi(m).
2744+
##
2745+
InstallMethod(QCLDPCCodeFromGroup, "method for binary linear code", true,
2746+
[IsInt, IsInt, IsInt], 0,
2747+
function(m, j, k)
2748+
local r, c, a, b, p, P, H, M, C, PermutationMatrix;
2749+
2750+
##
2751+
##----------------- start of private functions ---------------------
2752+
##
2753+
## PermutationMatrix - a private function for QCLDPCCodeFromGroup
2754+
PermutationMatrix := function(m, i)
2755+
local s, P, L;
2756+
if i = 0 or i > m then
2757+
Error("invalid value of i, 1 \\le i \\le ", m, "\n");
2758+
fi;
2759+
P := [];
2760+
L := List([1..m], i->Zero(GF(2))); L[i] := One(GF(2));
2761+
Append(P, [ L ]);
2762+
for s in [2..m] do;
2763+
L := RightRotateList(L);
2764+
Append(P, [ L ]);
2765+
od;
2766+
return P;
2767+
end;
2768+
##
2769+
##------------------ end of private functions ----------------------
2770+
##
2771+
2772+
p := Phi(m);
2773+
if (p mod j <> 0) then
2774+
Error(j, " does not divide ", p, "=Phi(", m, ")\n");
2775+
fi;
2776+
if (p mod k <> 0) then
2777+
Error(k, " does not divide ", p, "=Phi(", m, ")\n");
2778+
fi;
2779+
2780+
a := Position( List([1..m-1], i->OrderMod(i, m) ), k );
2781+
b := Position( List([1..m-1], i->OrderMod(i, m) ), j );
2782+
2783+
P := [];
2784+
for r in [0..j-1] do;
2785+
Append(P, [ List([0..k-1], i->a^i*b^r mod m) ]);
2786+
od;
2787+
2788+
H := [];
2789+
for r in [1..j] do;
2790+
M := [];
2791+
for c in [1..k] do;
2792+
M := TransposedMat( Concatenation( TransposedMat(M), TransposedMat( PermutationMatrix(m, P[r][c]) ) ) );
2793+
od;
2794+
Append(H, M);
2795+
od;
2796+
C := CheckMatCode( H, GF(2) );
2797+
C!.CheckMat := H;
2798+
C!.name := "low-density parity-check code";
2799+
C!.upperBoundMinimumDistance := Factorial(j+1);
2800+
return C;
2801+
end);

tst/QCLDPCCodeFromGroup.tst

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# The following is a manual example
2+
gap> C := QCLDPCCodeFromGroup(7,2,3);
3+
a linear [21,8,1..6]5..10 low-density parity-check code over GF(2)
4+
gap> MinimumWeight(C);
5+
6
6+
gap> # The quasi-cyclic structure is obvious from the check matrix
7+
gap> Display( CheckMat(C) );
8+
1 . . . . . . . 1 . . . . . . . . 1 . . .
9+
. 1 . . . . . . . 1 . . . . . . . . 1 . .
10+
. . 1 . . . . . . . 1 . . . . . . . . 1 .
11+
. . . 1 . . . . . . . 1 . . . . . . . . 1
12+
. . . . 1 . . . . . . . 1 . 1 . . . . . .
13+
. . . . . 1 . . . . . . . 1 . 1 . . . . .
14+
. . . . . . 1 1 . . . . . . . . 1 . . . .
15+
. . . . . 1 . . . . . 1 . . . . 1 . . . .
16+
. . . . . . 1 . . . . . 1 . . . . 1 . . .
17+
1 . . . . . . . . . . . . 1 . . . . 1 . .
18+
. 1 . . . . . 1 . . . . . . . . . . . 1 .
19+
. . 1 . . . . . 1 . . . . . . . . . . . 1
20+
. . . 1 . . . . . 1 . . . . 1 . . . . . .
21+
. . . . 1 . . . . . 1 . . . . 1 . . . . .
22+
gap> # This is the famous [155,64,20] quasi-cyclic LDPC codes
23+
gap> C := QCLDPCCodeFromGroup(31,3,5);
24+
a linear [155,64,1..24]24..77 low-density parity-check code over GF(2)
25+
gap> # An example using non prime m, it may take a while to construct this code
26+
gap> C := QCLDPCCodeFromGroup(356,4,8);
27+
a linear [2848,1436,1..120]312..1412 low-density parity-check code over GF(2)

0 commit comments

Comments
 (0)