Click here to Skip to main content
15,887,676 members
Home / Discussions / Algorithms
   

Algorithms

 
GeneralRe: SSE and multi-core processors Pin
led mike17-Apr-09 6:52
led mike17-Apr-09 6:52 
GeneralRe: SSE and multi-core processors Pin
epitalon23-Apr-09 22:19
epitalon23-Apr-09 22:19 
GeneralRe: SSE and multi-core processors Pin
led mike24-Apr-09 4:49
led mike24-Apr-09 4:49 
Questionrow major and column major order Pin
Sadaiyappan8-Apr-09 10:49
Sadaiyappan8-Apr-09 10:49 
AnswerRe: row major and column major order Pin
Luc Pattyn8-Apr-09 11:19
sitebuilderLuc Pattyn8-Apr-09 11:19 
GeneralRe: row major and column major order Pin
Sadaiyappan8-Apr-09 11:51
Sadaiyappan8-Apr-09 11:51 
GeneralRe: row major and column major order Pin
Luc Pattyn8-Apr-09 12:34
sitebuilderLuc Pattyn8-Apr-09 12:34 
QuestionBest coding practice. Pin
Member 41945936-Apr-09 18:08
Member 41945936-Apr-09 18:08 
I have a MASM routine that generates assembly code to implement a Quicksort. All is working, including support for embedded keys in records, support for signed/unsigned, big-endian/little endian, keys of BYTES/WORDS/DWORDS/FLOATS/DOUBLES/EXTENDED_FLOATING, null terminated strings for BYTES or WORDS (element count=0), multiple elements for any data type (counts from 1-2048), multiple data types for a secondary key including its use as a tie-breaker for equal primary keys to make the QuickSort Stable. I will add support for MMX and XMM keys, but the current quest is to add the capability to declare Ascending or Descending in any mixture for either the primary key or for the secondary key (one can be ascending, the other descending, or both the same - either ascending or descending). I could just invert the conditional transfers and keep the comparison order the same, or invert the comparison order and keep the conditional transfers the same, or finally, just swap the indexes at entry and restore them at exit (XCHG) and keep all of the rest of the extensive code the same.

Note, the source code is extensive, but the macro invocation conditionally assembles only what is required and there is not a lot of checking what should be done next. Inserting the XCHG's for each comparison would add code (small) and execution cycles (small), but the compare logic is the highest use code of the whole sort. Conditionally assembling a version for ascending order and a different version for descending order is basically a copy and paste with an exchange of either the indices (and has no extra code or cycles), or a change of the conditional transfers. It seems that maintaining the two copies in parallel might be dangerous - fixes to one set of code would have to always be applied to the other set, and we all know how often that strategy fails - duplicate versions aren't!

So the question is, should I swap the indices and which way should I do this - swap the indices or swap the comparison order, or should I create two versions, one for ascending and the other for descending?

Please feel free to jump in with both feet and kick up a little dust, but this is a Quicksort so I don't want to hear about C++ or C# and overloaded operators with all of the bloat that goes along with HLL.

Hmm, I just thought of a way to allow both the primary key and the secondary key to have null terminated strings. The lowest offset of ether key has to end at the higher offset, and the highest offset has to end at the end of the record. More goodie to add, but carefully since the secondary key logic was a copy of the primary key logic, with different parameters, and I already stripped out the support for a null terminated string (more than one line). Remember that bit about duplicate versions that aren't? Oh, well!

Dave.
AnswerRe: Best coding practice. [modified] Pin
Luc Pattyn7-Apr-09 4:27
sitebuilderLuc Pattyn7-Apr-09 4:27 
GeneralRe: Best coding practice. Pin
Member 41945937-Apr-09 14:40
Member 41945937-Apr-09 14:40 
GeneralRe: Best coding practice. Pin
Luc Pattyn7-Apr-09 15:21
sitebuilderLuc Pattyn7-Apr-09 15:21 
GeneralRe: Best coding practice. Pin
Member 41945937-Apr-09 16:23
Member 41945937-Apr-09 16:23 
GeneralRe: Best coding practice. Pin
Member 419459310-Apr-09 19:55
Member 419459310-Apr-09 19:55 
GeneralRe: Best coding practice. Pin
Luc 64801111-Apr-09 0:39
Luc 64801111-Apr-09 0:39 
GeneralRe: Best coding practice. Pin
Member 419459311-Apr-09 5:51
Member 419459311-Apr-09 5:51 
GeneralRe: Best coding practice. Pin
Luc 64801111-Apr-09 6:18
Luc 64801111-Apr-09 6:18 
GeneralRe: Best coding practice. Pin
Member 419459315-Apr-09 8:29
Member 419459315-Apr-09 8:29 
GeneralRe: Best coding practice. Pin
Luc 64801115-Apr-09 8:39
Luc 64801115-Apr-09 8:39 
GeneralRe: Best coding practice. Pin
Member 419459315-Apr-09 9:45
Member 419459315-Apr-09 9:45 
QuestionRotation of Bitmap Pin
CodeOfLife5-Apr-09 16:21
CodeOfLife5-Apr-09 16:21 
AnswerRe: Rotation of Bitmap [modified] Pin
Luc Pattyn5-Apr-09 16:30
sitebuilderLuc Pattyn5-Apr-09 16:30 
GeneralRe: Rotation of Bitmap Pin
CodeOfLife6-Apr-09 6:37
CodeOfLife6-Apr-09 6:37 
GeneralRe: Rotation of Bitmap Pin
Luc Pattyn6-Apr-09 6:59
sitebuilderLuc Pattyn6-Apr-09 6:59 
QuestionCreating RSOM from SOM Pin
Jasmine Pomelo4-Apr-09 14:04
Jasmine Pomelo4-Apr-09 14:04 
QuestionRe: Creating RSOM from SOM Pin
CPallini6-Apr-09 21:39
mveCPallini6-Apr-09 21:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.