Thread: How to multiply single dimensional array with 2-dimensional array

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

    How to multiply single dimensional array with 2-dimensional array

    Hi,

    How to multiply single dimensional array with 2-dimensional array. Please share me the logic.

    Code:
    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
    
    int message[]={1,1,0} //single dimensional array

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    27,552
    Quote Originally Posted by SarasMuthu
    How to multiply single dimensional array with 2-dimensional array. Please share me the logic.
    Considering that it looks like you want to do matrix multiplication, the Wikipedia article on matrix multiplication may be a good place to start.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Mar 2017
    Posts
    52
    No, I know matrix multiplication. Actually what is my problem means ? i am working with LDPC code

    Code:
    int main()
    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
     
    int message[]={1,1,0}
    .....
    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]); //How to do this conversion ? 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");
    }   
    
    }

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    27,552
    Quote Originally Posted by SarasMuthu
    No, I know matrix multiplication.
    Then you should know that the result of your matrix multiplication will be another matrix, but I see no result matrix, i.e., you don't understand matrix multiplication. Read the Wikipedia article carefully first, please.

    Alternatively, you are not doing matrix multiplication, in which case I cannot help you without more information because there are so many ways to "multiply single dimensional array with 2-dimensional array", and all of them except one will not be applicable.

    Quote Originally Posted by SarasMuthu
    Actually what is my problem means ?
    That is for you to answer. If you don't know what your problem means, then I surely cannot know either since all I know is what you have presented of your problem. I know what matrix multiplication is, but what matrix multiplication means is context/domain dependent.

    Quote Originally Posted by SarasMuthu
    i am working with LDPC code
    That is meaningless to me, and I doubt it actually has any bearing on your problem other than providing some context that is not needed here. What you need to know is the algorithm for the multiplication, and while that may be known via the context of "LDPC code", it is for you to find out, not for anyone else to do this essential preliminary work.
    Last edited by laserlight; 06-19-2017 at 04:37 AM.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    Registered User
    Join Date
    Mar 2017
    Posts
    52
    Iayyo da, It`s very difficult to make you understand..OOOps

  6. #6
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    27,552
    No, it is easy to make me understand: describe the algorithm that you have in mind to "multiply single dimensional array with 2-dimensional array". If you cannot do that, then it is you who does not understand enough to even properly ask for help in implementing what you want to implement, so you need to fix that first.

    EDIT:
    Oh, I noticed that you referenced code[i][j]. Is code your result matrix? If your problem is with a compile error, then instead of posting a syntactically incorrect code fragment, post the smallest and simplest program that you expect should compile but which demonstrates the problem. If your problem is with logic, then you should be describing the logic to the best of your ability.
    Last edited by laserlight; 06-19-2017 at 04:49 AM.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Assigning One dimensional array to two dimensional array
    By lightning_star in forum C Programming
    Replies: 1
    Last Post: 03-19-2014, 09:44 PM
  2. Replies: 12
    Last Post: 09-02-2013, 07:50 PM
  3. Replies: 4
    Last Post: 09-02-2013, 11:19 AM
  4. Replies: 24
    Last Post: 11-11-2008, 01:39 PM
  5. Replies: 1
    Last Post: 04-25-2006, 12:14 AM

Tags for this Thread