Need help in Matrix Addition & finding Inverse of a Matrix

This is a discussion on Need help in Matrix Addition & finding Inverse of a Matrix within the C Programming forums, part of the General Programming Boards category; Dear All, Am a beginner in C programming & I have following two tough programs as a part of my ...

  1. #1
    Registered User
    Join Date
    May 2009
    Posts
    1

    Need help in Matrix Addition & finding Inverse of a Matrix

    Dear All,

    Am a beginner in C programming & I have following two tough programs as a part of my self training.

    1. In a single-dimensional matrix, I want to add the elements of each row & elements of each column separately & then I have to print the result in the last column & in the last row. For example, If I got 3 rows & 3 columns, I want to print the sum of row elements in the 4 th column for each row & sum of column elements in the 4th row for each column. How can I accomplish this?

    2. In a single dimensional matrix, I have to reverse the second row elements alone & I have to print the result in the result matrix. How can I accomplish this?

    I request someone to reply at the earliest. I have been trying to solve this for the past 2 days. But am unable to solve it.

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    1. You can add up a row or a column with a loop. Then, since you need to add up every row/column, you need to put that loop inside a loop.

    2. Ignore the matrix part. Do you know how to reverse a single-dimensional array?

  4. #4
    Registered User
    Join Date
    May 2009
    Posts
    60
    Quote Originally Posted by ssatyan.129 View Post
    Dear All,

    If I got 3 rows & 3 columns, I want to print the sum of row elements in the 4 th column for each row & sum of column elements in the 4th row for each column.
    max size 3 => you want to print up to 4th => kinda weird !


    Quote Originally Posted by ssatyan.129 View Post
    In a single dimensional matrix, I have to reverse the second row elements alone
    symmetrically swap.
    first <=> last , second <=> pre-last ...

  5. #5
    Complete Beginner
    Join Date
    Feb 2009
    Posts
    312
    Quote Originally Posted by ssatyan.129 View Post
    2. In a single dimensional matrix, I have to reverse the second row elements alone & I have to print the result in the result matrix. How can I accomplish this?
    What does it mean to reverse the second row elements? Print them in reverse order? Print the second row of the inverse of the matrix?

    If you're not afraid to compute a lot of determinants, you may use Cramer's Rule to compute the inverse of a matrix, i.e. A^(-1) == adj(A)/det(A), where adj(A) is the adjugate matrix corresponding to A. Based on this rule, it shouldn't be hard to come up with a formula that computes the value of a single arbitrary element (i,j) of the inverse. There are better methods available, and I know that I have once been reading about them in my book on numerical math, but I don't remember any.

    Greets,
    Philip
    All things begin as source code.
    Source code begins with an empty file.
    -- Tao Te Chip

  6. #6
    Registered User linuxdude's Avatar
    Join Date
    Mar 2003
    Location
    Louisiana
    Posts
    926
    symmetrically swap.
    first <=> last , second <=> pre-last ...
    Vocab word of day: penultimate

  7. #7
    Registered User
    Join Date
    Sep 2008
    Location
    Toronto, Canada
    Posts
    1,831
    You keep saying "In a single-dimensional matrix" but you are in fact talking about a 2 dimensional matrix (rows and columns).

    No, Snafuist. He's not talking about inverse. Just reverse 2nd row elements array[ R, WIDTH - C]

    To start with, create a result matrix of dimensions rows+1 and cols+1 to allow for holding extra row and column for sums.

    1) Move the values into this new matrix.
    2) Loop accoss all rows to fill in row totals into last column.
    3) Loop across all columns to fill in column total in last row.
    4) Reverse the order of row #2's values.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C program - inverse of a matrix
    By chaugh in forum C Programming
    Replies: 4
    Last Post: 01-18-2010, 10:00 PM
  2. Matrix Help
    By HelpmeMark in forum C++ Programming
    Replies: 27
    Last Post: 03-06-2008, 04:57 PM
  3. matrix class
    By shuo in forum C++ Programming
    Replies: 2
    Last Post: 07-13-2007, 01:03 AM
  4. What is a matrix's purpose in OpenGL
    By jimboob in forum Game Programming
    Replies: 5
    Last Post: 11-13-2004, 11:19 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21