[issue36669] weakref proxy doesn't support the matrix multiplication operator

2019-04-26 Thread Mark Dickinson
Mark Dickinson added the comment: Now fixed for 3.8. Although this was an oversight, I'm erring on the side of regarding this as a new feature for 3.8 (and I think the omission is unlikely to bite anyone for Python 3.7 or 3.6), so I wouldn't recommend backporting this. Thanks for the

[issue36669] weakref proxy doesn't support the matrix multiplication operator

2019-04-26 Thread Mark Dickinson
Mark Dickinson added the comment: New changeset 7abb6c05afd02c17c7a941b64db5756b161b3cf7 by Mark Dickinson in branch 'master': bpo-36669: add matmul support to weakref.proxy (GH-12932) https://github.com/python/cpython/commit/7abb6c05afd02c17c7a941b64db5756b161b3cf7 --

[issue36669] weakref proxy doesn't support the matrix multiplication operator

2019-04-24 Thread Nathaniel Smith
Nathaniel Smith added the comment: Yeah, seems like a simple oversight to me. (Actually this is the first I've heard of weakref.proxy...) -- ___ Python tracker ___

[issue36669] weakref proxy doesn't support the matrix multiplication operator

2019-04-24 Thread Mark Dickinson
Change by Mark Dickinson : -- assignee: -> mark.dickinson ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue36669] weakref proxy doesn't support the matrix multiplication operator

2019-04-24 Thread Mark Dickinson
Mark Dickinson added the comment: Adding Nathaniel Smith (the matrix multiplication PEP author), just in case he knows some reason why weakref.proxy objects should _not_ support the matrix multiplication operator. -- nosy: +njs ___ Python tracker

[issue36669] weakref proxy doesn't support the matrix multiplication operator

2019-04-24 Thread Mark Dickinson
Change by Mark Dickinson : -- keywords: +patch pull_requests: +12857 stage: -> patch review ___ Python tracker ___ ___

[issue36669] weakref proxy doesn't support the matrix multiplication operator

2019-04-24 Thread Mark Dickinson
Mark Dickinson added the comment: > It's not obvious why it should. I'd say that it's not obvious why it shouldn't. The "weakproxy" type currently supports every single "PyNumberMethods" slot *except* matrix multiplication: see https://github.

[issue36669] weakref proxy doesn't support the matrix multiplication operator

2019-04-20 Thread SilentGhost
Change by SilentGhost : -- status: open -> pending ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue36669] weakref proxy doesn't support the matrix multiplication operator

2019-04-19 Thread SilentGhost
New submission from SilentGhost : It's not obvious why it should. Do you care to show a use case you had in mind? -- components: +Library (Lib) nosy: +SilentGhost, fdrake type: -> enhancement versions: +Python 3.8 ___ Python tracker

[issue36669] weakref proxy doesn't support the matrix multiplication operator

2019-04-19 Thread Dan Snider
Change by Dan Snider : -- nosy: bup priority: normal severity: normal status: open title: weakref proxy doesn't support the matrix multiplication operator ___ Python tracker <https://bugs.python.org/issue36

Re: matrix multiplication

2018-02-27 Thread Ian Kelly
On Tue, Feb 27, 2018 at 9:02 AM, Seb wrote: > That's right. I just tried this manipulation by replacing the last > block of code in my example, from the line above `for` loop with: > > ------ > # Alternative

Re: matrix multiplication

2018-02-27 Thread Seb
gt;> Just multiply the two matrices together. >>>> If A is an nx3 matrix and B is a 3x3 matrix, then C = A @ B is an >>>> nx3 matrix where C[i] = A[i] @ B. >>>> (This is a property of matrix multiplication in general, nothing >>>> special about

Re: matrix multiplication

2018-02-27 Thread Ian Kelly
faster way of multiplying each >>>> row (1x3) of a matrix by another matrix (3x3), compared to looping >>>> through the matrix row by row as shown in the code. >> >>> Just multiply the two matrices together. >> >>> If A is an nx3 matrix and B i

Re: matrix multiplication

2018-02-27 Thread Peter Otten
oping >>> through the matrix row by row as shown in the code. > >> Just multiply the two matrices together. > >> If A is an nx3 matrix and B is a 3x3 matrix, then C = A @ B is an nx3 >> matrix where C[i] = A[i] @ B. > >> (This is a property of matrix mul

Re: matrix multiplication

2018-02-26 Thread Seb
by row as shown in the code. > Just multiply the two matrices together. > If A is an nx3 matrix and B is a 3x3 matrix, then C = A @ B is an nx3 > matrix where C[i] = A[i] @ B. > (This is a property of matrix multiplication in general, nothing > special about numpy.) I think that'

Re: matrix multiplication

2018-02-26 Thread Gregory Ewing
= A @ B is an nx3 matrix where C[i] = A[i] @ B. (This is a property of matrix multiplication in general, nothing special about numpy.) -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: matrix multiplication

2018-02-26 Thread Ian Kelly
On Mon, Feb 26, 2018 at 3:12 PM, Dan Stromberg wrote: > On Mon, Feb 26, 2018 at 2:07 PM, Ian Kelly wrote: >> Taking LMGTFY to a whole new level of rudeness by obviously not even >> bothering to read the entire paragraph before responding. > > Is LMGTFY

Re: matrix multiplication

2018-02-26 Thread Dan Stromberg
On Mon, Feb 26, 2018 at 2:07 PM, Ian Kelly wrote: > On Mon, Feb 26, 2018 at 2:40 PM, Dan Stromberg wrote: >> On Mon, Feb 26, 2018 at 8:53 AM, Seb wrote: >>> On Sun, 25 Feb 2018 18:52:14 -0500, >>> Terry Reedy

Re: matrix multiplication

2018-02-26 Thread Ian Kelly
On Mon, Feb 26, 2018 at 2:40 PM, Dan Stromberg wrote: > On Mon, Feb 26, 2018 at 8:53 AM, Seb wrote: >> On Sun, 25 Feb 2018 18:52:14 -0500, >> Terry Reedy wrote: >> >> [...] >> >>> numpy has a matrix multiply function and now the '@'

Re: matrix multiplication

2018-02-26 Thread Dan Stromberg
On Mon, Feb 26, 2018 at 8:53 AM, Seb wrote: > On Sun, 25 Feb 2018 18:52:14 -0500, > Terry Reedy wrote: > > [...] > >> numpy has a matrix multiply function and now the '@' matrix multiply >> operator. > > Yes, but what I was wondering is whether there's a

Re: matrix multiplication

2018-02-26 Thread Ian Kelly
On Mon, Feb 26, 2018 at 9:53 AM, Seb wrote: > On Sun, 25 Feb 2018 18:52:14 -0500, > Terry Reedy wrote: > > [...] > >> numpy has a matrix multiply function and now the '@' matrix multiply >> operator. > > Yes, but what I was wondering is whether there's a

Re: matrix multiplication

2018-02-26 Thread Seb
On Sun, 25 Feb 2018 18:52:14 -0500, Terry Reedy wrote: [...] > numpy has a matrix multiply function and now the '@' matrix multiply > operator. Yes, but what I was wondering is whether there's a faster way of multiplying each row (1x3) of a matrix by another matrix (3x3),

Re: matrix multiplication

2018-02-25 Thread Terry Reedy
On 2/25/2018 12:45 PM, Seb wrote: Hello, The following is an example of an Nx3 matrix (`uvw`) representing N vectors that need to be multiplied by a 3x3 matrix (generated by `randint_mat` function) and store the result in `uvw_rots`: ---

matrix multiplication

2018-02-25 Thread Seb
Hello, The following is an example of an Nx3 matrix (`uvw`) representing N vectors that need to be multiplied by a 3x3 matrix (generated by `randint_mat` function) and store the result in `uvw_rots`: ------ import numpy as np

Re: don't understand matrix-multiplication should be reversed in python?

2015-11-13 Thread PythonDude
On Thursday, 12 November 2015 22:57:21 UTC+1, Robert Kern wrote: > On 2015-11-12 15:57, PythonDude wrote: > > Hi all, > > > > I've come around a webpage with python-tutorial/description for obtaining > > something and I'll solve this: > > > > R = p^T w > > > > where R is a vector and p^T is the

Re: don't understand matrix-multiplication should be reversed in python?

2015-11-13 Thread PythonDude
8], > [ 0, 3, 6, 9, 12], > [ 0, 4, 8, 12, 16]]) > py> m.T * m > matrix([[30]]) > > Yeah, I don't know what that person is talking about either. It looks > correct to me. Thank you very much, Ian - just had to be sure about this - I would also be very disappointed in Python, if this author was right about this non-intuitive interpretation of how to do matrix multiplication :-) -- https://mail.python.org/mailman/listinfo/python-list

Re: don't understand matrix-multiplication should be reversed in python?

2015-11-13 Thread Dave Farrance
PythonDude wrote: >On Thursday, 12 November 2015 22:57:21 UTC+1, Robert Kern wrote: >> He simply instantiated the two vectors as row-vectors instead of >> column-vectors, >> which he could have easily done, so he had to flip the matrix expression. > >Thank you very

Re: don't understand matrix-multiplication should be reversed in python?

2015-11-13 Thread Gregory Ewing
Dave Farrance wrote: Yep, he's evidently used to the Matlab/Octave way of defining "vectors" which is somewhat easier for a math-oriented interactive environment. It's just a *bit* more laborious to append columns in numpy. Yes, that's probably the main reason to do things that way. A

Re: don't understand matrix-multiplication should be reversed in python?

2015-11-12 Thread Robert Kern
On 2015-11-12 15:57, PythonDude wrote: Hi all, I've come around a webpage with python-tutorial/description for obtaining something and I'll solve this: R = p^T w where R is a vector and p^T is the transpose of another vector. ... p is a Nx1 column vector, so p^T turns into a 1xN row vector

don't understand matrix-multiplication should be reversed in python?

2015-11-12 Thread PythonDude
Hi all, I've come around a webpage with python-tutorial/description for obtaining something and I'll solve this: R = p^T w where R is a vector and p^T is the transpose of another vector. ... p is a Nx1 column vector, so p^T turns into a 1xN row vector which can be multiplied with the Nx1

Re: don't understand matrix-multiplication should be reversed in python?

2015-11-12 Thread Ian Kelly
On Thu, Nov 12, 2015 at 8:57 AM, PythonDude wrote: > Hi all, > > I've come around a webpage with python-tutorial/description for obtaining > something and I'll solve this: > > R = p^T w > > where R is a vector and p^T is the transpose of another vector. > > ... > p is a

[issue24133] Add 'composable' decorator to functools (with @ matrix multiplication syntax)

2015-05-06 Thread levkivskyi
New submission from levkivskyi: The matrix multiplication operator @ is going to be introduced in Python 3.5 and I am thinking about the following idea: The semantics of matrix multiplication is the composition of the corresponding linear transformations. A linear transformation

[issue24133] Add 'composable' decorator to functools (with @ matrix multiplication syntax)

2015-05-06 Thread R. David Murray
R. David Murray added the comment: This should be taken to python-ideas (and probably pypi) first. You can reopen if there is agreement that this should be done. IMO it should not be done for 3.5 in any case. -- nosy: +r.david.murray resolution: - later stage: - resolved status:

[issue21176] Implement matrix multiplication operator (PEP 465)

2014-06-11 Thread Jesús Cea Avión
Changes by Jesús Cea Avión j...@jcea.es: -- nosy: +jcea ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21176 ___ ___ Python-bugs-list mailing list

[issue21176] Implement matrix multiplication operator (PEP 465)

2014-04-09 Thread Nathaniel Smith
Changes by Nathaniel Smith n...@pobox.com: -- nosy: +njs ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21176 ___ ___ Python-bugs-list mailing list

[issue21176] Implement matrix multiplication operator (PEP 465)

2014-04-09 Thread Benjamin Peterson
Benjamin Peterson added the comment: I think this patch is fairly straightforward, and I don't want it to rot, so here we go... -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21176 ___

[issue21176] Implement matrix multiplication operator (PEP 465)

2014-04-09 Thread Roundup Robot
Roundup Robot added the comment: New changeset c553d8f72d65 by Benjamin Peterson in branch 'default': PEP 465: a dedicated infix operator for matrix multiplication (closes #21176) http://hg.python.org/cpython/rev/c553d8f72d65 -- nosy: +python-dev resolution: - fixed stage: needs patch

[issue21176] Implement matrix multiplication operator (PEP 465)

2014-04-08 Thread Benjamin Peterson
Benjamin Peterson added the comment: Here's what I consider a complete patch. -- assignee: belopolsky - benjamin.peterson Added file: http://bugs.python.org/file34762/mat-mult5.patch ___ Python tracker rep...@bugs.python.org

[issue21176] Implement matrix multiplication operator (PEP 465)

2014-04-07 Thread Alexander Belopolsky
priority: normal severity: normal stage: needs patch status: open title: Implement matrix multiplication operator (PEP 465) type: enhancement versions: Python 3.5 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21176

[issue21176] Implement matrix multiplication operator (PEP 465)

2014-04-07 Thread Benjamin Peterson
Benjamin Peterson added the comment: Here's a first patch. It works, but needs more tests (associativity, precedence, __rmatmul__, etc...) and also docs. I can work on that tomorrow. -- keywords: +patch nosy: +benjamin.peterson Added file:

[issue21176] Implement matrix multiplication operator (PEP 465)

2014-04-07 Thread Benjamin Peterson
Benjamin Peterson added the comment: Here are changes to the operator module... -- Added file: http://bugs.python.org/file34755/mat-mult2.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21176

[issue21176] Implement matrix multiplication operator (PEP 465)

2014-04-07 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: I've got to the point where I can do import ast ast.dump(ast.parse('a @ b')) Module(body=[Expr(value=BinOp(left=Name(id='a', ctx=Load()), op=MatMult(), right=Name(id='b', ctx=Load(]) I'll post a link to my bitbucket clone shortly. --

[issue21176] Implement matrix multiplication operator (PEP 465)

2014-04-07 Thread Benjamin Peterson
Benjamin Peterson added the comment: Here is a nearly complete patch... -- Added file: http://bugs.python.org/file34756/mat-mult3.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21176

[issue21176] Implement matrix multiplication operator (PEP 465)

2014-04-07 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Wow! That was quick. And I am still fighting with bitbucket. Maybe I should stop duplicating the effort at this point. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21176

[issue21176] Implement matrix multiplication operator (PEP 465)

2014-04-07 Thread Benjamin Peterson
Benjamin Peterson added the comment: On Mon, Apr 7, 2014, at 22:09, Alexander Belopolsky wrote: Alexander Belopolsky added the comment: Wow! That was quick. And I am still fighting with bitbucket. Maybe I should stop duplicating the effort at this point. Sorry about that. I only saw the

[issue21176] Implement matrix multiplication operator (PEP 465)

2014-04-07 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: Thanks for stepping in. From a quick look at your patch I don't see anything that I would do much differently. I noticed some whitespace issues in Include/token.h: -#define AT 49 -#define RARROW 50 -#define ELLIPSIS51

[issue21176] Implement matrix multiplication operator (PEP 465)

2014-04-07 Thread Benjamin Peterson
Benjamin Peterson added the comment: On Mon, Apr 7, 2014, at 22:25, Alexander Belopolsky wrote: Alexander Belopolsky added the comment: + .. versionadded:: 3.4 Are you planning to use the time machine? :-) Good catch. :) -- ___ Python

[issue21176] Implement matrix multiplication operator (PEP 465)

2014-04-07 Thread Benjamin Peterson
Benjamin Peterson added the comment: On Mon, Apr 7, 2014, at 22:23, Alexander Belopolsky wrote: Alexander Belopolsky added the comment: Thanks for stepping in. From a quick look at your patch I don't see anything that I would do much differently. I noticed some whitespace issues in

[issue21176] Implement matrix multiplication operator (PEP 465)

2014-04-07 Thread Alexander Belopolsky
Alexander Belopolsky added the comment: + .. versionadded:: 3.4 Are you planning to use the time machine? :-) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21176 ___

[issue21176] Implement matrix multiplication operator (PEP 465)

2014-04-07 Thread Benjamin Peterson
Benjamin Peterson added the comment: Here's my latest and greatest version. I'll finish up after some sleep. -- Added file: http://bugs.python.org/file34758/mat-mult4.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21176

Re: Matrix multiplication

2011-01-05 Thread Dan Stromberg
On Tue, Jan 4, 2011 at 11:31 PM, Tim Roberts t...@probo.com wrote: Zdenko okn...@gmail.com wrote: Please, can anybody write me a simple recursive matrix multiplication using multiple threads in Python, or at least show me some guidelines how to write it myself Matrix multiplication

Matrix multiplication

2011-01-04 Thread Zdenko
Please, can anybody write me a simple recursive matrix multiplication using multiple threads in Python, or at least show me some guidelines how to write it myself Thank You -- http://mail.python.org/mailman/listinfo/python-list

Re: Matrix multiplication

2011-01-04 Thread Ulrich Eckhardt
Zdenko wrote: Please, can anybody write me a simple recursive matrix multiplication using multiple threads in Python, or at least show me some guidelines how to write it myself No problem, I just need your bank account data to withdraw the payment and the address of your teacher whom to send

Re: Matrix multiplication

2011-01-04 Thread Grégory Leocadie
On 4 jan, 11:15, Ulrich Eckhardt ulrich.eckha...@dominolaser.com wrote: Zdenko wrote: Please, can anybody write me a simple recursive matrix multiplication using multiple threads in Python, or at least show me some guidelines how to write it myself No problem, I just need your bank

Re: Matrix multiplication

2011-01-04 Thread Zdenko
On 4.1.2011 11:15, Ulrich Eckhardt wrote: Zdenko wrote: Please, can anybody write me a simple recursive matrix multiplication using multiple threads in Python, or at least show me some guidelines how to write it myself No problem, I just need your bank account data to withdraw the payment

Re: Matrix multiplication

2011-01-04 Thread DevPlayer
matrix multiplication WHILE you were doing other things on your computer where matrix multiplication was a background process chugging away when you are not taxing the computer doing other stuff. Threading adds efficiency when you would have lots of blocking operations like reading in lots of big files

Re: Matrix multiplication

2011-01-04 Thread DevPlayer
BTW http://www.python.org/dev/peps/pep-0211/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Matrix multiplication

2011-01-04 Thread DevPlayer
See section titled: 'array' or 'matrix'? Which should I use? at http://www.scipy.org/NumPy_for_Matlab_Users BTW http://www.python.org/dev/peps/pep-0211/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Matrix multiplication

2011-01-04 Thread Dan Stromberg
On Tue, Jan 4, 2011 at 4:22 AM, Zdenko okn...@gmail.com wrote: On 4.1.2011 11:15, Ulrich Eckhardt wrote: Zdenko wrote: Please, can anybody write me a simple recursive matrix multiplication using multiple threads in Python, or at least show me some guidelines how to write it myself

Re: Matrix multiplication

2011-01-04 Thread Steven D'Aprano
On Tue, 04 Jan 2011 13:22:33 +0100, Zdenko wrote: I wrote these two codes for example: this one is naive way of matrix multiplication using one thread [...] this one is using two threads, each one is multiplying half of matrix [...] why is second one more than twice slower than first when

Re: Matrix multiplication

2011-01-04 Thread John Nagle
On 1/4/2011 2:15 AM, Ulrich Eckhardt wrote: Zdenko wrote: Please, can anybody write me a simple recursive matrix multiplication using multiple threads in Python, or at least show me some guidelines how to write it myself No problem, I just need your bank account data to withdraw the payment

Re: Matrix multiplication

2011-01-04 Thread Tim Roberts
Zdenko okn...@gmail.com wrote: Please, can anybody write me a simple recursive matrix multiplication using multiple threads in Python, or at least show me some guidelines how to write it myself Matrix multiplication is not generally done recursively. There's no conceptual gain. It makes more

Combination of element-wise and matrix multiplication

2008-07-01 Thread Jonno
+f*i x[1,1] = e*h+f*j What is the simplest way to do this? I ended up doing the matrix multiplication manually as above but this doesn't scale very nicely if a b become larger size. Cheers, Jonno. -- If a theory can't produce hypotheses, can't be tested, can't be disproven, and can't make

Re: Matrix Multiplication

2007-06-19 Thread Jeremy Sanders
sturlamolden wrote: That's what I wrote: NumPy has a matrix type. It is called called numpy.matrix. I did not suggest using the array type numpy.array. Reading carefully is indeed important... I know what you wrote and you are strictly correct. I was just clarifying it for a reader who

Re: Matrix Multiplication

2007-06-18 Thread Jeremy Sanders
sturlamolden wrote: Use numpy: www.scipy.org NumPy has a matrix type that overloads the * operator. Just a tiny followup, which may be important unless you carefully read the documentation. The * operator doesn't do matrix multiplication for normal numpy arrays - you do need to use its

Re: Matrix Multiplication

2007-06-18 Thread Will McGugan
[EMAIL PROTECTED] wrote: Hi, Is there any direct function for matrix multiplication in Python or any of its packages? or do we have to multiply element by element? If you want a pure Python module for 4x4 matrices, then you may want to look at Game Objects http://code.google.com/p

Re: Matrix Multiplication

2007-06-18 Thread sturlamolden
On Jun 18, 11:20 am, Jeremy Sanders jeremy [EMAIL PROTECTED] wrote: NumPy has a matrix type that overloads the * operator. Just a tiny followup, which may be important unless you carefully read the documentation. The * operator doesn't do matrix multiplication for normal numpy arrays

Matrix Multiplication

2007-06-17 Thread [EMAIL PROTECTED]
Hi, Is there any direct function for matrix multiplication in Python or any of its packages? or do we have to multiply element by element? Thank you, Amit -- http://mail.python.org/mailman/listinfo/python-list

Re: Matrix Multiplication

2007-06-17 Thread Thomas Wittek
[EMAIL PROTECTED]: Is there any direct function for matrix multiplication in Python or any of its packages? or do we have to multiply element by element? First hit on google for python matrix: http://matpy.sourceforge.net/ -- Thomas Wittek http://gedankenkonstrukt.de/ Jabber: [EMAIL PROTECTED

Re: Matrix Multiplication

2007-06-17 Thread sturlamolden
On Jun 17, 10:52 pm, [EMAIL PROTECTED] amitsoni. [EMAIL PROTECTED] wrote: Hi, Is there any direct function for matrix multiplication in Python or any of its packages? or do we have to multiply element by element? Use numpy: www.scipy.org NumPy has a matrix type that overloads the * operator

matrix Multiplication

2006-10-18 Thread Sssasss
hi evrybody! I wan't to multiply two square matrixes, and i don't understand why it doesn't work. Could you explain me? def multmat(A,B): A*B if len(A)!=len(B): return error D=[] C=[] for i in range(len(A)): D.append(0) for i in range(len(A)): C.append(D) for i in

Re: matrix Multiplication

2006-10-18 Thread Fredrik Lundh
Sssasss wrote: I wan't to multiply two square matrixes, and i don't understand why it doesn't work. def multmat(A,B): A*B if len(A)!=len(B): return error D=[] C=[] for i in range(len(A)): D.append(0) for i in range(len(A)): C.append(D) append doesn't copy data, so

Re: matrix Multiplication

2006-10-18 Thread Sssasss
Fredrik Lundh wrote: Sssasss wrote: I wan't to multiply two square matrixes, and i don't understand why it doesn't work. def multmat(A,B): A*B if len(A)!=len(B): return error D=[] C=[] for i in range(len(A)): D.append(0) for i in range(len(A)): C.append(D)

Re: matrix Multiplication

2006-10-18 Thread Gerrit Holl
On 2006-10-18 14:15:17 +0200, Sssasss wrote: Fredrik Lundh wrote: Sssasss wrote: I wan't to multiply two square matrixes, and i don't understand why it doesn't work. def multmat(A,B): A*B if len(A)!=len(B): return error D=[] C=[] for i in

Re: matrix Multiplication

2006-10-18 Thread David
Il 18 Oct 2006 04:17:29 -0700, Sssasss ha scritto: hi evrybody! I wan't to multiply two square matrixes, and i don't understand why it doesn't work. Can I suggest a little bit less cumbersome algorithm? def multmat2(A,B): A*B if len(A)!=len(B): return error # this check is not

Re: matrix Multiplication

2006-10-18 Thread Roberto Bonvallet
, col)) for col in zip(*b)] for row in a] ab [[30, 36, 42, 48], [66, 81, 96, 111]] Straightforward from the definition of matrix multiplication. -- Roberto Bonvallet -- http://mail.python.org/mailman/listinfo/python-list

Re: matrix Multiplication

2006-10-18 Thread Sssasss
David wrote: Il 18 Oct 2006 04:17:29 -0700, Sssasss ha scritto: hi evrybody! I wan't to multiply two square matrixes, and i don't understand why it doesn't work. Can I suggest a little bit less cumbersome algorithm? def multmat2(A,B): A*B if len(A)!=len(B): return error #

Re: matrix Multiplication

2006-10-18 Thread Sssasss
, 5, 6]] ab = [[sum(i*j for i, j in zip(row, col)) for col in zip(*b)] for row in a] ab [[30, 36, 42, 48], [66, 81, 96, 111]] Straightforward from the definition of matrix multiplication. -- Roberto Bonvallet Thank you, this one is very short! yes of course we can multiply different