I'd use PDL, with some overly-clever finagling to maximise locality:

Yes, I enjoy that in the third bit, "any" sounds like the normal pronunciation of "ne". I'm only human.

If you want to make a custom transformation that does loop-fusion manually, see the SYNOPSIS of Inline::Pdlpp for an also-bio-inspired example.

Edit: if one chooses to not loop-fuse, the ne produces a mask that is true for any non-matches; that can then be fed into which to give the positions of those.

Edit 2: the above should take a matter of minutes to write, which would be much quicker than writing it in C/C++, and should run pretty quickly. But the naive, 2,1e8 solution has the benefit of broadcasting, which would mean it would also benefit from auto-pthreading, which in C/C++ would be a lot of hard work.


In reply to Re: simple string comparison for efficiency by etj
in thread simple string comparison for efficiency by CaptainF

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.