Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1998
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1998

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

Search the Archive

Re: Block diagonal systems

  • To: mathgroup at smc.vnet.net
  • Subject: [mg13600] Re: Block diagonal systems
  • From: Paul Abbott <paul at physics.uwa.edu.au>
  • Date: Fri, 7 Aug 1998 03:08:05 -0400
  • Organization: University of Western Australia
  • References: <6puia4$6t2@smc.vnet.net> <6q3qq1$f1n@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Rolf Mertig wrote:

> One possibility is:
> 
> In[1]:= BlockDiagonalMatrix[mat_List /;
>      And @@ (MatchQ[Dimensions[#1], {_, _}] & ) /@ mat, fillit_:0] :=
>    Module[{b = {0,0}, f, m}, f[{x_,y_}][e_, {r_, s_}] :=
>       Set @@ {m[r + x, s + y], e};
>      Do[MapIndexed[f[b], mat[[i]], 2]; b+= Dimensions[mat[[i]]],
>       {i, Length[mat]}]; Array[m, b] /. m[_, _] -> fillit];

Nice solution. As a slight improvement, you can replace

  mat_List /; And @@ (MatchQ[Dimensions[#1], {_, _}] & ) /@ mat

with

  mat:{_?MatrixQ..}

Cheers,
	Paul 

____________________________________________________________________ 
Paul Abbott                                   Phone: +61-8-9380-2734
Department of Physics                           Fax: +61-8-9380-1014
The University of Western Australia            Nedlands WA  6907       
mailto:paul at physics.uwa.edu.au  AUSTRALIA                       
http://www.physics.uwa.edu.au/~paul

            God IS a weakly left-handed dice player
____________________________________________________________________


  • Prev by Date: Re: What is the fastest machine for Mathematica?
  • Next by Date: MathGroup/Newsgroup Search Engine
  • Previous by thread: Re: Block diagonal systems
  • Next by thread: Mandelbrot