Home > Archive > APL > September 2007 > Dyadic Transpose
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| David Liebtag 2007-09-06, 6:57 pm |
| Wow! For the first time in my 27 year career with APL, I just needed to use
dyadic transpose!
David
| |
| phil chastney 2007-09-07, 3:57 am |
| David Liebtag wrote:
> Wow! For the first time in my 27 year career with APL, I just needed to use
> dyadic transpose!
at one of the APL conferences, somebody had looked at uses of dyadic
transpose, and found that the majority of them were there to get the
axes in the "right" order for inner products and encode
the suggestion was that maybe dyadic transpose could be replaced by a
more powerful axis operator (which would be considerably faster, since
it only required a re-ordering of the addressing polynomial, rather than
a re-ordering of the actual elements)
dunno who it was, dunno when it was, dunno if anything came of it
all the same, 27 years is a long time -- are you stuck in some sort of
2-D world? . . . /phil
| |
| David Liebtag 2007-09-07, 7:57 am |
| I too used it to correct the order of the axes after a decode. I guess that
previously when I had trouble with axes order, I rearranged my arrays so
they were already in the correct order and did not need correction. This
time, I am working with data whose structure was determined by someone else
and since I couldn't rearrange the initial data, I had to use decode to fix
it.
David Liebtag
| |
| Morten Kromberg 2007-09-07, 7:57 am |
| On Sep 7, 10:40 am, phil chastney
<phil.hates.s...@amadeus.munged.eclipse.co.uk> wrote:
> David Liebtag wrote:
>
> at one of the APL conferences, somebody had looked at uses of dyadic
> transpose, and found that the majority of them were there to get the
> axes in the "right" order for inner products and encode
>
> the suggestion was that maybe dyadic transpose could be replaced by a
> more powerful axis operator (which would be considerably faster, since
> it only required a re-ordering of the addressing polynomial, rather than
> a re-ordering of the actual elements)
>
> dunno who it was, dunno when it was, dunno if anything came of it
>
> all the same, 27 years is a long time -- are you stuck in some sort of
> 2-D world? . . . /phil
In SHARP APL and J, the rank operator does some of this. We're
thinking seriously about adding rank to Dyalog, but do not yet have a
timetable for this.
For example, if you have a 3-dimensional array where each row has 3
elements and contains (hours minutes seconds), then
24 60 60 (decode rank 1) data
.... will decode each rank 1 subarray. An (encode rank 1 0) of that
result (1 0 meaning combine vectors on the left with scalars on the
right) would get you back to your original array, too.
In J, this doesn't seem to be necessary (but it does work), as they
changed encode and decode to work the way you usually want, having the
luxury of a little hindsight.
Morten
| |
|
|
"Morten Kromberg" <mkrom@dyalog.com> wrote in message
news:1189164841.098369.150770@r34g2000hsd.googlegroups.com...
> On Sep 7, 10:40 am, phil chastney
> <phil.hates.s...@amadeus.munged.eclipse.co.uk> wrote:
>
> In SHARP APL and J, the rank operator does some of this. We're
> thinking seriously about adding rank to Dyalog, but do not yet have a
> timetable for this.
>
> For example, if you have a 3-dimensional array where each row has 3
> elements and contains (hours minutes seconds), then
>
> 24 60 60 (decode rank 1) data
>
> ... will decode each rank 1 subarray. An (encode rank 1 0) of that
> result (1 0 meaning combine vectors on the left with scalars on the
> right) would get you back to your original array, too.
>
> In J, this doesn't seem to be necessary (but it does work), as they
> changed encode and decode to work the way you usually want, having the
> luxury of a little hindsight.
>
> Morten
>
I used to use it in a similar way with dates: ymd's, read from db's,
along with decode, but can't find an example right away
| |
|
| On Sep 7, 9:39 am, "jk" <*a...@planet.nl> wrote:
>
> I used to use it in a similar way with dates: ymd's, read from db's,
> along with decode, but can't find an example right away- Hide quoted text -
There is always the "classic" example of column-wise ordering of text
as in telephone directories or newspapers where you first make a 3D of
it, transpose the first 2 axes and reshape in 2D to get what you want.
I must admit, tho, that in 30 years of APL I haven't used transpose
that often. Some functions you don't use much _in general_ like
domino, en/decode. Other things like dimensions >3 (the most I've used
is 5, once!) are not used much...
| |
|
|
"del" <del5@hotmail.com> wrote in message
news:1189339609.312185.147880@50g2000hsm.googlegroups.com...
> On Sep 7, 9:39 am, "jk" <*a...@planet.nl> wrote:
>
> There is always the "classic" example of column-wise ordering of text
> as in telephone directories or newspapers where you first make a 3D of
> it, transpose the first 2 axes and reshape in 2D to get what you want.
> I must admit, tho, that in 30 years of APL I haven't used transpose
> that often. Some functions you don't use much _in general_ like
> domino, en/decode. Other things like dimensions >3 (the most I've used
> is 5, once!) are not used much...
>
{decode} is a very powerful function and widely used in actuarial practice
(David Michelson in Actuarial and Financial Applications with Base-Value
- APL89 Conference Proceedings; and an article by myself in Base-Value
in Actuarial Practice - QQ Dec. 1991)
I used {domino} a single time in solving King-Hardy's equation system - a
transform from an exponential function for graduation of mortality (Makeham:
lx <- s*x . g*c*x, a strictly increasing function, in which x = age and s, g
and c are constants to be solved from the raw demographic material)
| |
|
| On Sep 9, 8:06 am, del <d...@hotmail.com> wrote:
> On Sep 7, 9:39 am, "jk" <*a...@planet.nl> wrote:
>
>
>
>
> There is always the "classic" example of column-wise ordering of text
> as in telephone directories or newspapers where you first make a 3D of
> it, transpose the first 2 axes and reshape in 2D to get what you want.
> I must admit, tho, that in 30 years of APL I haven't used transpose
> that often. Some functions you don't use much _in general_ like
> domino, en/decode. Other things like dimensions >3 (the most I've used
> is 5, once!) are not used much...
I found a slick use for dyadic transpose: printing mailing labels, N-
up. Sounds like the same problem.
If you have a rank-3 array of mailing labels (1000 labels at 5 rows
and 30 columns each - a 100x5x30 tensor), you
can use a single reshape after a dyadic transpose to print them N-up.
I prefer the approach taken in J: take some subset of axes and move
them to the end of
the shape vector. That handles just about every problem that arises in
practice and, as
Phil Chastney points out, it's a LOT easier. The J approach has the
added advantage that
people can understand its definition without having sit down try it
out with examples
each time you need to use it!
Bob
| |
| Bob Armstrong 2007-09-12, 6:57 pm |
| On Sep 6, 3:58 pm, "David Liebtag" <DavidLieb...@vermontel.net> wrote:
> Wow! For the first time in my 27 year career with APL, I just needed to use dyadic transpose!
I remember using some hairy 3 and 4 D transposes , even some reducing
"traces" ~ 27 years ago when I learned APL to do the math I was
interested in . Always had trouble with indexing of the axes being the
inverse of my intuition .
In 4th.CoSy , which I've just received confirmation that I'll be
presenting a tutorial on at APL2007 , I have only implemented a simple
"flip" of the leading pair of axes ala Whitney's "K" . Deeper axes can
be reached with "each" . Having "eachleft" and "eachright" helps
reduce the need for flip and enclose tricks .
| |
|
| In article <1189115902.558324@r2d2.vermontel.net>,
David Liebtag <DavidLiebtag@vermontel.net> wrote:
>Wow! For the first time in my 27 year career with APL, I just needed to use
>dyadic transpose!
Not bad. It only took me 17 years.
Seth
|
|
|
|
|