Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2004
*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 2004

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

Search the Archive

Re: Alternative to defining 'operator' function?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg47551] Re: Alternative to defining 'operator' function?
  • From: Paul Abbott <paul at physics.uwa.edu.au>
  • Date: Thu, 15 Apr 2004 05:02:17 -0400 (EDT)
  • Organization: The University of Western Australia
  • References: <c5leel$bit$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

In article <c5leel$bit$1 at smc.vnet.net>,
 "Owen, HL (Hywel)" <H.L.Owen at dl.ac.uk> wrote:

> I often have programming problem where I'd like to calculate a set of dot
> products, e.g. applying a list of square matrices {R1,R2,R3...} to a vector
> v to obtain:
> 
> {R1.v,R2.R1.v,R3.R2.R1.v,...}
> 
> or other functions like that.

Distribute works here:

 Distribute[{Subscript[R,1], Subscript[R,2], Subscript[R,3]} . v, List]

> The method I've been using is to define an 'operator' function, e.g.
> 
> DotOperator[M_] := Dot[M, #] &
> 
> Then we have:
> 
> In: DotOperator[R][v]
> Out: R.v
> 
> as wanted, so that we can define a ComposeList as
> 
> In: Rest[ComposeList[DotOperator[#] & /@ {R1, R2, R3}, v]]
> Out: {R1.v, R2.R1.v, R3.R2.R1.v}
> 
> to obtain the result we want.
> 
> Is there a simpler way than this that doesn't involve defining functions
> like DotOperator?

Here is one way. Define the action of Rn on v:

  Subscript[R, n_][v_] := Subscript[R, n] . v

then use ComposeList:

  Rest[ComposeList[Subscript[R,1], Subscript[R,2], Subscript[R,3]}, v]]

Cheers,
Paul

-- 
Paul Abbott                                   Phone: +61 8 9380 2734
School of Physics, M013                         Fax: +61 8 9380 1014
The University of Western Australia      (CRICOS Provider No 00126G)         
35 Stirling Highway
Crawley WA 6009                      mailto:paul at physics.uwa.edu.au 
AUSTRALIA                            http://physics.uwa.edu.au/~paul


  • Prev by Date: Re: DirectMath experience
  • Next by Date: Re: Question: ABS and \[Prime]
  • Previous by thread: Alternative to defining 'operator' function?
  • Next by thread: Re: Alternative to defining 'operator' function?