Okay. I succeeded in getting the caching variant to compile, but it crashes for needles > 20 bits. (Note: almost certainly down to changes I have to make to get it to compile here (LLP64 v lp64 changes), but since I do not understand the code, and there's nothing to reference it against, introducing bugs was almost inevitable.)

But, 2 days banging my head is enough. I don't need to prove your point for you. Here is a simple version of my brute-force bitstrnstrn(), if you're motivated to finish your code and compare, be my guest.

Note:the eclectic ordering of the parameters bitstrnstrn( &hay, &pin, bit_offset_hay, bit_offset_pin, bit_len_hay, bit_len_pin ), means that the values most needing to be in registers, automatically are as a consequence of the x64 calling convention (for my compiler).

#define SL( v, o ) __shiftleft128( *((v)+1), *((v)), o ) __forceinline U8 cmpBits( const register U64 *hay, const register U64 *pin, U8 regis +ter ohay, U8 register opin, U64 lpin ) { U64 register i; for( i=0; i < lpin/64; ++i, ++hay, ++pin ) { if( SL( hay, ohay ) != SL( pin, opin ) ) return 0; } { U8 lastbits = lpin % 64; U64 mask = ( ( 1ull << ( lastbits ) ) -1 ) << ( 64 - lastbits +); if( ( SL( hay, ohay ) & mask ) != ( SL( pin, opin ) & mask ) ) + return 0; } return 1; } U64 bitstrnstrn( const register U64 *hay, const register U64 *pin, U8 +register ohay, U8 register opin, U64 lhay, U64 lpin ) { U64 register i; for( i = ohay; i < lhay+ohay; ++i ) { if( cmpBits( hay+(i/64), pin, i%64, opin, lpin ) ) return i; } return -1; }

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". I'm with torvalds on this
In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked

In reply to Re^19: [OT] The interesting problem of comparing (long) bit-strings. by BrowserUk
in thread [OT] The interesting problem of comparing bit-strings. by BrowserUk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.