Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #14626

Re: Map

From Bob Hanlon <hanlonr357@gmail.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Map
Date 2013-05-25 09:33 +0000
Message-ID <knq0i3$59c$1@smc.vnet.net> (permalink)
References <20130524102517.549836A70@smc.vnet.net>
Organization Time-Warner Telecom

Show all headers | View raw


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 Hanlon


On Fri, May 24, 2013 at 6:25 AM, Jon Morris <djpmorris@googlemail.com>wrote:

> I'm new to Mathematica and I've been given some code to help me analyse
> some data. I'm trying to understand what the Map function does,
> specifically what the {2,2} means?
>
>    qbarlist = Map[(# - bragg) &, hkllist,{2, 2}];
>
> hklist is a 3 column list, bragg is a three element vector.
>
> When I try the same line with {2} or {1} I seem to get the same answer.
> The online explanation of this term does not make that much sense to me.
> I'd be very grateful if someone could explain the purpose of the last term
> of the Map syntax.
>
> Thanks,
> Jon
>
>

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: Map Bob Hanlon <hanlonr357@gmail.com> - 2013-05-25 09:33 +0000

csiph-web