[comp.lang.misc] The number of aliasing patterns for N arrays

brnstnd@stealth.acf.nyu.edu (04/13/90)

In article <14332@lambda.UUCP> jlg@lambda.UUCP (Jim Giles) writes:
> From article <20080@megaron.cs.arizona.edu>, by gudeman@cs.arizona.edu (David Gudeman):
> > Actually, it increases exponentially with the number of aliasing
> > patterns in the arguments of the functions.  For a function of 3
> > array arguments, the maximum number of versions needed is 2^3 = 8.
> No, the number increases combinatorially.  Aliasing occurs pairwise
> between arguments (an/or global data).  So, the number of potentially
> aliased pairs is N choose 2, ie. a binomial coefficient.
  [ implying that the number of versions is 2^(N choose 2), not 2^N ]

Hmmm, this doesn't sound right. After all, if A and B could be aliased,
and B and C could be aliased, then A and C could be aliased. (This is
why the natural keyword is ``alias,'' not ``noalias.'')

I count 2 for 2, 5 for 3, 15 for 4, 52 for 5, 218 for 6. Go figure.

Anyway, this is all irrelevant, because as Jim loves to remind us,
aliasing is rarely useful. (It can't be---otherwise Fortran would allow
it.) Therefore you only need two versions: the amazingly fast one for no
aliasing, and the slow one for the rare cases. Right, Jim?

---Dan