MathGroup Archive 2004

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

Search the Archive

Re: Creating a symmetric matrix


The problem with that, I think, is that it replaces n(n+1)/2 elements
(some of which may be zeroes) with n^2 rules. The result has Head
equal to SparseArray, true, but it's anything but sparse.

Bobby

Paul Abbott <paul at physics.uwa.edu.au> wrote in message news:<c3bqrj$f2f$1 at smc.vnet.net>...
> 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


  • Prev by Date: Notebook path in title bar of window and/or notebooks menu
  • Next by Date: Re: Lists
  • Previous by thread: Re: Creating a symmetric matrix
  • Next by thread: Font size