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 using `np.matmul` >

Re: matrix multiplication

2018-02-27 Thread Seb
gt;>>> 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's only true if B is

Re: matrix multiplication

2018-02-27 Thread Ian Kelly
g 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 is a 3x3 matrix, then C = A

Re: matrix multiplication

2018-02-27 Thread Peter Otten
ough 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 multiplication in general, nothing &

Re: matrix multiplication

2018-02-26 Thread Seb
. > 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's only true if B is the sam

Re: matrix multiplication

2018-02-26 Thread Gregory Ewing
hen 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.) -- 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 rude? I think maybe it was back when it sai

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 wrote: >>> >>> [...] >>> numpy has a matrix multiply function and now the '@' mat

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 '@' matrix multiply >>> operator. >> >> Yes, but what I was wonderi

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 faster way of > multiplying each row (1x3)

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 faster way of > multiplying each row (1x3)

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), compared to looping th

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 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 collecti

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 much Robert - I just had to

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 t

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

2015-11-13 Thread PythonDude
6, 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-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 w

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 Nx1 column vector, so p^T

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 weig

Re: Matrix multiplication

2011-01-05 Thread Dan Stromberg
On Tue, Jan 4, 2011 at 11:31 PM, Tim Roberts 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 > > Matrix mul

Re: Matrix multiplication

2011-01-04 Thread Tim Roberts
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 Matrix multiplication is not generally done recursively. There's no conceptual gain. It

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 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 sl

Re: Matrix multiplication

2011-01-04 Thread Dan Stromberg
On Tue, Jan 4, 2011 at 4:22 AM, Zdenko 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 guid

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 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
your 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

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 and

Re: Matrix multiplication

2011-01-04 Thread Grégory Leocadie
On 4 jan, 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 a

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 teache

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

Combination of element-wise and matrix multiplication

2008-07-01 Thread Jonno
1,0] = e*g+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, ca

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 reade

Re: Matrix Multiplication

2007-06-18 Thread sturlamolden
On Jun 18, 11:20 am, Jeremy Sanders 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 > nump

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.

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

Re: Matrix Multiplication

2007-06-17 Thread sturlamolden
On Jun 17, 10:52 pm, "[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 *

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

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

2006-10-18 Thread Sssasss
a package, but if you insist in using lists > of lists: > > >>> b = [[1, 2, 3, 4], > ... [4, 5, 6, 7], > ... [7, 8, 9, 10]] > >>> > >>> a = [[1, 2, 3], > ... [4, 5, 6]] > >>> > >>> ab = [[sum(i*j for i, j in z

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):

Re: matrix Multiplication

2006-10-18 Thread Roberto Bonvallet
... [7, 8, 9, 10]] >>> >>> a = [[1, 2, 3], ... [4, 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 -- http://mail.python.org/mailman/listinfo/python-list

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

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=[] > > >

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

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 co

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