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: [mg123486] Re: Preventing unwanted threading by Inner
  • From: Ray Koopman <koopman at sfu.ca>
  • Date: Thu, 8 Dec 2011 05:28:39 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <jbni23$47f$1@smc.vnet.net>

On Dec 7, 3:18 am, Chris Young <c... at comcast.net> wrote:
> I'm trying to prevent Inner from expanding my points into coordinates:
>
> In[283]:= Inner[Times, {a, b, c}, {{A, =CE=B1}, {B, =CE=B2}, {C, =CF=87}}, Plus]
> Out[283]= {a A + b B + c C, a =CE=B1 + b =CE=B2 + c =CF=87}
>
> 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, =CE=B1}, {B, =CE=B2}, {C, =CF=87}}, Plus];
> SetAttributes[Times, Listable];
> Protect[Times];
>
> In[315]:= myInnnerProd
>
> Out[315]= {a A + b B + c C, a =CE=B1 + b =CE=B2 + c =CF=87}
>
> 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, =CE=B1}, {B, =CE=B2}, {C, =CF=87}}, Plus];
> myInnnerProd = ReleaseHold[myInnerProd]
> SetAttributes[Times, Listable];
> Protect[Times];
>
> Out[346]= a {A, =CE=B1} + b {B, =CE=B2} + c {C, =CF=87}

This is a little better than my first suggestion.

Inner[Times, {a1,a2,a3}, HoldForm /@
{{b11,b12},{b21,b22},{b31,b32}}, Plus]

a1 {b11,b12} + a2 {b21,b22} + a3 {b31,b32}



  • Prev by Date: Re: Preventing unwanted threading by Inner
  • Next by Date: Re: Complex diagram
  • Previous by thread: Re: Preventing unwanted threading by Inner
  • Next by thread: Re: Preventing unwanted threading by Inner