comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: "ALOG2" ? (Ugly code follows)
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: "ALOG2" ? (Ugly code follows) [message #14862] Sat, 03 April 1999 00:00
luthi is currently offline  luthi
Messages: 20
Registered: March 1999
Junior Member
Amara

wouldn't it be simpler to use the transformations for the base of a logaritm
described in any mathematics text?

log2(x) = ln(x)*log2(e)

(or in idl-language: alog2(x) = alog(x)*alog2(exp(1.0)) )

then you still have to calculate log2(e) but this is 1/ln(2), so the
simplyfied code looks like

function alog2, x
return, alog(x)/alog(2.0)
end ;{alog2}

(of course this works for any base)

hope this helps!

Martin

--
============================================================
Martin Luethi Tel. +41 1 632 40 92
Glaciology Section Fax. +41 1 632 11 92
VAW ETH Zuerich
CH-8092 Zuerich mail luthi@vaw.baum.ethz.ch
Switzerland
============================================================
Re: "ALOG2" ? (Ugly code follows) [message #14863 is a reply to message #14862] Sat, 03 April 1999 00:00 Go to previous message
Med Bennett is currently offline  Med Bennett
Messages: 109
Registered: April 1997
Senior Member
Hello Amara,

This seems to be a simpler problem than you have indicated:

IDL> x=[0.5,1,2,3,4,6,8,10]
IDL> print,alog(x)/alog(2)
-1.00000 0.000000 1.00000 1.58496 2.00000
2.58496 3.00000 3.32193

i.e., log base 2 of a number is just the natural log of the number divided by the
natural log of 2. Am I missing something?
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: "ALOG2" (lame question)
Next Topic: "ALOG2" ? (Ugly code follows)

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 20:02:22 PDT 2025

Total time taken to generate the page: 0.05293 seconds