Thread: LDPC Encoding_Showing wrong result in codeword

  1. #1
    Registered User
    Join Date
    Mar 2017
    Posts
    52

    LDPC Encoding_Showing wrong result in codeword

    Hi,
    I am working LDPC encoding and decoding.In Vivado HLS, I need to transform a parity-check matrix H (that only consists of ones and zeros) from a non-standard to a standard form through C/C++ programming language.

    Its showing wrong result while generating codeword, please debug my program.

    ISSUE : codeword, is wrong.
    Codeword actual result should be [0 0 1 0 1 1] but its displaying [0 1 1 1 0 0]


    this is, express it as

    Hsys = [I| P]

    This is my H parity check matrix

    H= [1 1 0 0 1 0;
    1 0 0 1 0 1;
    1 1 1 0 0 1 ];

    1. Arranging the parity check matrix in systematic form using row and column operations

    Hsys = [I| P]

    systematic parity check matrix, Hsys= [0 0 1 0 1 1
    0 1 0 1 1 1;
    1 0 0 1 0 1;]
    2. Rearranging the systematic parity check matrix

    Generator matrix G =[Ptranspose\I];

    Therefore, G= [0 1 1 1 0 0 ;
    1 1 0 0 1 0 ;
    1 1 1 0 0 1]

    3. Generate the codeword in by multiplying message with generator matrix G

    c=m.G //c =codeword

    Through C code, i have completed coding tasks 1 &2, but while generation codeword its showing wrong result.

    for e.g. m=011
    c= [011] [0 1 1 1 0 0 ;
    1 1 0 0 1 0 ;
    1 1 1 0 0 1]


    Code:
    // coding for the general form beginning using rows and cols
        int i,j,msg_length,sum=0,k;
        int message[1][10]={0};
        int rows,cols,r=0,r2,c;
        int H_Matrix[10][10]={0},code[10][10]={0};
        int temp[10][10]={0};
    .................
    ..............
    for(j=0;j<cols;j++)
        {
            printf("%d\t ",H_Matrix[i][j]);
        }
        printf("\n");
    }
    
    
    for (i = 0; i < 1; i++) {
          for (j = 0; j < cols; j++) {
            for (k = 0; k < rows; k++) {
              sum = sum^( message[i][k]&H_Matrix[k][j]);
            }
     
            code[i][j] = sum;
            sum = 0;
          }
        }
       
    //code wrd
    printf("the code word \n");   
    for(i=0;i<1;i++)
    {
        for(j=0;j<cols;j++)
        {
            printf("%d\t ",code[i][j]);
        }
        printf("\n");
    }
    Attached Images Attached Images LDPC Encoding_Showing wrong result in codeword-errorcode-jpg 

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    > .................
    > ..............
    Then provide us with a program we can simply copy/paste/test without all this messing about guessing the lines you so carefully omitted for our inconvenience.


    Better still, pre-initialise your input with a known test case so it's even easier to test.
    Code:
    int H_Matrix[10][10] = { 
      { 1, 0, 0, 1, 0 },
       // etc
    };
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Jun 2015
    Posts
    1,640
    Do you realize that
    Code:
    for (i = 0; i < 1; i++)
    will run the block only once, i.e., it's as if the loop wasn't there? Maybe you want the condition to be i < 2 so the block is run twice with i as 0 and 1.

  4. #4
    Registered User
    Join Date
    Mar 2017
    Posts
    52
    @Algorism, I have changed i=2, but its showing wrong result. Please look over the attachment. LDPC Encoding_Showing wrong result in codeword-errorcode-jpg

  5. #5
    Registered User
    Join Date
    Mar 2017
    Posts
    52
    Hi, I have got result correctly. I have did minor mistake in my code. Thanks for all your response.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Wrong result.
    By zaiken in forum C Programming
    Replies: 4
    Last Post: 11-12-2014, 08:19 AM
  2. Wrong declaration, Right result ?
    By The SharK in forum C++ Programming
    Replies: 14
    Last Post: 10-24-2005, 01:11 PM
  3. whats wrong with this? no errors but wrong result
    By InvariantLoop in forum C Programming
    Replies: 6
    Last Post: 01-28-2005, 12:48 AM
  4. wrong result?
    By o0o in forum C++ Programming
    Replies: 5
    Last Post: 01-11-2004, 09:53 AM
  5. cos() returning wrong result?
    By rmullen3 in forum C++ Programming
    Replies: 6
    Last Post: 08-20-2002, 11:46 PM

Tags for this Thread