Division matrix

Discussion in 'Python' started by Cleuson Alves, Nov 13, 2012.

  1. Hello, I need to solve an exercise follows, first calculate the inverse matrix and then multiply the first matrix.
    I await help.
    Thank you.
    follows the code below incomplete.

    m = [[1,2,3],[4,5,6],[7,8,9]]
    x = []
    for i in [0,1,2]:
    y = []
    for linha in m:
    y.append(linha)
    x.append(y)

    print x
    [[1, 4, 7], [2, 5, 8], [3, 6, 9]]

    def ProdMatrix(x,b):
    tamL = len(x)
    tamC = len(x[0])
    c = nullMatrix(tamL,tamC)
    for i in range(tamL):
    for j in range(tamC):
    val = 0
    for k in range(len(b)):
    val = val + x[l]*b[k][j]
    c[j]
    return c
     
    Cleuson Alves, Nov 13, 2012
    #1
    1. Advertising

  2. On Tue, 13 Nov 2012 10:19:43 -0200, Cleuson Alves <>
    declaimed the following in gmane.comp.python.general:

    > Thanks, I'm starting to plan now, so I'm still confused with the production
    > code, but what I need is to divide array 2x2 or 3x3.
    > I still can not!


    Divide it by what? A scalar... Another square matrix of the same
    size... Or a square matrix of a different size (is that even
    possible?)...

    Based
    http://en.wikipedia.org/wiki/Division_(mathematics)#Division_of_matrices
    upon, I can understand where the need for the inverse comes from -- and
    multiplication by the inverse gives the "division". Next up,
    http://en.wikipedia.org/wiki/Invertible_matrix#Inversion_of_2.C3.972_matrices
    gives direct formulations for 2x2 and 3x3 matrices.

    --
    Wulfraed Dennis Lee Bieber AF6VN
    HTTP://wlfraed.home.netcom.com/
     
    Dennis Lee Bieber, Nov 13, 2012
    #2
    1. Advertising

  3. On Tue, Nov 13, 2012 at 1:00 AM, Cleuson Alves <> wrote:
    > Hello, I need to solve an exercise follows, first calculate the inverse matrix and then multiply the first matrix.


    I would just point out that in most numerical applications, you rarely
    need to calculate the intermediate of the matrix inverse directly.
    See, e.g., http://www.johndcook.com/blog/2010/01/19/dont-invert-that-matrix/

    Of course, if this hasn't been said yet: NumPy.

    Michael
     
    R. Michael Weylandt, Nov 13, 2012
    #3
  4. Cleuson Alves

    Guest

    Le mardi 13 novembre 2012 02:00:28 UTC+1, Cleuson Alves a écrit :
    > Hello, I need to solve an exercise follows, first calculate the inverse matrix and then multiply the first matrix.
    >
    > I await help.
    >
    > Thank you.
    >
    > follows the code below incomplete.
    >
    >
    >
    > m = [[1,2,3],[4,5,6],[7,8,9]]
    >
    > x = []
    >
    > for i in [0,1,2]:
    >
    > y = []
    >
    > for linha in m:
    >
    > y.append(linha)
    >
    > x.append(y)
    >
    >
    >
    > print x
    >
    > [[1, 4, 7], [2, 5, 8], [3, 6, 9]]
    >
    >
    >
    > def ProdMatrix(x,b):
    >
    > tamL = len(x)
    >
    > tamC = len(x[0])
    >
    > c = nullMatrix(tamL,tamC)
    >
    > for i in range(tamL):
    >
    > for j in range(tamC):
    >
    > val = 0
    >
    > for k in range(len(b)):
    >
    > val = val + x[l]*b[k][j]
    >
    > c[j]
    >
    > return c


    ------

    Pedagogical hint:
    Before blindly calculating the inverse matrix, it may be
    a good idea to know if the inverse matrix exists.

    jmf
     
    , Nov 14, 2012
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. lvcargnini

    Matrix composed by two matrix

    lvcargnini, Jul 4, 2006, in forum: VHDL
    Replies:
    3
    Views:
    2,675
    Jonathan Bromley
    Jul 5, 2006
  2. Replies:
    94
    Views:
    4,495
    ¬a\\/b
    Feb 9, 2007
  3. Holgerson

    Matrix*Vector and Vector*Matrix

    Holgerson, Oct 25, 2007, in forum: C++
    Replies:
    3
    Views:
    409
    Holgerson
    Oct 26, 2007
  4. Terry Reedy
    Replies:
    0
    Views:
    556
    Terry Reedy
    Apr 2, 2009
  5. Robert Kern
    Replies:
    0
    Views:
    596
    Robert Kern
    Apr 2, 2009
Loading...

Share This Page