The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Inactive » comp.soft-sys.math.mathematica

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Flattening a hypermatrix into an ordinary matrix
Replies: 7   Last Post: Jun 2, 2012 5:51 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Carlos Felippa

Posts: 974
Registered: 12/6/04
Flattening a hypermatrix into an ordinary matrix
Posted: Jun 1, 2012 5:21 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

I have an n x n hypermatrix, the entries of which are m x m blocks.
For example A below (m=3, n=2):

A={{ A11,A12},{A21,A22}};

I want to convert this to an ordinary n*m x n*m matrix.
For the example I want A to become


This can be easily done with C style loops as

For [i=1,i<=n,i++, For[j=1,j<=n,j++,
For [k=1,k<=m,k++, For [l=1,l<=m,l++,

but is there a more elegant way using Flatten?
(Flatten[A,1] doesnt do it.) It should work also for blocks
of varying size for future use.

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.