MathGroup Archive 2013

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

Search the Archive

Re: Map

  • To: mathgroup at smc.vnet.net
  • Subject: [mg130922] Re: Map
  • From: Jon Morris <djpmorris at googlemail.com>
  • Date: Sat, 25 May 2013 05:41:19 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-outx@smc.vnet.net
  • Delivered-to: mathgroup-newsendx@smc.vnet.net

Explanation received via email reposted incase it helps other people:


hklist = Array[h, {5, 3}];

bragg = {b1, b2, b3};

qbarlist = Map[(# - bragg) &, hklist, {2, 2}];

As stated in the documentation ( http://reference.wolfram.com/mathematica/ref/Map.html ), the third argument to Map is the level specification and the form {n1, n2} specifies levels n1 through n2. In this case n1 and n2 are equal so it is equivalent to just {n1}.

qbarlist === Map[(# - bragg) &, hklist, {2}]

True

If you look at your outputs carefully you will see that you do not get the same result with a third argument of {1}

qbarlist === Map[(# - bragg) &, hklist, {1}]

False

qbarlist // Dimensions

{5, 3, 3}

Map[(# - bragg) &, hklist, {1}] // Dimensions

{5, 3}

Examine the two different arrays above to understand the different behavior.

Bob



Reply:

What I was hoping it would give as a result was:

{{h[1,1]-b1, h[1,2]-b2, h[1,3]-b3},
 {h[2,1]-b1, h[2,2]-b2, h[2,3]-b3},
 {h[3,1]-b1, h[3,2]-b2, h[3,3]-b3},...

After your explanation I realise that I get that result with Map[(#-bragg) &, hkllist, {1}] and this makes me think that this may have given a bug in the original code.

Thanks for your help!



  • Prev by Date: Re: Silly question on how to insert sections, subsections and etc. on a notebook
  • Next by Date: Re: Work on Basic Mathematica Stephen!
  • Previous by thread: Re: Map
  • Next by thread: Re: Silly question on how to insert sections, subsections and etc.