MathGroup Archive 2006

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

Search the Archive

Re: creating a symbolic square symmetric matrix


ravi wrote:

>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, use the condition  " /;i>j " in the definition of your symmetric matrix

Subscript[a,i_,j_]/;i>j:=Subscript[a,j,i]

mat[n_]:=Table[Subscript[a,i,j],{i,n},{j,n}] 

example: 
mat[3]//MatrixForm



Heinz Spindler


  • Prev by Date: Re: creating a symbolic square symmetric matrix
  • Next by Date: Re: General--Differential equation problem..
  • Previous by thread: Re: creating a symbolic square symmetric matrix
  • Next by thread: License server issue