Re: Re: Variant of inner Product ...

• To: mathgroup at smc.vnet.net
• Subject: [mg56807] Re: [mg56747] Re: [mg56683] Variant of inner Product ...
• From: Chris Chiasson <chris.chiasson at gmail.com>
• Date: Fri, 6 May 2005 03:00:44 -0400 (EDT)
• References: <200505051001.GAA21941@smc.vnet.net>
• Reply-to: Chris Chiasson <chris.chiasson at gmail.com>
• Sender: owner-wri-mathgroup at wolfram.com

```Just realized I read your question incorrectly... once I understood; I
realized that my solution puts you back at square one... Hartmut
Wolf's solution seems to do the trick though

On 5/5/05, Wolf, Hartmut <Hartmut.Wolf at t-systems.com> wrote:
>
> >-----Original Message-----
> >From: =?ISO-8859-1?Q?Detlef_M=FCller?= at smc.vnet.net
To: mathgroup at smc.vnet.net
> >[mailto:=?ISO-8859-1?Q?Detlef_M=FCller?= at smc.vnet.net]
> >Sent: Wednesday, May 04, 2005 6:33 AM
> >Subject: [mg56807] [mg56747] [mg56683] Variant of inner Product ...
> >
> >Hello,
> >
> >I have the following to do:
> >
> >Given
> >
> >In[1]:= A={1,2,3}; B={{a,b},{c,d},{r,s}};
> >
> >And a Function f, I like to have
> >
> >Out[2] = {f[1,a],f[1,b]}+{f[2,c],f[2,d]}+{f[3,r],f[3,s]}
> >
> >The trial
> >
> >In[8]:=A={1,2,3}; B={{a,b},{c,d,e},{r,s}};
> >In[9]:= Inner[f,A,B]
> >Out[9]= f[1,{a,b}]+f[2,{c,d,e}]+f[3,{r,s}]
> >
> >looks promising,
> >but if the Lists in B have the same length, "Inner"
> >makes something different:
> >
> >In[15]:=
> >A={1,2,3}; B={{a,b},{c,d},{r,s}}; Inner[f,A,B]
> >
> >Out[16]= {f[1,a]+f[2,c]+f[3,r],f[1,b]+f[2,d]+f[3,s]}
> >
> >So for now I have an ugly Table-Construction doing the job,
> >but I can't imagine there is no elegant and clear solution
> >for this ... any suggestions?
> >
> >Greetings,
> >   Detlef
> >
> >
>
> Detlef,
>
> your desired expression will be reduced further, because Plus ist Listable. Such I'll show it with CirclePlus:
>
> Observe:
>
> In[38]:= Inner[f, A, B, g]
> Out[38]=
> {g[f[1, a], f[2, c], f[3, r]], g[f[1, b], f[2, d], f[3, s]]}
>
> Such just use the right stuff for g:
>
> In[39]:= CirclePlus @@ Transpose@Inner[f, A, B, List]
> Out[39]=
> {f[1, a], f[1, b]}\[CirclePlus]{f[2, c], f[2, d]}\[CirclePlus]{f[3, r],
>     f[3, s]}
>
> Perhaps this appears simpler (?):
>
> In[40]:= Thread[f[A, B]]
> Out[40]= {f[1, {a, b}], f[2, {c, d}], f[3, {r, s}]}
>
> In[41]:= CirclePlus @@ Thread /@ Thread[f[A, B]]
> Out[41]=
> {f[1, a], f[1, b]}\[CirclePlus]{f[2, c], f[2, d]}\[CirclePlus]{f[3, r],
>     f[3, s]}
>
> --
> Hartmut Wolf
>
>

--
Chris Chiasson
http://chrischiasson.com/
1 (810) 265-3161

```

• Prev by Date: Re: Plot axis numbers
• Next by Date: Re: Re: Re: debugging
• Previous by thread: Re: Variant of inner Product ...
• Next by thread: Re: Variant of inner Product ...