MathGroup Archive 2011

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

Search the Archive

Re: Preventing unwanted threading by Inner

  • To: mathgroup at smc.vnet.net
  • Subject: [mg123489] Re: Preventing unwanted threading by Inner
  • From: Bob Hanlon <hanlonr357 at gmail.com>
  • Date: Thu, 8 Dec 2011 05:29:15 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <201112071113.GAA04136@smc.vnet.net>

Inner[Times, {a, b, c}, {pt1, pt2, pt3}, Plus] /.
 Thread[{pt1, pt2, pt3} -> {{A, \[Alpha]}, {B, \[Beta]}, {C, \[Chi]}}]

{a A + b B + c C, a \[Alpha] + b \[Beta] + c \[Chi]}

Dot[{a, b, c}, {pt1, pt2, pt3}] /.
 Thread[{pt1, pt2, pt3} -> {{A, \[Alpha]}, {B, \[Beta]}, {C, \[Chi]}}]

{a A + b B + c C, a \[Alpha] + b \[Beta] + c \[Chi]}


Bob Hanlon


On Wed, Dec 7, 2011 at 6:13 AM, Chris Young <cy56 at comcast.net> wrote:
> I'm trying to prevent Inner from expanding my points into coordinates:
>
> In[283]:= Inner[Times, {a, b, c}, {{A, =E1}, {B, =E2}, {C, =F7}}, Plus]
> Out[283]= {a A + b B + c C, a =E1 + b =E2 + c =F7}
>
> As I understand it, this has to do with Times being Listable:
>
> In[304]:= Attributes[Times]
> Out[304]= {Flat, Listable, NumericFunction, OneIdentity, Orderless, Protected}
>
> But clearing the listable attribute doesn't do anything:
>
> Unprotect[Times];
> ClearAttributes[Times, Listable];
> myInnnerProd = Inner[Times, {a, b, c}, {{A, =E1}, {B, =E2}, {C, =F7}}, Plus];
> SetAttributes[Times, Listable];
> Protect[Times];
>
> In[315]:= myInnnerProd
>
> Out[315]= {a A + b B + c C, a =E1 + b =E2 + c =F7}
>
> In addition, I have to resort to using Hold on the points. Not sure
> why; I would have thought that making Times non-listable would have
> been enough.
>
> In[343]:=
> Unprotect[Times];
> ClearAttributes[Times, Listable];
> myInnerProd =
>  Inner[Times, {a, b, c}, Hold /@ {{A, =E1}, {B, =E2}, {C, =F7}}, Plus];
> myInnnerProd = ReleaseHold[myInnerProd]
> SetAttributes[Times, Listable];
> Protect[Times];
>
>
> Out[346]= a {A, =E1} + b {B, =E2} + c {C, =F7}
>



  • Prev by Date: Re: Complex diagram
  • Next by Date: Re: Study of a real function
  • Previous by thread: Re: Preventing unwanted threading by Inner
  • Next by thread: Re: Preventing unwanted threading by Inner