INTERFACE PZProc; (* Miscellaneous functions and procedures *) (* Last edited on 2001-11-04 16:17:11 by stolfi *) FROM PZTypes IMPORT NAT, NATS, INT, LONG, BOOLS; PROCEDURE ReduceToPeriod(VAR (*IO*) t: LONG; tLo, tHi: LONG; VAR (*OUT*) k: INT); (* Reduces "t" to the range "[tLo _ tHi)" by adding to it some integer multiple "k" of "tHi - tLo". *) PROCEDURE Squeeze(x: LONG; sigma: LONG): LONG; (* Maps a variable "x" that has Gaussian distribution with mean zero and deviation "sigma" to a variable that is uniformly distributed n "[-1..+1]". *) PROCEDURE Stretch(x: LONG; sigma: LONG): LONG; (* The functional inverse of "Squeeze". *) PROCEDURE OldSqueeze(x: LONG; epsilon, delta: LONG): LONG; (* Returns the "significant" value of "x" assuming it is contaminated by noise of absolute magnitude "epsilon" and relative magnitude "delta". I.e. the result is approximately "x/epsilon" when "ABS(x)" is small, and approximately "SGN(x)*log(ABS(x))/delta" when "ABS(x)" is large *) PROCEDURE OldStretch(x: LONG; epsilon, delta: LONG): LONG; (* The functional inverse of "OldSqueeze". *) PROCEDURE Interpolate(t: LONG; t0, p0: LONG; t1, p1: LONG): LONG; (* Interpolates linearly the value at time "t" between values "p0" and "p1", assuming they have times "t0" and "t1". *) PROCEDURE CubicInterpolate( t: LONG; t0, p0: LONG; t1, p1: LONG; t2, p2: LONG; t3, p3: LONG; ): LONG; (* Interpolates cubically some function at time "t", assuming it has values "p0,..p3" at times "t0,..t3". *) PROCEDURE SelectAll(n: NAT): REF BOOLS; (* Returns a vector of "n" booleans, all TRUE. *) PROCEDURE AdjustUnit(givenUnit: LONG; dev, big: LONG): LONG; (* Adjusts the "givenUnit" for quantization of a variable whose standard deviation is "dev" and whose values range in "[-big..+big]". Will increase "givenUnit" if needed to avoid overflow, or decrease it to ensure quantization errors less than dev*10^-6. In any case, if "givenUnit" is changed, or no good unit was found, also prints a warning to "stderr". *) PROCEDURE SortOK(VAR x: NATS; VAR OK: BOOLS); (* Returns in "x" a permutation of the indices of "OK" that all elements "x[k]" with "OK[x[i]] = TRUE" are at the beginning. *) END PZProc. (* Copyright © 2001 Universidade Estadual de Campinas (UNICAMP). Authors: Helena C. G. Leitão and Jorge Stolfi. This file can be freely distributed, used, and modified, provided that this copyright and authorship notice is preserved, and that any modified versions are clearly marked as such. This software has NO WARRANTY of correctness or applicability for any purpose. Neither the authors nor their employers chall be held responsible for any losses or damages that may result from its use. *)