Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2004
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

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

Search the Archive

Re: Creating a symmetric matrix

  • To: mathgroup at smc.vnet.net
  • Subject: [mg46986] Re: Creating a symmetric matrix
  • From: Paul Abbott <paul at physics.uwa.edu.au>
  • Date: Thu, 18 Mar 2004 04:38:01 -0500 (EST)
  • Organization: The University of Western Australia
  • References: <c2p9ld$dns$1@smc.vnet.net> <200403130440.XAA15145@smc.vnet.net> <A8166766-7689-11D8-A63D-0003938BF55C@jeol.com> <c36baq$s26$1@smc.vnet.net> <c3bfgk$7i5$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

In article <c3bfgk$7i5$1 at smc.vnet.net>,
 Paul Abbott <paul at physics.uwa.edu.au> wrote:

> In article <c36baq$s26$1 at smc.vnet.net>, DrBob <drbob at bigfoot.com> 
> wrote:
> 
> > Building a matrix that large (2000x2000), when half the information is 
> > redundant, is probably a bad idea in the first place; and that applies to 
> > the upper-triangular matrix you're taking it from as well.
> > 
> > Instead, you should write code that uses the necessary information more 
> > efficiently.
> > 
> > SparseArray also may be of help.
> 
> Perhaps something like
> 
>   Flatten[Table[{i,j} -> a[i,j],{j, 1, 4}, {i, 1, j}]];
> 
>   % /. ({i_, j_} -> a_) :> {j, i} -> a;
> 
>   Normal[SparseArray[Join[%, %%]]]

or maybe

  tri = Flatten[Table[{i, j} -> a[i, j], {j, 1, 4}, {i, 1, j}]]

  diag = Cases[tri, c:({i_, i_} -> a_) -> c]

  tri = SparseArray[tri]

  diag = SparseArray[diag]

  tri + Transpose[tri] - diag

  Normal[%]

Cheers,
Paul

-- 
Paul Abbott                                   Phone: +61 8 9380 2734
School of Physics, M013                         Fax: +61 8 9380 1014
The University of Western Australia      (CRICOS Provider No 00126G)         
35 Stirling Highway
Crawley WA 6009                      mailto:paul at physics.uwa.edu.au 
AUSTRALIA                            http://physics.uwa.edu.au/~paul


  • Prev by Date: Re: doing things on a procedural way and doing them on a functional way
  • Next by Date: Re: Re: Exact real solutions of cubic equations
  • Previous by thread: Re: Creating a symmetric matrix
  • Next by thread: Re: Creating a symmetric matrix