MathGroup Archive 1999

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

Search the Archive

Re: re: my previous question on matrix element assignment

  • To: mathgroup at smc.vnet.net
  • Subject: [mg17262] Re: [mg17236] re: my previous question on matrix element assignment
  • From: Daniel Reeves <dreeves at eecs.umich.edu>
  • Date: Fri, 30 Apr 1999 02:34:45 -0400
  • Sender: owner-wri-mathgroup at wolfram.com

Not sure I understand your solution... What is f?
Here's what I did:

SetAttributes[setIndex, HoldFirst]
setIndex[mat_, index_, value_]:= mat[[Sequence@@index]] = value

SetAttributes[setIndices, HoldFirst]
setIndices[mat_, indices, values_]:=
  MapThread[setIndex[mat,#1,#2]&, {indices, values}]

--    --    --    --    --    --    --    --    --    --    --    -- 
Daniel Reeves               http://ai.eecs.umich.edu/people/dreeves/

"The idea of programming in a low level language like C will seem as
specialized and esoteric as programming in microcode or assembler 
seems today."  -- Stephen Wolfram, creator of Mathematica


On Mon, 26 Apr 1999, Richard Finley wrote:

> 
> Nothing like posting a question to the group to make you see the answer...I
> had asked how to
> make assignments to certain matrix elements of (for example) mat =
> Array[mat,{3,3}]  where the indices of the matrix elements to be assigned
> are in the list v = {{1,2},{1,3},{2,3},{3,1}} and the values they are to be
> assigned are in the list w = {1, 4, 2, 5}, so m[1,2]=1, m[1,3]=4, etc...
> 
> My head is now clear enough to see the answer:
> 
> sol=mat/.Thread[f/@v->w]
> 
> Thanks to anyone who thinks about it anyway and I am interested to see any
> other approaches.
> 
> Richard Finley
> 




  • Prev by Date: Re: Counting list elements above/below a given value
  • Next by Date: Re: Mathematica 3.0 and Visual Basic
  • Previous by thread: Re: my previous question on matrix element assignment
  • Next by thread: Re: Re: my previous question on matrix element assignment