CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: LDPC:How to make LDPC parity check matrix H from non-systematic to systematic in C/C+

  1. #1
    Join Date
    Jun 2017
    Posts
    13

    LDPC:How to make LDPC parity check matrix H from non-systematic to systematic in C/C+

    Hi,
    I am working with KINTEX board for LDPC encoding and decoding.Through 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. Here below you may find samples of non-standard parity check matrices in which Gauss-Jordan elimination (over GF(2)) can be applied.

    Initially, i need C/C++ programming logic please help me if you do have any idea about LDPC. I would need a method that works out with matrices of any dimension.

    this is, express it as

    Hsys = [I| P]

    This is my H matrix

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

    Expected Systematic H matrix

    Hsys=[1 0 0 1 0 1;
    0 1 0 1 1 1;
    0 0 1 0 1 1 ];

    Code:
    #include<stdio.h>
    int main()
    {
        // encoding
        int i,j;
        int message;
        int H_Matrix[3][6]={{1,1,0,0,1,0},{1,0,0,1,0,1},{1,1,1,0,0,1}};
        int temp[3][6]={0};
    for(j=0;j<6;j++)
        {
            temp[1][j]=(H_Matrix[1][j]^H_Matrix[0][j]);
            H_Matrix[1][j] = temp[1][j];
            temp[2][j]=(H_Matrix[2][j]^H_Matrix[0][j]);
            H_Matrix[2][j] = temp[2][j];
            temp[0][j]=(H_Matrix[0][j]^H_Matrix[1][j]);
            H_Matrix[0][j] = temp[0][j];
        }
      
    for(i=0;i<3;i++)
    {
        for(j=0;j<6;j++)
        {
            printf("%d\t ",H_Matrix[i][j]);
        }
        printf("\n");
    }
    }
    Logic
    n=6 k=3 q=2
    Start [0,0] = 1
    Pivot [0,0] = 1
    r_2 --> r_2 - r_1
    r_3 --> r_3 - r_1
    1 1 0 0 1 0
    0 1 0 1 1 1
    0 0 1 0 1 1
    --
    Start [1,1] = 1
    Pivot [1,1] = 1
    r_1 --> r_1 - r_2
    1 0 0 1 0 1
    0 1 0 1 1 1
    0 0 1 0 1 1
    --
    Start [2,2] = 1
    Pivot [2,2] = 1
    1 0 0 1 0 1
    0 1 0 1 1 1
    0 0 1 0 1 1

  2. #2
    Join Date
    Jun 2003
    Location
    Armenia, Yerevan
    Posts
    720

    Re: LDPC:How to make LDPC parity check matrix H from non-systematic to systematic in

    A friend of mine, has written Gauss eliminator which can be easily adopted for int values, here is the code:
    Code:
    void GaussEliminator::solve()
    {
    m_vecResult.clear();
    
    std::vector<double> v(m_dataMatrix.size() + 1);
    
    unsigned char curr_index = 0, add_index = 0;
    
    //now triagonalize matrix
    
    for (data_matrix::iterator i = m_dataMatrix.begin(), e = m_dataMatrix.end(), k; i != e; ++i, ++curr_index) {
    
    //normalize next row
    
    std::transform(i->begin(), i->end(), i->begin(), std::bind2nd(std::divides<double>(), *(i->begin() + curr_index)));
    
    //remove that item from the next ones
    
    for (k = i + 1; k != e; ++k) {
    
    //base row
    
    v.assign(i->begin(), i->end());
    
    //multiply by the next modified row and then substract
    
    std::transform(v.begin(), v.end(), v.begin(), std::bind2nd(std::multiplies<double>(), *(k->begin() + curr_index)));
    
    std::transform(k->begin(), k->end(), v.begin(), k->begin(), std::minus<double>()); 
    
    }
    
    }
    
    //now perform reverse process
    
    curr_index = m_dataMatrix.size();
    
    for (data_matrix::reverse_iterator i = m_dataMatrix.rbegin(), e = m_dataMatrix.rend(); i != e; ++i, ++add_index, --curr_index)
    
    m_vecResult.push_front((i->back() - std::inner_product<std::vector<double>::iterator, std::deque<double>::iterator, double>(i->begin() + curr_index, i->end() - 1, m_vecResult.begin(), 0)));
    
    }
    Last edited by AvDav; June 15th, 2017 at 12:54 PM.

  3. #3
    Join Date
    Jun 2017
    Posts
    13

    Re: LDPC:How to make LDPC parity check matrix H from non-systematic to systematic in

    Hi,

    Thanks for your response. Really i can`t understand concept of your code. I am beginner in programming code (C/C++) so i request you to start from the main function.


    This is my H matrix

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

    Expected Systematic H matrix: Hsys = [Identity matrix | P] //Requirement:Initially, i need C/C++ programming logic please help me if you do have any idea about LDPC. I would need a method that works out with matrices of any dimension.

    Hsys=[1 0 0 1 0 1;
    0 1 0 1 1 1;
    0 0 1 0 1 1 ];

    Quote Originally Posted by AvDav View Post
    A friend of mine, has written Gauss eliminator which can be easily adopted for int values, here is the code:
    Code:
    void GaussEliminator::solve()
    {
    m_vecResult.clear();
    
    std::vector<double> v(m_dataMatrix.size() + 1);
    
    unsigned char curr_index = 0, add_index = 0;
    
    //now triagonalize matrix
    
    for (data_matrix::iterator i = m_dataMatrix.begin(), e = m_dataMatrix.end(), k; i != e; ++i, ++curr_index) {
    
    //normalize next row
    
    std::transform(i->begin(), i->end(), i->begin(), std::bind2nd(std::divides<double>(), *(i->begin() + curr_index)));
    
    //remove that item from the next ones
    
    for (k = i + 1; k != e; ++k) {
    
    //base row
    
    v.assign(i->begin(), i->end());
    
    //multiply by the next modified row and then substract
    
    std::transform(v.begin(), v.end(), v.begin(), std::bind2nd(std::multiplies<double>(), *(k->begin() + curr_index)));
    
    std::transform(k->begin(), k->end(), v.begin(), k->begin(), std::minus<double>()); 
    
    }
    
    }
    
    //now perform reverse process
    
    curr_index = m_dataMatrix.size();
    
    for (data_matrix::reverse_iterator i = m_dataMatrix.rbegin(), e = m_dataMatrix.rend(); i != e; ++i, ++add_index, --curr_index)
    
    m_vecResult.push_front((i->back() - std::inner_product<std::vector<double>::iterator, std::deque<double>::iterator, double>(i->begin() + curr_index, i->end() - 1, m_vecResult.begin(), 0)));
    
    }

  4. #4
    Join Date
    Jun 2003
    Location
    Armenia, Yerevan
    Posts
    720

    Re: LDPC:How to make LDPC parity check matrix H from non-systematic to systematic in

    1) Well, I have no idea on what LDPC is.
    2) I just thought the code can be useful for this purpose and really it can work out with matrix of arbitrary NxM dimensions.

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
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)