Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #16635

Re: matrix manipulation

From Roland Franzius <roland.franzius@uos.de>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: matrix manipulation
Date 2014-03-10 08:44 +0000
Message-ID <lfju0o$hlp$1@smc.vnet.net> (permalink)
References <lfeio3$5r1$1@smc.vnet.net>
Organization Time-Warner Telecom

Show all headers | View raw


Am 08.03.2014 09:01, schrieb dimanag78@gmail.com:
> Hello to all.
>
> I have the following 6x6 matrix
>
> Table[Subscript[C, k, j][i], {k, 1, 6}, {j, 1, 6}]
>
> I want this matrix to be symmetric, that is,
> Subscript[C, k, j][i] = Subscript[C, j, k][i] for j != k.
>
> In other words I want the matrix
>
> {{Subscript[C, 1, 1][i], Subscript[C, 1, 2][i], Subscript[C, 1, 3][i],
>     Subscript[C, 1, 4][i], Subscript[C, 1, 5][i],
>    Subscript[C, 1, 6][i]}, {Subscript[C, 1, 2][i],
>    Subscript[C, 2, 2][i], Subscript[C, 2, 3][i], Subscript[C, 2, 4][i],
>     Subscript[C, 2, 5][i],
>    Subscript[C, 2, 6][i]}, {Subscript[C, 1, 3][i],
>    Subscript[C, 2, 3][i], Subscript[C, 3, 3][i], Subscript[C, 3, 4][i],
>     Subscript[C, 3, 5][i],
>    Subscript[C, 3, 6][i]}, {Subscript[C, 1, 4][i],
>    Subscript[C, 2, 4][i], Subscript[C, 3, 4][i], Subscript[C, 4, 4][i],
>     Subscript[C, 4, 5][i],
>    Subscript[C, 4, 6][i]}, {Subscript[C, 1, 5][i],
>    Subscript[C, 2, 5][i], Subscript[C, 3, 5][i], Subscript[C, 4, 5][i],
>     Subscript[C, 5, 5][i],
>    Subscript[C, 5, 6][i]}, {Subscript[C, 1, 6][i],
>    Subscript[C, 2, 6][i], Subscript[C, 3, 6][i], Subscript[C, 4, 6][i],
>     Subscript[C, 5, 6][i], Subscript[C, 6, 6][i]}}
>
>
> Thank you very much, in advance, for yor help.
>

Avoid C, its reserved.

Use more advanced procedures like Outer and  Array with Sort.

Outer[Sort[{#1,#2}]&, #, #]&[Range[6]]
gives you the Matrix of a list of sorted pairs of indices from Range 
which is of course symmetric.


(Outer[ ( Subscript[k, Sequence @@ Sort[{#1, #2}]] &), #, #] &)[
  Range[6]]


You can use this method directly in array contructions

A = Array[Subscript[k, Sequence @@ Sort[{#1, #2}]] &, {6, 6}]


If you have already an array A of expressions, you can symmetrize it later

B=1/2 (A+Transpose[A])

For compactness and shielding from simplifikations I prefer number 
strings as indizes

Array[Superscript[k,
         StringJoin @@ ToString /@ Sort[{#1, #2}]] &, {6, 6}]

-- 

Roland Franzius

Back to comp.soft-sys.math.mathematica | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

matrix manipulation dimanag78@gmail.com - 2014-03-08 08:01 +0000
  Re: matrix manipulation Roland Franzius <roland.franzius@uos.de> - 2014-03-10 08:44 +0000
  Re: matrix manipulation dimanag78@gmail.com - 2014-03-12 07:29 +0000

csiph-web