MathGroup Archive 2000

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Rearranging a tensor

  • To: mathgroup at smc.vnet.net
  • Subject: [mg22463] Re: Rearranging a tensor
  • From: "Robert Nowak" <robert.nowak at ims.co.at>
  • Date: Sat, 4 Mar 2000 02:26:33 -0500 (EST)
  • Organization: telecom.at (Vienna, Austria)
  • References: <89icvm$n7d@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

hopefully this is simple enough.
if you are not familiar to mathematica funtional programming style better
dont try to understand it, but as you see .... it works.

In[10]:=
<< LinearAlgebra`MatrixManipulation`

In[11]:=
c // AppendRows @@ # & /@ # & // Flatten[#, 1] &

Out[11]=
{{1, 1, 1, 2, 2, 2}, {1, 1, 1, 2, 2, 2}, {1, 1, 1, 2, 2, 2}, {3, 3, 3, 4, 4,
    4}, {3, 3, 3, 4, 4, 4}, {3, 3, 3, 4, 4, 4}}


even simpler:

In[95]:=
BlockMatrix[c]

Out[95]=
{{1, 1, 1, 2, 2, 2}, {1, 1, 1, 2, 2, 2}, {1, 1, 1, 2, 2, 2}, {3, 3, 3, 4, 4,
    4}, {3, 3, 3, 4, 4, 4}, {3, 3, 3, 4, 4, 4}}


Robert
--
---
Robert Nowak (robert.nowak at ims.co.at)
Ionen Mikrofabrikations Systeme GmbH
A-1020 Wien, Schreygasse 3, Austria
Phone: (+43 1)2144894-32, Fax: (+43 1)2144894-99

DIAMOND Mark <noname at noname.com> wrote in message
news:89icvm$n7d at smc.vnet.net...
> I have
>
> In[1]:= a={{1,2},{3,4}};
>
> In[2]:= b=Table[1,{3},{3}];
>
> In[3]:= c=Outer[Times,a,b]
>
> Out[3]= {{{{1, 1, 1}, {1, 1, 1}, {1, 1, 1}},
>
> >     {{2, 2, 2}, {2, 2, 2}, {2, 2, 2}}},
>
> >    {{{3, 3, 3}, {3, 3, 3}, {3, 3, 3}}, {{4, 4, 4}, {4, 4, 4}, {4, 4,
4}}}}
>
> In[4]:= c//MatrixForm
>
> Out[4]//MatrixForm=
>                     1 1 1   2 2 2
>                     1 1 1   2 2 2
>                     1 1 1   2 2 2
>
>                     3 3 3   4 4 4
>                     3 3 3   4 4 4
>                     3 3 3   4 4 4
>
> I would now like to rearrange c so that it is of the form
>
{1,1,1,2,2,2},{1,1,1,2,2,2},{1,1,1,2,2,2},{3,3,3,4,4,4},{ 3,3,3,4,4,4},{3,3
> ,3,4,4,4}}
>
> There must be a *simple* way to do this but I cannot see it. Help would be
> appreciated.
>
> Cheers,
>
> Mark R Diamond
> Vision Research Laboratory
> The University of Western Australia
> no spam email: markd at psy dot uwa dot edu dot au
>
>
>




  • Prev by Date: Re: newbie, problems with loading packages
  • Next by Date: Re: Rearranging a tensor
  • Previous by thread: Re: Rearranging a tensor
  • Next by thread: Re: Rearranging a tensor