/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 2003-2011 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Phong Vo <kpv@research.att.com> *
* *
***********************************************************************/
#include "vchdr.h"
/* Compute the highest period in all quasi-cycles of a data set.
**
** Written by Kiem-Phong Vo
*/
#if __STD_C
#else
#endif
{
return -1;
/* compute suffix array and longest-common-prefix array */
return -1;
return -1;
}
continue;
p += 1;
if(p > 0)
p -= 1;
}
/* dist[k] counts number of matches at distance k */
for(i = 0; i < sz; ++i)
{ for(m = 0, s = c, k = i+1; k < sz && s >= 0; ++k, --s)
{ if(lcp[k] == 0)
break;
break;
}
for(n = 0, s = c, p = i-1; p >= 0 && s >= 0; --p, --s)
{ if(lcp[p] == 0)
break;
break;
}
if(m > 0 && m <= n) /* count the closer one */
dist[m] += 1;
else if(n > 0 && n <= m)
dist[n] += 1;
}
/* compute an array of candidate peaks */
/* initialize running sum of distances of a suitable neighborhood */
m += dist[i];
/* a peak is larger than the total sum of a small neighborhood around it */
peak[i] = 1;
}
#ifdef DEBUG
for(i = 2; i < sz; ++i)
{ if(dist[i] <= 0)
continue;
if(peak[i])
}
#endif
/* a period is a peak with multiples that have matches */
continue;
{ if(dist[k] == 0)
continue;
{ n = 0;
break;
}
n += dist[k]; /* sum the weights */
if(peak[k])
{ s += 1; /* count peaks */
peak[k] = 0;
}
}
if(s > c && n > m )
{ p = i; m = n; c = s; }
}
return (ssize_t)p;
}