Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #15306
| From | Frank Iannarilli <frankeye@cox.net> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Quantity[] (Units) slows things! Solutions? |
| Date | 2013-08-16 07:07 +0000 |
| Message-ID | <kukj38$qt6$1@smc.vnet.net> (permalink) |
| Organization | Time-Warner Telecom |
Hi,
This is for Mathematica9 which introduced units-handling via the Quantity[] function and its friends. It's a nice provision, but can slow things down substantially for production work, e.g. below shows a factor of 6500 slowdown!
For example:
lwc[dBZ_, sigma_, n_Quantity] := (1/6) Exp[-9 sigma^2/2] Pi
Quantity[1.,"Grams"/("Centimeters"^3)]
Sqrt[n (10^(dBZ/10))
Quantity[1., ("Millimeters")^6/("Meters"^3)]]
Timing[Table[lwc[dbz, 0.35,
Quantity[200., 1/("Centimeters"^3)]],
{dbz, -100., -10., 0.1}]]
===>>65 Seconds!
whereas the unitless equivalent:
lwcn[dBZ_, sigma_, n_] := (1/6) Exp[-9 sigma^2/2] Pi
1.0 Sqrt[n (10^(dBZ/10)) ]
Timing[Table[lwcn[dbz, 0.35, 200.], {dbz, -100., -10., 0.1}]]
===>>0.01 Seconds!
Can anyone suggest any tricks other than removing the units-handling?
Back to comp.soft-sys.math.mathematica | Previous | Next — Next in thread | Find similar | Unroll thread
Quantity[] (Units) slows things! Solutions? Frank Iannarilli <frankeye@cox.net> - 2013-08-16 07:07 +0000 Re: Quantity[] (Units) slows things! Solutions? "Kevin J. McCann" <kjm@KevinMcCann.com> - 2013-08-17 06:04 +0000
csiph-web