[Date Index]
[Thread Index]
[Author Index]
RE: Alternative to defining 'operator' function?
*To*: mathgroup at smc.vnet.net
*Subject*: [mg47565] RE: [mg47505] Alternative to defining 'operator' function?
*From*: "Owen, HL (Hywel)" <H.L.Owen at dl.ac.uk>
*Date*: Fri, 16 Apr 2004 05:20:34 -0400 (EDT)
*Sender*: owner-wri-mathgroup at wolfram.com
Thanks to David, Bob and Paul for useful suggestions.
Rest[FoldList[#2.#1&, v, {R1, R2, R3}]] and
Rest@FoldList[Dot[#2, #1] &, v, {R1, R2, R3, R4}]
are basically equivalent and work for an arbitrary list of matrices -
thanks! Couldn't see for looking... Looks like it'll work for any function
of two variables I guess?
Paul's idea is a good one if you need to generate a symbolic set of
expressions (not right for my problem though):
Subscript[R, n_][v_] := Subscript[R, n]
Rest[ComposeList[Subscript[R,1], Subscript[R,2], Subscript[R,3]}, v]]
Hywel
> What about...
>
> Rest@FoldList[Dot[#2, #1] &, v, {R1, R2, R3, R4}]
> {R1.v, R2.R1.v, R3.R2.R1.v, R4.R3.R2.R1.v}
>
> David Park
> djmp at earthlink.net
> http://home.earthlink.net/~djmp/
>
> From: Owen, HL (Hywel) [mailto:H.L.Owen at dl.ac.uk]
To: mathgroup at smc.vnet.net
>
> Hi folks,
>
> 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.
>
> 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?
>
> Thanks,
>
> Hywel
>
>
>
Prev by Date:
**Re: Solvability sensitive to small changes in numerical input**
Next by Date:
**RE: Re: DirectMath experience**
Previous by thread:
**RE: Alternative to defining 'operator' function?**
Next by thread:
**Re: Alternative to defining 'operator' function?**
| |