Click here to Skip to main content
       

Algorithms

 
QuestionPuzzle 8 Solving with bfs [modified] Pinmembermohammadkaab25-Sep-12 22:50 
AnswerRe: Puzzle 8 Solving with bfs PinmemberAlan Balkany26-Sep-12 4:27 
GeneralRe: Puzzle 8 Solving with bfs Pinmembermohammadkaab26-Sep-12 4:38 
GeneralRe: Puzzle 8 Solving with bfs PinmemberAlan Balkany26-Sep-12 4:42 
GeneralRe: Puzzle 8 Solving with bfs Pinmembermohammadkaab26-Sep-12 5:01 
GeneralRe: Puzzle 8 Solving with bfs PinmemberAlan Balkany26-Sep-12 5:09 
GeneralRe: Puzzle 8 Solving with bfs [modified] Pinmembermohammadkaab26-Sep-12 21:36 
QuestionBit Interleaver PinmemberSkippums24-Sep-12 16:07 
I am wondering if anyone knows of a more efficient algorithm to perform a bit-interleave/deinterleave that takes 256-bits and interleaves every 64-th bit in the output. For example, I want:
// NOTE: The order of the bits is inconsequential, as long as each string of 4 bits comes from a different 64-bit block
output = (bit[ 0] << 255) | (bit[ 64] << 254) | (bit[128] << 253) | (bit[192] << 252)
       | (bit[ 1] << 251) | (bit[ 65] << 250) | (bit[129] << 249) | (bit[193] << 248)
       | ...
       | (bit[63] <<   3) | (bit[127] <<   2) | (bit[191] <<   1) | (bit[255])
So far, I have the following algorithms (presented in untested C++):
// Interleave
__uint16 *data   = new __uint16[32 / sizeof(__uint16)]; // Data to interleave
__uint64 *result = new __uint64[32 / sizeof(__uint64)]();
 
for (int resIdx = 0; resIdx < 4; ++resIdx) {
    for (int dataIdx = resIdx; dataIdx < 16; dataIdx += 4) {
        __uint64 temp = data[dataIdx];
        temp |= temp << 24;
        temp |= temp << 12;
        temp &= 0x000F000F000F000FULL;
        temp |= temp <<  6;
        temp |= temp <<  3;
        temp &= 0x1111111111111111ULL;
        result[resIdx] |= temp << (dataIdx & 3);
    }
}
 
// Deinterleave
__uint64 *data   = new __uint64[32 / sizeof(__uint64)]; // Data to deinterleave
__uint16 *result = new __uint16[32 / sizeof(__uint16)];
for (int dataIdx = 0; dataIdx < 4; ++dataIdx) {
    for (int resIdx = dataIdx; resIdx < 16; resIdx += 4) {
        __uint64 temp = data[dataIdx] >> (resIdx >> 2);
        temp &= 0x1111111111111111ULL;
        temp |= temp >>  3;
        temp |= temp >>  6;
        temp &= 0x000F000F000F000FULL;
        temp |= temp >> 12;
        temp |= temp >> 24;
        result[resIdx] = (__uint16)temp;
    }
}
Sounds like somebody's got a case of the Mondays
 
-Jeff

QuestionImage processing Pinmemberfabio_antonio23-Sep-12 8:25 
AnswerRe: Image processing PinmemberAlan Balkany24-Sep-12 4:46 
QuestionChecking the network Pinmemberen41115-Sep-12 7:24 
AnswerlinkRe: Checking the network PinmemberYvesDaoust21-Sep-12 0:11 
Questionan optimal elevator-use algorithm PinmemberBillWoodruff13-Sep-12 3:38 
AnswerRe: an optimal elevator-use algorithm PinmemberAlan Balkany13-Sep-12 4:41 
GeneralRe: an optimal elevator-use algorithm PinmemberBillWoodruff19-Sep-12 4:35 
QuestionPlease, poke holes in my cryptographic function... [modified] PinmemberSixOfTheClock13-Sep-12 0:52 
QuestionWhat kind of checksum can this be? [modified] PinmemberGrooverFromHolland9-Sep-12 9:18 
AnswerRe: What kind of checksum can this be? PinmemberAlan N9-Sep-12 11:55 
GeneralRe: What kind of checksum can this be? PinmemberGrooverFromHolland9-Sep-12 22:15 
QuestionLinear Regression Most Efficient algorithm calc Line of Best Fit PinmemberA*****4-Sep-12 19:24 
AnswerRe: Linear Regression Most Efficient algorithm calc Line of Best Fit [modified] PinmemberPeter_in_27804-Sep-12 20:17 
QuestionRunning out of Memory - Maths Check PinmemberMike-MadBadger3-Sep-12 7:52 
AnswerRe: Running out of Memory - Maths Check [modified] PinmemberAndrei Straut3-Sep-12 9:03 
GeneralRe: Running out of Memory - Maths Check PinmemberMike-MadBadger3-Sep-12 10:11 
GeneralRe: Running out of Memory - Maths Check PinmemberAndrei Straut3-Sep-12 10:56 

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

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


Advertise | Privacy | Mobile
Web03 | 2.8.140721.1 | Last Updated 12 Jul 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid