Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: list comprehension question

Reply
Thread Tools

Re: list comprehension question

 
 
Dwight Hutto
Guest
Posts: n/a
 
      10-17-2012
On Tue, Oct 16, 2012 at 10:13 PM, Dwight Hutto <(E-Mail Removed)> wrote:
> On Tue, Oct 16, 2012 at 9:54 PM, Kevin Anthony
> <(E-Mail Removed)> wrote:
>> I've been teaching myself list comprehension, and i've run across something
>> i'm not able to convert.
>>
>> here's the original code for matrix multiplcation
>>
>> retmatrix = Matrix(self.__row,other.__col)
>> for m in range(0,retmatrix.__row):
>> for n in range(0,retmatrix.__col):
>> product = 0
>> for p in range(1,self.__col+1):
>> product += (self.__matrix[m][p] * other.__matrix[p][n])
>> retmatrix.__matrix[m][n] = product
>>
>> Here is what i have so far:
>> retmatrix.__matrix = [[ product = product + (self.__matrix[m][p]*
>> other.__matrix[p][n])
>> if product else self.__matrix[m][p]* other.__matrix[p][n])
>> for p in range(0,self.col)
>> for n in range(0,self.col)]
>> for m in range(0,self.__row)]
>>
>> But i know that isn't correct, can someone nudge my in the right direction?
>>
>>
>> --
>> Thanks
>> Kevin Anthony
>> www.NoSideRacing.com
>>
>> Do you use Banshee?
>> Download the Community Extensions:
>> http://banshee.fm/download/extensions/
>>
>>
>> --
>> http://mail.python.org/mailman/listinfo/python-list
>>

>
>
> I did this a little while back for something else, but memories get
> jumbled up in these molecules of data I have floating around in my
> mind, but maybe this will put you on the right track.
>
>
> --


I know this doesn't answer the python question, but it will help you
algorithm out what you need to know.

I do lots of interdisciplinary research, so if this doesn't help, let
me know, and I'll take a refresher, and work up some code. Also, look
at numpy.
--
Best Regards,
David Hutto
CEO: http://www.hitwebdevelopment.com
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
List comprehension in if clause of another list comprehension Vedran Furac( Python 4 12-19-2008 01:35 PM
Appending a list's elements to another list using a list comprehension Debajit Adhikary Python 17 10-18-2007 06:45 PM
List comprehension returning subclassed list type? Shane Geiger Python 4 03-25-2007 09:34 AM
[Newby question] List comprehension Eelco Hoekema Python 7 08-06-2004 04:20 PM
List Comprehension question Mark Elston Python 1 12-11-2003 03:54 AM



Advertisments