Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jul 28th, 2006, 9:28 AM   #21
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Posts: 1,799
Rep Power: 5 Sane will become famous soon enough
So what was this for anyways?
Sane is online now   Reply With Quote
Old Jul 28th, 2006, 9:42 AM   #22
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Pattern recognition. This is one of those cases where abstraction can't be afforded, unfortunately, because of the large number of operations. I need to go off and redesign the microprocessor. Incidentally, involving the center square is a substantial penalty, performance-wise.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Jul 28th, 2006, 9:50 AM   #23
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Posts: 1,799
Rep Power: 5 Sane will become famous soon enough
Oh, so your request for a "Python" solution was a request for an efficient solution? I'm searching your post for any hints of sarcasm. Oh well. I guess you went with hydroxide's then.
Sane is online now   Reply With Quote
Old Jul 28th, 2006, 10:06 AM   #24
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
There's no sarcasm there. None of the solutions given is effective. I'm a fan of abstraction. Elegance and clarity. Women and scotch. Sometimes they just don't happen to woik out.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Jul 28th, 2006, 11:21 PM   #25
hydroxide
Programmer
 
Join Date: Apr 2005
Posts: 73
Rep Power: 4 hydroxide is on a distinguished road
Quote:
Originally Posted by DaWei
Pattern recognition. This is one of those cases where abstraction can't be afforded, unfortunately, because of the large number of operations. I need to go off and redesign the microprocessor. Incidentally, involving the center square is a substantial penalty, performance-wise.
Quote:
Originally Posted by DaWei
Pattern recognition. This is one of those cases where abstraction can't be afforded, unfortunately, because of the large number of operations. I need to go off and redesign the microprocessor. Incidentally, involving the center square is a substantial penalty, performance-wise.
Ok - some questions/thoughts:
* Is it necessary to have your structure as a list of lists?
* What about a flat list? 3*y + x gives the index for a flat list, which saves you a lookup. (is y+y+y+x faster??)
* If using a flat list, you reuse the list with g[:] = [...] which IIRC is more efficient than creating a new list.
* What about a dict? Complex numbers can function as points (0+0j, 0+1j,..., 2+2j) - assuming that they're compiled in.
* How tight is memory? Can you have four lookup tables and just switch the table based on the rotation? If rotation is a frequent operation, the tradeoff might be worthwhile. The lookup tables would point to indices of a flat list.
*For rotation using a flat list, if you have a dummy member at the end you could use multiplication and slicing:
grid = [0,1,2,3,4,5,6,7,8, None]
grid[:] = (grid*3)[2::3]
* Timing things is left as an exercise... ;-P

-T.

Last edited by hydroxide; Jul 28th, 2006 at 11:34 PM.
hydroxide is offline   Reply With Quote
Old Jul 30th, 2006, 9:58 AM   #26
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Thanks for the exercise . In the reality of this usage no lookups or tricks or maps or sich be necessary. Flat is the way to go, of course, unless I whup up me a special set of hardware. The positional movements for a 90-degree rotation and for a mirror are fixed. I was just curious, again, what abstraction would cost.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[Python] Grid encryptor Jessehk Show Off Your Open Source Projects 7 Nov 29th, 2007 7:11 PM
Distance between 2 grid references Oddball Show Off Your Open Source Projects 7 Mar 12th, 2006 2:52 PM
easiest way to represent a grid? keweedsmo C++ 4 Feb 10th, 2006 6:03 PM
Little off-topic... Grid coordinate handling CodeCaster C++ 13 Jul 4th, 2005 7:07 AM
Need assistance with program DJ_Mittens C++ 4 Apr 20th, 2005 7:48 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 12:46 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC