I need to choose. Consider this:

        a . i . j

where a is an array of arrays. The first or closest index i selects an inner
array of a, and the second, fastest moving index j selects an element
of the inner array.

To scan the inner elements contiguously we must use he formula

        linear_index = i * N + j

If you view it like this:

//      j=0,1,2

        ( (0,1,2),  // i = 0
          (3,4,5),  // i =1
          (6,7,8) ) // i=2

i is selecting a row, and j a column. In this view a "top level"
array is a column vector. Actually I personally see it the other
way, that is, I see a row of columns. YMMV :)

Now, remember there is a more fundamental way
to do projections:

        j (i a)

because the dot (.) notation is just reverse application.

So here's the problem: if we convert the array of arrays to
a matrix, that is a single linear array with a tuple argument,
what order do the indices go in?

If we take:

        a . i . j ==> mat(a) . (i,j)

preserving the index order, then we unfortunately get this as equivalent:

        (i,j) mat(a)

I ask this question because at the moment Felix is bugged:
it uses both orderings in different places, so now is the time
to fix the order.

I like this rule:

        int ^ N ^ M => int ^ (N * M)

which is what I thought was implemented (but apparently in
some places M and N are swapped).

Note this rule is equivalent to:

        a . i . j ==> a . (j,i)

because the first applied index i eliminates the M leaving int ^ N.

So roughly: if we preserve the index order for the type notation
we have to swap it for the index values (relative to the dot notation:
the order is preserved for the functional notation).



--
john skaller
skal...@users.sourceforge.net
http://felix-lang.org




------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to