Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^14: [OT] The interesting problem of comparing (long) bit-strings.

by salva (Canon)
on Mar 31, 2015 at 13:25 UTC ( [id://1121991]=note: print w/replies, xml ) Need Help??


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

My code is still not ready, I would publish it once I feel it is.
  • Comment on Re^14: [OT] The interesting problem of comparing (long) bit-strings.

Replies are listed 'Best First'.
Re^15: [OT] The interesting problem of comparing (long) bit-strings.
by BrowserUk (Patriarch) on Mar 31, 2015 at 13:42 UTC

    That's fine, i'm in exactly the same position.

    Mine seems to work most of the time, but I've occasionally seen long patterns found at offsets other than (earlier) than expected.

    Given I was using random data, it is a possibility, but with needles of 100s or 1000s of bits (extracted from the randomly generated haystack), you wouldn't expect it to happen with any frequency in a human lifetime -- even in a billion bits of haystack -- and I've seen it half a dozen times already.

    Of course, it only ever happens when both haystack and needle are huge; when, even if I did dump the bits for manual inspection comparing thousands of 0s & 1s by eye is just too painful. (I did try it once!)

    Hence, I went looking for a better test strategy -- DeBruijn sequences -- which took rather longer to get right than I'd like to admit. (Would have been easier on a big-endian processor!)

    That -- last night -- allowed me to confirm that there are some circumstances when I get false hits -- it seems to be related to __shiftleft128() treating a shift value of 64 as 0!

    So now I'm recoding the entire thing in an OO style so that I don't have to juggle so many different offsets, shifts and counts in the mainline code. But I only just started.

    Bottom line: instead of continuing to post "Boyer Moore would be faster!" - "No it won't!" - "Yes it will!"; how about we wait until we're both ready and compare our actual code.


    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
      I don't think I would be able to work on my B-M implementation over the next days, so, here there is what I currently have: bitstrstr.c.

      I think the B-M side of the algorithm is pretty done, what remains is converting the slow_check function into a fast_check one.

      Then, there are edge cases as reading bytes out of boundaries and things like that which should be checked.

        Okay salva. Understood. This stuff is hard isn't it.

        If I ever get all the edge-cases covered in mine, I'll try and understand yours enough to finish it off. (I hope you'll field a few questions; cos after a first glance, there'll be a few :)


        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

        I have mine working and pretty well tested, if you're interested to see it?

        I've started looking at your B-M version -- which doesn't look like any B-M implementation I've ever seen? -- and ... well, expect questions :)


        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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1121991]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (9)
As of 2024-04-23 09:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found