logarthim
Hatem Bahig
hatem@comp.metro-u.ac.jp
Wed, 30 Oct 2002 12:50:40 +0900
This is a multi-part message in MIME format.
------=_NextPart_000_001A_01C28012.F35696A0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
MessageAgain, my question is: given an integer N (assume that N>0, since =
it is easy to calculate the log(-N) if we know log(N) ), how to =
calculate log(N) (of course log (N) is not integer). ?
As you know, in the C language, it is easy to calculate log(N), even =
there is no function that takes an integer and return the log as floate =
nu. (real nu.). This can be done by the concept "cast" and using the =
function [double log ( double ...) ].
So, if there is a log. function for floating nu. (mpf_t) and the concept =
"cast" can be used, then it is possible to calculate log for any =
integer.
Unfortunately, I tried to use this concept "cast", but I didn't sucess.=20
Is there a function to calculate log for floating nu.?
On the other hand, if some one want to calculate floor(log(N)), then =
there is another way to calculate it by mpz_get_str .
Another point the functions on type"size_t" are not clear for me, ?=20
yours,
Hatem
----- Original Message -----=20
From: Paul Leyland=20
To: Jan Sahner ; Hatem Bahig=20
Cc: gmp-discuss@swox.com=20
Sent: Monday, October 28, 2002 10:07 PM
Subject: RE: logarthim
Three answers:
1) The log is (generally) not an integer.
2) Log(0) is undefined
2) If you want floor(log(N)), for N>1, the function to use is =
mpz_sizeinbase()
The rest you can look up in the manual.
Extending the function to N<0 or N=3D1, and determining the fractional =
part is left as an exercise.
Paul
-----Original Message-----
From: Jan Sahner [mailto:jan@quaeldich.de]=20
Sent: 28 October 2002 12:22
To: Hatem Bahig
Cc: gmp-discuss@swox.com
Subject: Re: logarthim
I don't think that this is conceptually possible, as this should =
usually be an irrational number.=20
Yours,=20
Jan=20
Hatem Bahig wrote:=20
Dear all I would be thankful if some one inform me the name of =
function to calculate the logarithm (log to base 2) for any integer =
(mpz) (in GMP)? Thank you in advance.=20
------=_NextPart_000_001A_01C28012.F35696A0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Message</TITLE>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 5.50.4134.100" name=3DGENERATOR></HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Again, my question is: given an integer =
N (assume=20
that N>0, since it is easy to calculate the log(-N) if we know =
log(N) ),=20
how to calculate log(N) (of course log (N) is not integer). =
?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>As you know, in the C language, it is =
easy to=20
calculate log(N), even there is no function that takes an =
integer and=20
return the log as floate nu. (real nu.). This can be done by =
the=20
concept "cast" and using the function [double log ( double =
...)=20
].</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>So, if there is a log. function for =
floating nu.=20
(mpf_t) and the concept "cast" can be used, then it is possible to=20
calculate log for any integer.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Unfortunately, I tried to use this =
concept=20
"cast", but I didn't sucess. </FONT></DIV><FONT face=3DArial =
size=3D2>
<DIV><FONT face=3DArial size=3D2>Is there a function to calculate log =
for floating=20
nu.?</FONT></DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>On the other hand, if some one want to calculate <FONT=20
color=3D#0000ff>floor(log(N)), </FONT><FONT color=3D#000000>then there =
is another=20
way to calculate it by mpz_get_str .</FONT></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Another point the functions=20
on type"size_t" are not clear for me, ?</FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>yours,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Hatem</FONT></DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style=3D"FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV=20
style=3D"BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: =
black"><B>From:</B>=20
<A title=3Dpleyland@microsoft.com =
href=3D"mailto:pleyland@microsoft.com">Paul=20
Leyland</A> </DIV>
<DIV style=3D"FONT: 10pt arial"><B>To:</B> <A title=3Djan@quaeldich.de =
href=3D"mailto:jan@quaeldich.de">Jan Sahner</A> ; <A=20
title=3Dhatem@comp.metro-u.ac.jp =
href=3D"mailto:hatem@comp.metro-u.ac.jp">Hatem=20
Bahig</A> </DIV>
<DIV style=3D"FONT: 10pt arial"><B>Cc:</B> <A =
title=3Dgmp-discuss@swox.com=20
href=3D"mailto:gmp-discuss@swox.com">gmp-discuss@swox.com</A> </DIV>
<DIV style=3D"FONT: 10pt arial"><B>Sent:</B> Monday, October 28, 2002 =
10:07=20
PM</DIV>
<DIV style=3D"FONT: 10pt arial"><B>Subject:</B> RE: logarthim</DIV>
<DIV><FONT face=3DArial size=3D2></FONT><FONT face=3DArial =
size=3D2></FONT><FONT=20
face=3DArial size=3D2></FONT><BR></DIV>
<DIV><SPAN class=3D075545912-28102002><FONT face=3DArial =
color=3D#0000ff=20
size=3D2>Three answers:</FONT></SPAN></DIV>
<DIV><SPAN class=3D075545912-28102002><FONT face=3DArial =
color=3D#0000ff=20
size=3D2></FONT></SPAN> </DIV>
<DIV><SPAN class=3D075545912-28102002><FONT face=3DArial =
color=3D#0000ff size=3D2>1)=20
The log is (generally) not an integer.</FONT></SPAN></DIV>
<DIV><SPAN class=3D075545912-28102002><FONT face=3DArial =
color=3D#0000ff size=3D2>2)=20
Log(0) is undefined</FONT></SPAN></DIV>
<DIV><SPAN class=3D075545912-28102002><FONT face=3DArial =
color=3D#0000ff size=3D2>2)=20
If you want floor(log(N)), for N>1, the function to use is=20
mpz_sizeinbase()</FONT></SPAN></DIV>
<DIV><SPAN class=3D075545912-28102002><FONT face=3DArial =
color=3D#0000ff=20
size=3D2></FONT></SPAN> </DIV>
<DIV><SPAN class=3D075545912-28102002><FONT face=3DArial =
color=3D#0000ff size=3D2>The=20
rest you can look up in the manual.</FONT></SPAN></DIV>
<DIV><SPAN class=3D075545912-28102002><FONT face=3DArial =
color=3D#0000ff=20
size=3D2></FONT></SPAN> </DIV>
<DIV><SPAN class=3D075545912-28102002><FONT face=3DArial =
color=3D#0000ff=20
size=3D2>Extending the function to N<0 or N=3D1, and determining =
the fractional=20
part is left as an exercise.</FONT></SPAN></DIV>
<DIV><SPAN class=3D075545912-28102002><FONT face=3DArial =
color=3D#0000ff=20
size=3D2></FONT></SPAN> </DIV>
<DIV><SPAN class=3D075545912-28102002></SPAN><SPAN=20
class=3D075545912-28102002><FONT face=3DArial color=3D#0000ff=20
size=3D2></FONT></SPAN> </DIV>
<DIV><SPAN class=3D075545912-28102002><FONT face=3DArial =
color=3D#0000ff=20
size=3D2>Paul</FONT></SPAN></DIV>
<DIV><SPAN class=3D075545912-28102002><FONT face=3DArial =
color=3D#0000ff=20
size=3D2></FONT></SPAN> </DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px =
solid; MARGIN-RIGHT: 0px">
<DIV></DIV>
<DIV class=3DOutlookMessageHeader lang=3Den-us dir=3Dltr =
align=3Dleft><FONT=20
face=3DTahoma size=3D2>-----Original Message-----<BR><B>From:</B> =
Jan Sahner=20
[mailto:jan@quaeldich.de] <BR><B>Sent:</B> 28 October 2002=20
12:22<BR><B>To:</B> Hatem Bahig<BR><B>Cc:</B> <A=20
=
href=3D"mailto:gmp-discuss@swox.com">gmp-discuss@swox.com</A><BR><B>Subje=
ct:</B>=20
Re: logarthim<BR><BR></FONT></DIV>I don't think that this is =
conceptually=20
possible, as this should usually be an irrational number. <BR>Yours, =
<BR>Jan=20
<BR>Hatem Bahig wrote:=20
<BLOCKQUOTE TYPE=3D"CITE">
<STYLE></STYLE>
<FONT face=3DArial><FONT size=3D-1>Dear =
all</FONT></FONT> <FONT=20
face=3DArial><FONT size=3D-1> I would be thankful if some one =
inform me=20
the name of function to calculate the logarithm (log to base =
2) for=20
any integer (mpz) (in GMP)?</FONT></FONT> <FONT =
face=3DArial><FONT=20
size=3D-1>Thank you in=20
advance.</FONT></FONT> </BLOCKQUOTE></BLOCKQUOTE></BLOCKQUOTE></BODY=
></HTML>
------=_NextPart_000_001A_01C28012.F35696A0--