Re: "ALOG2" ? (Ugly code follows) [message #14862] |
Sat, 03 April 1999 00:00 |
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  |
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?
|
|
|