Re: Why overloaded arithmetic operations are so slow?

• To: mathgroup at smc.vnet.net
• Subject: [mg49760] Re: [mg49729] Why overloaded arithmetic operations are so slow?
• From: János <janos.lobb at yale.edu>
• Date: Fri, 30 Jul 2004 06:02:12 -0400 (EDT)
• References: <200407291145.HAA10328@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Give a try to:

zz /: Plus[z1_zz, z2_zz] :=  zz /: Plus[z1, z2] = zz[First[z1] +
First[z2]]

Mathematica Book 2.5.9

On my machine it gives:
In[10]:=
Do[Print[Timing[Plus @@ Table[zz[10^(i - 1)], {i, n}]]], {n, 15}]

From In[10]:=
{0. Second,zz[1]}

From In[10]:=
{0. Second,zz[11]}

From In[10]:=
{0. Second,zz[111]}

From In[10]:=
{0. Second,zz[1111]}

From In[10]:=
{0. Second,zz[11111]}

From In[10]:=
{0. Second,zz[111111]}

From In[10]:=
{0. Second,zz[1111111]}

From In[10]:=
{0. Second,zz[11111111]}

From In[10]:=
{0. Second,zz[111111111]}

From In[10]:=
{0. Second,zz[1111111111]}

From In[10]:=
{0. Second,zz[11111111111]}

From In[10]:=
{0. Second,zz[111111111111]}

From In[10]:=
{0. Second,zz[1111111111111]}

From In[10]:=
{0. Second,zz[11111111111111]}

From In[10]:=
{0. Second,zz[111111111111111]}

/Oh !  I discovered something I always wanted to know but could never
figure it out and was too shy to ask.   How to put in mail the In[] and
Out[] text.  Well, well those bracket selections are very handy :) /

János
On Jul 29, 2004, at 7:45 AM, Sergey Afonin wrote:

> Do[Print[Timing[Plus @@ Table[zz[10^(i - 1)], {i, n}]]], {n, 15}]
-------------------------------------------------
clear perl code is better than unclear awk code; but NOTHING comes
close to unclear perl code
http://www.faqs.org/faqs/computer-lang/awk/faq/

```

• Prev by Date: Re: ListDensityPlot, ColorFunction, and associated confusions
• Next by Date: Re: ListDensityPlot, ColorFunction, and associated confusions