[jmichel@math.jussieu.fr: Re: [GAP Forum] block matrix]

Jean Michel jmichel at math.jussieu.fr
Wed Jun 8 20:53:16 BST 2005


----- Forwarded message from Jean Michel <jmichel at math.jussieu.fr> -----

Date: Wed, 8 Jun 2005 21:48:33 +0200
From: Jean Michel <jmichel at math.jussieu.fr>
To: Luca Giuzzi <giuzzi at dmf.unicatt.it>
Subject: Re: [GAP Forum] block matrix
Message-ID: <20050608194833.GA3206 at math.jussieu.fr>
References: <Pine.GSO.4.05.10506072337210.19905-100000 at gauss> <20050608092522.GA20250 at dmf.unicatt.it>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20050608092522.GA20250 at dmf.unicatt.it>
User-Agent: Mutt/1.5.6i
Status: RO
Content-Length: 1725
Lines: 46

On Wed, Jun 08, 2005 at 11:25:22AM +0200, Luca Giuzzi wrote:
> On Tue, Jun 07, 2005 at 11:39:53PM -0400, Vahid Dabbaghian-Abdoly wrote:
> > Dear GAP Forum,
> > 
> > I am want to construct a diagonal block matrix such that the 
> > diagonal entries have different dimensions.
> > Is there any function or method for such a matrix in GAP?
> > 
> > Best regards, Vahid
> > 
> > 
> There is no such function I am aware of in GAP ...
> (I actually got this snippet from somebody on the mailing list some time
> ago)

The following function from the CHEVIE package may help

#############################################################################
##
#F  DiagonalMat( <m1>,...,<mn> ) diagonal block-matrix
##
##  returns the block diagonal matrix with diagonal entries
##  <m1>  ... <mn> 
##  m_i may be rectangular or empty; blocks of size 1x1 may be given as
scalars
##  DiagonalMat( <v> ) where v is a list of scalars is like
DiagonalMat(v1,..vn)
##
DiagonalMat:=function(arg)local res,fr,fc,r,c,m;
  if Length(arg)=1 and IsList(arg[1]) and Length(arg[1])>0 and not
    IsList(arg[1][1]) then arg:=arg[1];fi;
  fr:=function(m)if IsMat(m) then return Length(m);else return 1;fi;end;
  fc:=function(m)if not IsMat(m) then return 1;
    elif Length(m)=0 then return 0; else return Length(m[1]);fi;end;
  res:=NullMat(Sum(arg,fr),Sum(arg,fc));
  r:=0;c:=0;
  for m in arg do
    if IsMat(m) then res{r+[1..fr(m)]}{c+[1..fc(m)]}:=m;
    else res[r+1][c+1]:=m;fi;
    r:=r+fr(m);c:=c+fc(m);
  od;
  return res;
end;
------------------------------------------------------------------------
Jean MICHEL, Equipe des groupes finis, Institut de Mathematiques UMR7586 
Bureau 9D17 tel.(33)144278119, 175, rue du Chevaleret 75013 Paris

----- End forwarded message -----

-- 
------------------------------------------------------------------------
Jean MICHEL, Equipe des groupes finis, Institut de Mathematiques UMR7586 
Bureau 9D17 tel.(33)144278119, 175, rue du Chevaleret 75013 Paris




More information about the Forum mailing list