MathGroup Archive 2004

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

Search the Archive

Re: Assigning elements to a matrix

  • To: mathgroup at smc.vnet.net
  • Subject: [mg47371] Re: [mg47358] Assigning elements to a matrix
  • From: Sseziwa Mukasa <mukasa at jeol.com>
  • Date: Wed, 7 Apr 2004 03:16:29 -0400 (EDT)
  • References: <200404061036.GAA09276@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

On Apr 6, 2004, at 6:36 AM, Mark Coleman wrote:

> Greetings,
>
> I need to create a series of n x n matrices, in both conventional and
> sparse matrix formats. I have a (large) table of lists, where each list
> is of the form:
>
> {i,j,value}, where {i,j} are the row-column indices and value is the
> corresponding numerical value, i.e., m[[i,j]]=value.
>
> Using this data I need to create an n x n matrix where all the values
> except those specified in my list are 0. I would also like to create a
> similar matrix, this time using Mathematica's built-in SpareMatrix 
> format.
>
> Can anyone suggest a way to do this?
>

Assuming lst is of the form of your data:

m=SparseArray[{#1,#2}->#3&@@@lst]

Regards,

Ssezi


  • Prev by Date: Re: All combinations
  • Next by Date: Re: Scientific Notation in ListPlot Axes
  • Previous by thread: Assigning elements to a matrix
  • Next by thread: Re: Assigning elements to a matrix