A generalized Transpose?

• To: mathgroup at smc.vnet.net
• Subject: [mg9097] A generalized Transpose?
• From: Tom Burton <tburton at cts.com>
• Date: Mon, 13 Oct 1997 23:33:12 -0400
• Sender: owner-wri-mathgroup at wolfram.com

Consider first the nested list
In[16]:= ys1={{{a1,b1},{c1,d1}},{{a2,b2},{c2,d2}}};

It's easy to make the slowest index vary the fastest:
In[21]:= Transpose[ys1,RotateRight[Range[Depth[ys1]-1]]]
Out[21]= {{{a1,a2},{b1,b2}},{{c1,c2},{d1,d2}}}

MY QUESTION:

What I have is a list of structures of identical form, but each structure
is not rectangular. An example with only two structures is
ys={{a1,{b1,{c1,d1}}},{a2,{b2,{c2,d2}}}};

My question is, How can I make the similar change to this list, to obtain:
ysT={{a1,a2},{{b1,b2},{{c1,c2},{d1,d2}}}};

MY MOTIVE FOR THE QUESTION:

ys is a list of evaluations of a data structure at a
list of values of an independent variable, say x:

xs = {x1,x2}

Given ysT, it's relatively easy to set up the {x,y} pairs:
In[33]:= xys=Map[Transpose[{xs,#}]&,ysT,{-2}]
Out[33]= {{{x1,a1},{x2,a2}},{{{x1,b1},{x2,b2}},
{{{x1,c1},{x2,c2}},{{x1,d1},{x2,d2}}}}}

and then convert these to a structure of interpolations,
In[34]:= Map[Interpolation,xys,{-3}]
Out[34]= {Interpolation[{{x1,a1},{x2,a2}}],
{Interpolation[{{x1,b1},{x2,b2}}],
{Interpolation[{{x1,c1},{x2,c2}}],
Interpolation[{{x1,d1},{x2,d2}}]}}}
that matches the structure of my data.

This generalization of Interpolation to structured data would be quite
handy, but I am stumped by the first step in the process. Do you see how to
do this step or how to reach the goal another way?

Thanks for taking the time to read this.

Thomas E. Burton              353 Sanford Road
Brahea Consulting             Encinitas CA 92024-1508
tburton at cts.com               619/436-7436

• Prev by Date: Mathematical Libraries
• Next by Date: RE:
• Previous by thread: Re: Mathematical Libraries
• Next by thread: Re: A generalized Transpose?