Re: [Tutor] Matrix Multiplication user entries

2018-03-23 Thread Mats Wichmann
On 03/23/2018 12:02 AM, Noor Alghanem wrote: > Hello, > > I am trying to write a program that is basically multiplying two matrices > one of size 1x8 and the other one of size 8x4. The different thing that I > am trying to figure out is that I want the program to ask the user to enter > the values

[Tutor] Matrix Multiplication user entries

2018-03-23 Thread Noor Alghanem
Hello, I am trying to write a program that is basically multiplying two matrices one of size 1x8 and the other one of size 8x4. The different thing that I am trying to figure out is that I want the program to ask the user to enter the values for the 1x8 matrix only which will be used in the multip

Re: [Tutor] Matrix help

2018-03-22 Thread Alan Gauld via Tutor
On 22/03/18 11:35, Connie Callaghan wrote: > Hi, > I was just looking help for a matrix that I am building, it needs to look > like this > 1, 0, 0, ...,0 > A,b,c,0,...,0 > 0,a,b,c,...,0 > 0,0,a,b,c,..0 > 0,0,0,a,b,c,...,0 > 0,0,0,0...0, 1 What exactly are the a,b,c values? Are they variables o

Re: [Tutor] Matrix help

2018-03-22 Thread Peter Otten
Connie Callaghan wrote: > Hi, > I was just looking help for a matrix that I am building, it needs to look > like this 1, 0, 0, ...,0 > A,b,c,0,...,0 > 0,a,b,c,...,0 > 0,0,a,b,c,..0 > 0,0,0,a,b,c,...,0 > 0,0,0,0...0, 1 > > It has n rows and columns and the first and last line has to have 1s at > t

[Tutor] Matrix help

2018-03-22 Thread Connie Callaghan
Hi, I was just looking help for a matrix that I am building, it needs to look like this 1, 0, 0, ...,0 A,b,c,0,...,0 0,a,b,c,...,0 0,0,a,b,c,..0 0,0,0,a,b,c,...,0 0,0,0,0...0, 1 It has n rows and columns and the first and last line has to have 1s at the corners as shown, and a,b,c going diago

Re: [Tutor] Matrix bug

2015-04-05 Thread Steven D'Aprano
On Sun, Apr 05, 2015 at 11:12:32AM -0300, Narci Edson Venturini wrote: > The next code has an unexpected result: > > >>>a=3*[3*[0]] > >>>a > [[0, 0, 0], [0, 0, 0], [0, 0, 0]] > >>>a[0][0]=1 > >>>a > [[1, 0, 0], [1, 0, 0], [1, 0, 0]] It isn't obvious, and it is *very* common for people to run into

Re: [Tutor] Matrix bug

2015-04-05 Thread Alan Gauld
On 05/04/15 15:12, Narci Edson Venturini wrote: The next code has an unexpected result: a=3*[3*[0]] Note that this makes three references to the list of 3 references to 0. In other words you reference the same list 3 times. So when you change the first copy you change the other 2 also. Put a

Re: [Tutor] Matrix bug

2015-04-05 Thread Emile van Sebille
On 4/5/2015 7:12 AM, Narci Edson Venturini wrote: The next code has an unexpected result: a=3*[3*[0]] a now contains three references to the same object, hence the results you show below. You can create three distinct objects as follows: >>> a = [ [0,0,0] for i in (0,1,2) ] >>> a[1][1]=1

[Tutor] Matrix bug

2015-04-05 Thread Narci Edson Venturini
The next code has an unexpected result: >>>a=3*[3*[0]] >>>a [[0, 0, 0], [0, 0, 0], [0, 0, 0]] >>>a[0][0]=1 >>>a [[1, 0, 0], [1, 0, 0], [1, 0, 0]] The code assigned to "1" a(0,0), a(1,0) and a(2,0). It was expected: [[1, 0, 0], [0, 0, 0], [0, 0, 0]] When the followind code is ran, them the corre

Re: [Tutor] Matrix Multiplication and its Inverse

2013-07-13 Thread Steven D'Aprano
On 13/07/13 05:05, Jack Little wrote: Is there a way in python to do matrix multiplication and its inverse? No external modules is preferred, but it is ok. If you have numpy, you should use that. If you want a pure Python version, here's a quick and dirty matrix multiplier that works only f

Re: [Tutor] matrix-vector multiplication errors

2008-02-02 Thread Eike Welk
On Friday 01 February 2008 23:13, Dinesh B Vadhia wrote: > I've posted this on the Scipy forum but maybe there are answers on > Tutor too. I'm performing a standard Scipy matrix* vector > multiplication, b=Ax , (but not using the sparse module) with > different sizes of A as follows: > > > Assumin

Re: [Tutor] matrix-vector multiplication errors

2008-02-02 Thread Eike Welk
On Friday 01 February 2008 23:13, Dinesh B Vadhia wrote: > I've posted this on the Scipy forum but maybe there are answers on > Tutor too. I'm performing a standard Scipy matrix* vector > multiplication, b=Ax , (but not using the sparse module) with > different sizes of A as follows: > > > Assumin

[Tutor] matrix-vector multiplication errors

2008-02-01 Thread Dinesh B Vadhia
I've posted this on the Scipy forum but maybe there are answers on Tutor too. I'm performing a standard Scipy matrix* vector multiplication, b=Ax , (but not using the sparse module) with different sizes of A as follows: Assuming 8 bytes per float, then: 1. matrix A with M=10,000 and N=15,000

Re: [Tutor] Matrix

2005-10-26 Thread Alan Gauld
This doesn't seem to have been answered... "Shi Mu" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >I can not understand the use of "cell in row" for two times in the code: > > # convert the matrix to a 1D list > matrix = [[13,2,3,4,5],[0,10,6,0,0],[7,0,0,0,9]] > items = [cell for ro

[Tutor] Matrix

2005-10-24 Thread Shi Mu
I can not understand the use of "cell in row" for two times in the code: # convert the matrix to a 1D list matrix = [[13,2,3,4,5],[0,10,6,0,0],[7,0,0,0,9]] items = [cell for row in matrix for cell in row] print items ___ Tutor maillist - Tutor@python.o

Re: [Tutor] Matrix

2005-01-14 Thread Hugo González Monteverde
Brian van den Broek wrote: 2) To get around that, and be more efficient with matricies with many empty cells: .>>> my_matrix_as_dict = {(1,1):4, (1,2):6, (1,3):8, (2,1):56, (2,3):12, (3,1):3, (3,2):3} .>>> my_matrix_as_dict[(3,1)] 3 .>>> my_matrix_as_dic

Re: [Tutor] Matrix

2004-12-20 Thread Bob Gailer
On Sun, 19 Dec 2004, Bugra Cakir wrote: > I want to create a matrix in Python. For example 3x4 how can i > create this? thanks Just for the heck of it would you tell us what you want to do with the matrix? Sometimes there are interesting alternate ways to do things that might not be obvious to a

Re: [Tutor] Matrix

2004-12-20 Thread Danny Yoo
On Sun, 19 Dec 2004, Bugra Cakir wrote: > I want to create a matrix in Python. For example 3x4 how can i > create this? thanks Hi Bugra, Just for reference, here's the relevant FAQ about how to do matrices in Python: http://python.org/doc/faq/programming.html#how-do-i-create-a-multidimension

Re: [Tutor] Matrix

2004-12-20 Thread Alan Gauld
> A list of lists is the most logical construction. > But -- you don't need to assemble the rows separately -- > this works too: > >>> my_matrix_as_lists = [ [4, 6, 8, 1],\ > ... [2, 5, 1, 3],\ > ... [2, 1, 2, 8] ] And you don't need the line continuation characters either. Because Python ca

Re: [Tutor] Matrix

2004-12-19 Thread Brian van den Broek
Rob Kapteyn said unto the world upon 2004-12-19 22:44: Hello to the list ! A list of lists is the most logical construction. But -- you don't need to assemble the rows separately -- this works too: >>> my_matrix_as_lists = [ [4, 6, 8, 1],\ ... [2, 5, 1, 3],\ ...

Re: [Tutor] Matrix

2004-12-19 Thread Rob Kapteyn
Juan: Thanks for the tip, but the correct address seems to be: http://www.scipy.com/ the .org does not answer. Now I have to check out the graphing tools they have:-) Rob On Dec 19, 2004, at 8:01 PM, Juan Shen wrote: Try SciPy. http://www.scipy.org/ It has mat class to handle matrix and much els

Re: [Tutor] Matrix

2004-12-19 Thread Rob Kapteyn
Hello to the list ! A list of lists is the most logical construction. But -- you don't need to assemble the rows separately -- this works too: >>> my_matrix_as_lists = [ [4, 6, 8, 1],\ ... [2, 5, 1, 3],\ ... [2, 1, 2, 8] ]

Re: [Tutor] Matrix

2004-12-19 Thread Juan Shen
Try SciPy. http://www.scipy.org/ It has mat class to handle matrix and much else. Juan Bugra Cakir wrote: hi, I want to create a matrix in Python. For example 3x4 how can i create this? thanks ___ Tutor maillist - [EMAIL PROTECTED] http://mail.pyt

Re: [Tutor] Matrix

2004-12-19 Thread Brian van den Broek
Bugra Cakir said unto the world upon 2004-12-19 10:33: hi, I want to create a matrix in Python. For example 3x4 how can i create this? thanks ___ Tutor maillist - [EMAIL PROTECTED] http://mail.python.org/mailman/listinfo/tutor Hi, at least two ways usin

[Tutor] Matrix

2004-12-19 Thread Bugra Cakir
hi, I want to create a matrix in Python. For example 3x4 how can i create this? thanks ___ Tutor maillist - [EMAIL PROTECTED] http://mail.python.org/mailman/listinfo/tutor