MathGroup Archive 2011

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

Search the Archive

Re: concatenate matrices?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg118166] Re: concatenate matrices?
  • From: Murray Eisenberg <murray at math.umass.edu>
  • Date: Fri, 15 Apr 2011 03:55:27 -0400 (EDT)

Perhaps DrMajorBob has already replied, but here's my take on why folks 
use prefix notation: to avoid nesting brackets and/or braces. The more 
you do nest, the harder things may become to read at a glance.

Postfix is often used for the same purpose. Another reason is so that 
the main idea of what's being done is the expression to the left of the 
postfix operator // and then the expression to the right of // is, in a 
sense, an "afterthought" -- oh yes, do this to what you get.  For example,

   (* Solve a quadratic; oh, yes: then approximate it numerically *)
   Solve[x^2 - 7 x + 5 == 0, x] // N

   (* ditto; oh, yes, display enough digits in the result *)
   NSolve[x^2 - 7 x + 5 == 0, x] // NumberForm[#, 12] &

In the latter instance, it's not only the connotation of an 
"afterthought" being accomplished through postfix notation. This also is 
avoiding a nested expression -- one that can be considerably harder to 
read since the second argument, 12, to NumberForm, appears only at the 
end of a relatively long expression:

   NumberForm[NSolve[x^2 - 7 x + 5 == 0, x], 12]

Once you're comfortable not just with postfix notation but also pure 
functions (using # and &), you may well find the postfix form more 
transparent than the straightforward, but nested, form without postfix. 
Especially as the base expression becomes more complicated.

On 4/14/2011 4:50 AM, Robert Rosenbaum wrote:
> DrMajorBob,
>
> A little off topic, but I was wondering why you suggested the prefix notation
>> Transpose@{y1, y2}
> instead of
> Transpose[{y1,y2}]
>
> I've noticed other people doing the same on this mailing list, and sometimes suggesting postfix as well.  I would guess that Transpose[{y1,y2}] is more readily understood by most users.  Is there a reason that you and others often suggest the arguably less common prefix or postfix notations?
>
>
> Best,
> Robert
>
>
> On Apr 12, 2011, at 4:56 AM, DrMajorBob wrote:
>
>> Transpose@{y1, y2}
>>
>> Bobby
>>
>> On Mon, 11 Apr 2011 06:08:14 -0500, hadi motamedi<motamedi24 at gmail.com>
>> wrote:
>>
>>> Dear All
>>> I have two column matrices named y1&  y2 with dimensions as 448000*1 .
>>> Can you please let me know how to construct a new matrix say 'y' with
>>> dimensions 448000*2 such that each column of it equals y1(or y2)?
>>> Thank you
>>>
>>
>>
>> --
>> DrMajorBob at yahoo.com
>>
>
>
>
>
>
>
>

-- 
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: concatenate matrices?
  • Next by Date: Re: concatenate matrices?
  • Previous by thread: Re: concatenate matrices?
  • Next by thread: Re: concatenate matrices?