Advertisement
Guest User

TPC_LDPC.m

a guest
Jul 18th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 2.00 KB | None | 0 0
  1. %%
  2. clear; clc;
  3. n = 7;
  4. % m = 5;
  5. ef = n;
  6. layers = 2;
  7. % wc = 2;
  8.  
  9. % A = zeros(n, m);
  10. % for col = 1 : m
  11. %   randRows = randperm(n);
  12. %   rowsWithOne = randRows(1:wc);
  13. %   A(rowsWithOne, col) = 1;
  14. % end
  15. % A
  16.  
  17. H = hammgen(ceil(log2(n)))
  18. G = gen2par(H)
  19. % H = transpose(H)
  20. % TPC = Gen_TPC(A, H)
  21. % size(TPC)
  22.  
  23. Protho_gen = Gen_Protho(n, ef, layers);
  24. %OfSpecialProtho = Protho_num(v, Protho_gen);
  25. Protho_matrix = Compute_Protho(n,ef);
  26. size(Protho_gen)
  27. gfrank(Protho_gen)
  28. fid = fopen('Parity_LDPC.txt','wt');
  29. for ii = 1:size(Protho_gen,1)
  30.     fprintf(fid,'%g\t', Protho_gen(ii,:));
  31.     fprintf(fid,'\n');
  32. end
  33. numel(Protho_gen(:,1))
  34.  
  35.  
  36. %%
  37. clear; clc;
  38. n = 7;
  39. ef = n;
  40. H = hammgen(ceil(log2(n)));
  41. Prothograph_matrix = [1 4 2 3 0 5 6; 0 0 0 0 0 0 0];
  42. a=zeros(n);
  43. a(1,:) = ones(1,n);
  44. Res = a;
  45. for i = 2:n
  46.     a = zeros(n);
  47.     a(i,:) = ones(1,n);
  48.     Res = [Res a];
  49. end
  50. Res = [Res; repmat(eye(ef),1,n)];
  51. Inserted = InsertComp(n,ef,2,Res,H);
  52. fid = fopen('Parity_Unshuffled.txt','wt');
  53. for ii = 1:size(Inserted,1)
  54.     fprintf(fid,'%g\t', Inserted(ii,:));
  55.     fprintf(fid,'\n');
  56. end
  57. reshuf = Prothograph_matrix(1,1:n)
  58. idx = Gen_Protho_vec(n,ef, reshuf);
  59. Inserted_Shuffled = Inserted(:,idx);
  60. fid = fopen('Parity_Shuffled.txt','wt');
  61. for ii = 1:size(Inserted_Shuffled,1)
  62.     fprintf(fid,'%g\t', Inserted_Shuffled(ii,:));
  63.     fprintf(fid,'\n');
  64. end
  65. x = ([1 1 0 0 1 0 1 1 1 0 0 1 0 1 0 0 1 1 0 1 0 0 0 1 0 1 1 1 1 1 0 1 0 0 0 0 0 1 1 0 1 0 1 1 0 1 0 0 0]);
  66. x = x(:,idx);
  67. size(x);
  68. Proizv = reshape(mod((x*transpose(Inserted_Shuffled)), 2),[],1)
  69.  
  70. %%
  71. Protho_gen_hammgen = InsertComp(n, ef, layers, Protho_gen, H)
  72. fid = fopen('Parity.txt','wt');
  73. for ii = 1:size(Protho_gen_hammgen,1)
  74.     fprintf(fid,'%g\t', Protho_gen_hammgen(ii,:));
  75.     fprintf(fid,'\n');
  76. end
  77. size(Protho_gen_hammgen)
  78. gfrank(Protho_gen_hammgen)
  79. [L1,u,L2] = lu(Protho_gen_hammgen);
  80.  
  81. x = ([1 0 0 0 1 0 0 0 1 1 1 0 0 1 1 1 1 1 1 1 0 1 1 1 0 0 0 1 0 0 0 0 0 1 1 0 1 1 0 1 1 0 0 0 0 1 1 0 0]);
  82. size(x)
  83. Proizv = mod((x*transpose(Protho_gen
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement