Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #7043

Re: Preventing unwanted threading by Inner

From Bob Hanlon <hanlonr357@gmail.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Preventing unwanted threading by Inner
Date 2011-12-08 10:43 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <jbq4cr$iug$1@smc.vnet.net> (permalink)
References <201112071113.GAA04136@smc.vnet.net>

Show all headers | View raw


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@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}
>

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: Preventing unwanted threading by Inner Bob Hanlon <hanlonr357@gmail.com> - 2011-12-08 10:43 +0000

csiph-web