MathGroup Archive 1998

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

Search the Archive

Re: Assignment to a block inside a matrix


  • To: mathgroup@smc.vnet.net
  • Subject: [mg10702] Re: Assignment to a block inside a matrix
  • From: Paul Abbott <paul@physics.uwa.edu.au>
  • Date: Fri, 30 Jan 1998 04:24:37 -0500
  • Organization: University of Western Australia
  • References: <6ahnqi$phs@smc.vnet.net>

John JOWETT wrote:

>       I have a package that works with the "symplectic unit matrix"
> defined for an n-degree of freedom Hamiltonian system by
> 
> symJ[n_Integer]:=
>   Block[{s},s=Table[0,{2n},{2n}];
>     Do[
>        s[[{k+1,k+2},{k+1,k+2}]]={{0,1},{-1,0}},
>        {k,0,2n-2,2}
>       ];s]
> 
> I.e. the definition involves the assignment to a 2 by 2 sub-matrix. Can
> someone tell me authoritatively whether this programming  construct is
> correct or whether I need to rewrite the function  using ReplacePart or
> something?   

This is fine (very much looks like a bug in the latest Windows version).


BTW, here is a recursive alternative:

In[1]:= << "LinearAlgebra`MatrixManipulation`" In[2]:= zero[n_] :=
Table[0, {n}, {2}] In[3]:= symJ[1] = {{0, 1}, {-1, 0}};  In[4]:=
symJ[n_] := symJ[n] = 
   BlockMatrix[{{symJ[n - 1], zero[2n - 2]}, 
     {Transpose[zero[2n - 2]], symJ[1]}}]

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@physics.uwa.edu.au  AUSTRALIA                            
http://www.pd.uwa.edu.au/~paul

            God IS a weakly left-handed dice player
____________________________________________________________________



  • Prev by Date: Re: output form
  • Next by Date: Bug? Can suddenly not edit with LINUX Frontend
  • Prev by thread: Re: Assignment to a block inside a matrix
  • Next by thread: A web page for gee-whizz Mathematica examples?