CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2017
    Posts
    13

    LDPC:How to declare

    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.


    Code:
    int main()
    {
        // coding for the general form beginning using rows and cols
        int i,j,msg_length,sum=0,k;
       int message[]={1,1,0}          //single dimensional array
        int rows=3,cols=6,r=0,r2,c;
        int Generator[10][10],code[10][10]={0};
        int temp[10][10]={0};
        int H_Matrix[3][6]={{1,1,0,0,1,0},{1,0,0,1,0,1},{1,1,1,0,0,1}}; //2-dimensional array
    */
    ....................
    ...............
    */
    
    for(i=0;i<rows;i++)
    {
        for(j=0;j<cols;j++)
        {
            Generator[i][j]=H_Matrix[i][j];
        //    printf("%d\t ",Generator[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]&Generator[k][j]); //How to compute? This line showing error while compiling 
            }
     
            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");
    }   
    
    }
    Last edited by 2kaud; June 19th, 2017 at 06:23 AM.

  2. #2
    Join Date
    Jan 2006
    Location
    Singapore
    Posts
    6,765

    Re: LDPC:How to declare

    message[i][k] results an error because message is a one-dimensional array. You probably meant to write:
    Code:
    sum = sum ^ (message[k] & Generator[k][j]);
    By the way, it looks like you have the same code as the original poster over here: How to multiply single dimensional array with 2-dimensional array, except that you've provided much more context from the get go. Hope you're actually the same person or working on the same project together and not some plagiarism involved... but then if so it is good to pick one forum and stick to it, or if you wish to switch help channel, inform the previous one.
    C + C++ Compiler: MinGW port of GCC
    Build + Version Control System: SCons + Bazaar

    Look up a C/C++ Reference and learn How To Ask Questions The Smart Way
    Kindly rate my posts if you found them useful

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured