Re: Inner product can be modified?

*To*: mathgroup at smc.vnet.net*Subject*: [mg21473] Re: Inner product can be modified?*From*: "Allan Hayes" <hay at haystack.demon.co.uk>*Date*: Tue, 11 Jan 2000 04:17:52 -0500 (EST)*References*: <85cmmt$lgk@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

Denis, General point: Mathematica has a programming language that is not tied to Mathematics - if you can use the generality to get what you need efficiently then use it. I have certainly made use of Inner to generalize Dot, but I can't trace this at the moment. However, consider finding the volume of a hypercube in n-space with edges parallel to the axes and with the ends ot the principle diagonal given by v1 and v2: v1 = {a, b, c}; v2 = {A, B, C}; Inner[Subtract, v1, v2, Times] (a - A) (b - B) (c - C) Times @@ (v1 - v2) (a - A) (b - B) (c - C) The "Inner " form looks cumbersome, but it is faster, certainly for higher dimensions v1 = Table[Random, {100}]; v2 = Table[Random, {100}]; Do[Inner[Subtract, v1, v2, Times], {100}] // Timing {0.38 Second, Null} Do[Times @@ (v1 - v2), {100}] // Timing {1.15 Second, Null} Allan --------------------- Allan Hayes Mathematica Training and Consulting Leicester UK www.haystack.demon.co.uk hay at haystack.demon.co.uk Voice: +44 (0)116 271 4198 Fax: +44 (0)870 164 0565 "Denis Cousineau" <decousin at indiana.edu> wrote in message news:85cmmt$lgk at smc.vnet.net... > Hi, > > I've seen in the documentation that the command > Inner[] > can be modified so that it is not necessarily the > sum (Plus) that is executed on the elements. > > Is is done frequently in mathematics? I discover that > I needed to do that in my own application, but though > I was doing a crazy thing, so if other did, I would > like to know. > > What kind of application requires a different aggregate > operation than Plus? > Is is well-known? > Do you have an easy-to-access reference where this > is done? > > Thank you for your help. > Denis > > P.S. mail and post reply appreciated. > -- > > Denis Cousineau, Postdoc ***************************** > Cognitive psychology * * > Indiana University * Etudiant devant l'eternel * > Psychology Building * * > Bloomington, 47405 ***************************** > > Office: (812) 856-5217 Fax: (812) 855-1086 > E-mail: decousin at indiana.edu http://Prelude.PSY.UMontreal.CA/~cousined >