Re: creating a symbolic square symmetric matrix
- To: mathgroup at smc.vnet.net
- Subject: [mg66330] Re: creating a symbolic square symmetric matrix
- From: Peter Pein <petsie at dordos.net>
- Date: Wed, 10 May 2006 06:33:12 -0400 (EDT)
- References: <e3pege$ifq$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
ravi schrieb:
> Hi,
> First, I created a square matrix with the following command :
> n=4;
> mat=Table[Subscript[a,i, j],{i,n},{j,n}]
> In the same style, I would like to create a symmetric matric where all
> a[i, j] is replaced by a[j,i] for i>j. For i<=j, the coefficients
> remain in place.
> I tried to use the replace command :
> Replace[mat,Subscript[a,i,j]->Subscript[a,j,i]]
> This just interchanged the elements. I want this replacement only for
> the lower or upper triangular matrix elements.
> Would appreciate tips of doing a conditional substitution.
> /ravi
>
Hi ravi,
you might want to try
mat = Array[Subscript[a, Sequence @@ Through[{Min, Max}[##]]]&, {n, n}]
so there's no need to do a Replace[].
Peter