Re: Efficient pattern-matching in a large array [message #77059] |
Tue, 02 August 2011 11:29 |
John Correira
Messages: 25 Registered: August 2011
|
Junior Member |
|
|
On 08/02/2011 02:05 PM, Chris O'Dell wrote:
> I have a byte array of tens of millions values (read from a binary
> file). I want to find an 8-byte pattern where ever it occurs. Similar
> to where, but 8 values at a time instead of one. The problem is
> finding a way to do this that is as fast as possible. The pattern is:
> [234, 203, 138, 216, 21, 52, 117, 39].
>
> Right now, I have this in a big loop and it takes a while. We tried
> "match2" but it ran out of memory.
>
> Thanks,
> Chris
>
Would the following do the trick?
index = where( array eq 234B $
AND shift(array,-1) eq 203B $
AND shift(array,-2) eq 138B $
AND shift(array,-3) eq 216B $
etc etc
Regards,
John
|
|
|