Hi Claudio
The problem is that Array1[1000][1000] is for all intents and purposes an
array of random numbers, I have neither preconception of nor control over
the contents of Array1. On the other hand, Array2[50][50] is also an array
of random numbers, the only difference is that I know the value and location
of each number in that matrix. My goal is to determine whether the pattern
of numbers in Array2 occurs somewhere in Array1, and if it does not, which
50x50 region in Array1 will contain an array which is most similar to
Array2. That is to say, of all the possible 50x50 arrays in the original
1000x1000 array, which is the most similar to Array2. It can be safely
assumed that a perfect 100% match will never occur.
The most obvious way to determine this is to physically break Array1 up into
50x50 arrays. Starting at (0,0)(50,50), then to (1,0)(51,50)...all the way
to (950,950)(1000,1000), I compare each one od these 50x50 'subarrays' with
Array2. The one with the least difference is considered the 'closest match'.
If, however, the difference is more than a certain threshhold (say more than
25%), it is not considered similar enough and then no match is defined.
I am looking for a better, more optimized method of performing this search.
One way (which is best avoided) is to do what I do, but using assembly.
ciao
cybit
"Claudio Puviani" <pu*****@hotmail.com> wrote in message
news:jz*********************@news4.srv.hcvlny.cv.n et...
"cybit friendly" <rooivalk at sa-military plop co plop za> wrote Hi
<snip>
Since you don't define "closest match", my advice is likely to be off
base, but bits are cheap, so...
Try to create a "digest" of Array2 such that if the digest of another
array of the same size is numerically close, the two arrays are probably close
matches. You can then compute digests of the subarrays of Array1 and compare them
to the pre-computed digest of Array2. If you design your digest such that you can
recompute it by removing elements and adding new ones, you can then
quickly scan Array1 by doing S-shaped sweeps, thereby minimizing the changes to the
current digest.
Claudio Puviani