Putting together a larger matrix from smaller matrices

Robert Kern robert.kern at gmail.com
Tue Aug 25 14:42:31 EDT 2009


On 2009-08-24 21:30 PM, Matjaz Bezovnik wrote:
> Dear all,
>
> I'm but a layman so do not take offence at this maybe over simple
> question.
>
> This is something which is done often in FEM methods, and the alike.
>
> I have matrix A of 3x3 elements, and B, of the same number of
> elements, 3x3.
>
> What would be the most obvious way to assemble a matrix which:
> a11 a12 a13
> a21 a22 a23
> a31 a32 a33+b11 b12 b13
>                        b21 b22 b23
>                        b31 b32 b33
>
> (the missing elements = zero)
>
> (you see the pattern - if there was a third matrix C, it would
> "connect" to b33 on the main diagonal)

You will certainly want to use numpy for this and ask questions on the numpy 
mailing list.

   http://www.scipy.org/Mailing_Lists

I believe that someone recently posted a recipe for constructing such "block 
diagonal" arrays. I think it will be included in a future release of numpy.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco




More information about the Python-list mailing list