Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*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 2006

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

Search the Archive

Re: matrix operations -- shared data vs copied

  • To: mathgroup at smc.vnet.net
  • Subject: [mg65935] Re: [mg65917] matrix operations -- shared data vs copied
  • From: Murray Eisenberg <murray at math.umass.edu>
  • Date: Mon, 24 Apr 2006 06:01:39 -0400 (EDT)
  • Organization: Mathematics & Statistics, Univ. of Mass./Amherst
  • References: <200604231017.GAA11827@smc.vnet.net>
  • Reply-to: murray at math.umass.edu
  • Sender: owner-wri-mathgroup at wolfram.com

A bit of simple experimentation will give you answers (as will carefully 
reading the documentation!).  And it has nothing whatsoever to do with 
the fact that you're working with a matrix.

   a = 1
1
   b = a
1
   b
1
   a = 2
2
   b
1

However, if you use SetDelayed (abbreviation := ) instead of Set 
(abbreviation = ) for giving b a value, then what happens is different:

   a = 1
1
   b := a
   b
1
   a = 2
2
   b
2


robert.dodier at gmail.com wrote:
> Hello,
> 
> I'm trying to get a handle on what Mathematica does with some
> matrix operations. I wasn't able to figure it out by web or newsgroups
> search so maybe you can help.
> 
> Suppose A is a matrix. Consider these operations.
> 
> (1) B = A
> 
> (2) myfunction[A]
> 
> (3) B = (some way of extracting column 1 of A)
> 
> (4) B = (some way of pasting A onto another matrix)
> 
> The question of interest is whether modifying elements of A also
> modify B after operations (1), (3), and (4), and whether modifications
> of the formal argument within myfunction also modify the actual
> argument (namely A).
> 
> In some math languages, B = A and myfunction[A] actually create
> copies of A, likewise row/column extraction and pasting matrices
> together. But that's not the only way to do it; I'm trying to figure
> out where Mathematica stands on this point.
> 
> Thanks for any pointers or other information.
> 
> Robert Dodier
> 
> 

-- 
Murray Eisenberg                     murray at math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower      phone 413 549-1020 (H)
University of Massachusetts                413 545-2859 (W)
710 North Pleasant Street            fax   413 545-1801
Amherst, MA 01003-9305


  • Prev by Date: Re: Where do I put my own add-on packages?
  • Next by Date: Periodic Rebirth of Hyperbolic Functions by ODE in Mathematica
  • Previous by thread: Re: matrix operations -- shared data vs copied
  • Next by thread: Re: matrix operations -- shared data vs copied