How to "unflatten"?

• To: mathgroup at smc.vnet.net
• Subject: [mg83884] How to "unflatten"?
• From: Hauke Reddmann <fc3a501 at uni-hamburg.de>
• Date: Mon, 3 Dec 2007 07:09:06 -0500 (EST)

```Excuse a complete noob's question:

I do calculations with S matrices and need to convert
the tensor form Sab_cd (which would be e.g. the nested
list {{{{,},{,}},{{,},{,}}},{{{,},{,}},{{,},{,}}}} -
I omitted variables a1-a16, since only the structure
of the list, a 2*2*2*2 nest, is relevant) into a
matrix Mab_cd: {{,,,},{,,,},{,,,},{,,,}}. That is trivial:
Mab_cd=Partition[Flatten[Sab_cd],4].

But how to reverse the process? Of course even I already
can write a quadruple loop S[[,,,]]=M[,] with direct
handover of elements, but that is so unelegant, especially
as I have to apply this a hundred times in the computation
(and can't write subroutines yet, I'm a noob after all :-)

Question 2: I could skip the whole converting if I knew
how to do an Einstein sum over two indices inside a tensor:
Sab_cd -> Sab_ca -> sum(a=1,n,Sab_ca) -> Tb_c.
At the moment I do this whith "blocking" multiple indices
into a matrix and then do the matrix product, but this is
more a clever hack.
--
Hauke Reddmann <:-EX8    fc3a501 at uni-hamburg.de
order stormed the surface where chaos set norm
had there always been balance? ...surely not
therein lies the beauty

```

• Prev by Date: Re: Hiding number cell
• Next by Date: Re: Hiding number cell
• Previous by thread: Re: Re: Presentations Package Announcement
• Next by thread: Re: How to "unflatten"?