Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   Division matrix (http://www.velocityreviews.com/forums/t954449-division-matrix.html)

Cleuson Alves 11-13-2012 01:00 AM

Division matrix
 
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[i])
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[i][l]*b[k][j]
c[i][j]
return c

Dennis Lee Bieber 11-13-2012 06:48 PM

Re: Division matrix
 
On Tue, 13 Nov 2012 10:19:43 -0200, Cleuson Alves <cleuson.o@gmail.com>
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/Divisio...on_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/Inverti...3.972_matrices
gives direct formulations for 2x2 and 3x3 matrices.

--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/


R. Michael Weylandt 11-13-2012 10:14 PM

Re: Division matrix
 
On Tue, Nov 13, 2012 at 1:00 AM, Cleuson Alves <cleuson.o@gmail.com> 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/0...t-that-matrix/

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

Michael

wxjmfauth@gmail.com 11-14-2012 09:04 AM

Re: Division matrix
 
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[i])
>
> 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[i][l]*b[k][j]
>
> c[i][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


All times are GMT. The time now is 05:45 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.