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
On Tue, 27 Feb 2018 07:36:31 -0700, Ian Kelly wrote: > On Tue, Feb 27, 2018 at 4:08 AM, Peter Otten <__pete...@web.de> wrote: >> Seb wrote: >>> On Tue, 27 Feb 2018 12:25:30 +1300, >>> Gregory Ewing wrote: Seb wrote: > I was wondering is whether there's a faster way of multiplying

Re: matrix multiplication

2018-02-27 Thread Ian Kelly
On Tue, Feb 27, 2018 at 4:08 AM, Peter Otten <__pete...@web.de> wrote: > Seb wrote: > >> On Tue, 27 Feb 2018 12:25:30 +1300, >> Gregory Ewing wrote: >> >>> Seb wrote: I was wondering is whether there's a faster way of multiplying each row (1x3) of a matrix by another matrix (3x3), compar

Re: matrix multiplication

2018-02-27 Thread Peter Otten
Seb wrote: > On Tue, 27 Feb 2018 12:25:30 +1300, > Gregory Ewing wrote: > >> Seb wrote: >>> 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 >>> through the matrix row by row as shown in the code. > >> Jus

Re: matrix multiplication

2018-02-26 Thread Seb
On Tue, 27 Feb 2018 12:25:30 +1300, Gregory Ewing wrote: > Seb wrote: >> 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 >> through the matrix row by row as shown in the code. > Just multiply the two matric

Re: matrix multiplication

2018-02-26 Thread Gregory Ewing
Seb wrote: 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 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-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`: ---

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 multiplication is not generally done recursive

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 makes more sense iterat

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 an

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 wh

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 guidelines >>> how to write it myself >> >> No

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
I would be very suprised if you achieve faster results threading this problem. There's been much discussed on benefits or lack thereof to threading in Python (or in general). Threading is best used in situations where you are doing different kinds of tasks. For example if you want to do your matri

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 account data to withdraw the

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

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 > numpy arrays That's what I wrote: "

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/gameo

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 s

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 * operator. -- http://mail.py

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 PROTEC

Re: matrix Multiplication

2006-10-18 Thread Sssasss
Roberto Bonvallet wrote: > Sssasss wrote: > > 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" > > Wrong validation here: you _can

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
Sssasss wrote: > 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" Wrong validation here: you _can_ multiply two matrices with a different number

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