POV-Ray : Newsgroups : povray.general : source code pow function : Re: source code pow function Server Time
3 Jul 2024 04:20:12 EDT (-0400)
  Re: source code pow function  
From: Le Forgeron
Date: 8 Aug 2015 09:42:08
Message: <55c60730$1@news.povray.org>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Le 08/08/2015 07:48, Anthony D. Baye a écrit :
> Does the source actually use the default power function from the
> cmath library?
> 

Where ? in the SDL or function in the SDL, or internally ?

In the SDL, yes, it's mapped to whatever the math library provide for
pow().

In function, yes too.

Internally, oh yes!


> It seems to me that I heard the default algorithm was actually
> somewhat inefficient.
> 

All that is rumour so far. You vaguely heard that it would be vaguely ..
.

If you are referring to something like

http://stackoverflow.com/questions/9652549/self-made-pow-c

(second answer, with POW(a,b) = EXP(LOG(a)*b) ) it's a trick that
works only :
1. on float of 32 bits
2. with Ieee-757 representation normalised value

(Remember that such float only provide 6 to 7 significant digits)

That's a non-portable optimisation which does not even handle corner
situation (when the number is denormalized due to the encoded value,
or NaN... ).

BTW, the OP of LOG also assumed that int type is at least 32 bits...
oh the hard delusion on some architectures (this year (2015), I still
have to handle a modern chip (or rather SoC) with int of 16 bits: its
natural size (it can do 64 bits, but it costs more))


> Please correct me if I'm wrong.
> 
> Regards, A.D.B.
> 
> 

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iJwEAQEIAAYFAlXGBy8ACgkQhKAm8mTpkW1XFgP+KZ/ASzfUBzPXFw0gHoXKBixQ
RoSLXuvheJsJRQpTaqi3d5mijMsn32ARnwTIvtyUPy/ehJKQXgdcLOIYNSKcDDgO
E5SwKnJnqAgxuWsWJCz4kKG2TjAkiFtEhuj8DRK5YaUFhIW8lxJyncToJZgjCcMK
6hohRLifjF0NAachrwg=
=mdFT
-----END PGP SIGNATURE-----


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.