Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #7041
| From | Ray Koopman <koopman@sfu.ca> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: Preventing unwanted threading by Inner |
| Date | 2011-12-08 10:42 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <jbq4as$iu1$1@smc.vnet.net> (permalink) |
| References | <jbni23$47f$1@smc.vnet.net> |
On Dec 7, 3:18 am, Chris Young <c...@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}
Inner[Times, {a1,a2,a3}, {b1,b2,b3}, Plus] /.
Thread[{b1,b2,b3} -> HoldForm /@ {{b11,b12},{b21,b22},{b31,b32}}]
a1 {b11,b12} + a2 {b21,b22} + a3 {b31,b32}
Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Preventing unwanted threading by Inner Chris Young <cy56@comcast.net> - 2011-12-07 11:18 +0000
Re: Preventing unwanted threading by Inner "Oleksandr Rasputinov" <oleksandr_rasputinov@hmamail.com> - 2011-12-08 10:38 +0000
Re: Preventing unwanted threading by Inner Chris Young <cy56@comcast.net> - 2011-12-10 12:44 +0000
Re: Preventing unwanted threading by Inner Ray Koopman <koopman@sfu.ca> - 2011-12-08 10:42 +0000
Re: Preventing unwanted threading by Inner Chris Young <cy56@comcast.net> - 2011-12-10 12:43 +0000
Re: Preventing unwanted threading by Inner DrMajorBob <btreat1@austin.rr.com> - 2011-12-11 08:52 +0000
Re: Preventing unwanted threading by Inner Ray Koopman <koopman@sfu.ca> - 2011-12-08 10:42 +0000
Re: Preventing unwanted threading by Inner Chris Young <cy56@comcast.net> - 2011-12-10 12:29 +0000
Re: Preventing unwanted threading by Inner DrMajorBob <btreat1@austin.rr.com> - 2011-12-09 10:58 +0000
Re: Preventing unwanted threading by Inner Vince Virgilio <blueschi@gmail.com> - 2011-12-10 12:30 +0000
csiph-web