Folks,
Having spent some considerable effort in sorting out the floating point
code in the I370 port pf GCC, I would now like a floating point library to
go with it. From what I have seen most implementations use "Computer
Approximations" by "P Hart" (hope I got that right) for all the constants.
Unfortunately my local library can't get me a copy. The IEE library in
London does not seem to have a copy. Any other suggestions on a good place
to start? I have looked at the FAQ but that only seems to have extensions.
Any thoughts on a good way to proceed,,,
Dave Wade 18 1640
David Wade wrote: Folks,
Having spent some considerable effort in sorting out the floating point code in the I370 port pf GCC, I would now like a floating point library to go with it. From what I have seen most implementations use "Computer Approximations" by "P Hart" (hope I got that right) for all the constants. Unfortunately my local library can't get me a copy. The IEE library in London does not seem to have a copy. Any other suggestions on a good place to start? I have looked at the FAQ but that only seems to have extensions. Any thoughts on a good way to proceed,,,
I suggest you look for our very own P.J.Plauger's book:
P.J. Plauger, The Standard C Library, Prentice Hall, 1992, ISBN
0-13-131509-9
It was actually listed in the Bibliography of the FAQ at http://c-faq.com/sx2/index.html
You might find some of the other references useful.
You might also find having a copy of the C standard to hand useful,
information on where you can get the various versions can be found here http://clc-wiki.net/wiki/Basics_Of_The_C_Standard
--
Flash Gordon
Living in interesting times.
Web site - http://home.flash-gordon.me.uk/
comp.lang.c posting guidlines and intro - http://clc-wiki.net/wiki/Intro_to_clc
"David Wade" writes: Having spent some considerable effort in sorting out the floating point code in the I370 port pf GCC, I would now like a floating point library to go with it. From what I have seen most implementations use "Computer Approximations" by "P Hart" (hope I got that right) for all the constants. Unfortunately my local library can't get me a copy. The IEE library in London does not seem to have a copy. Any other suggestions on a good place to start? I have looked at the FAQ but that only seems to have extensions. Any thoughts on a good way to proceed,,,
No, it's John Hart. Lucky me (I guess), I have a copy. I think AMS55 would
be a decent place to start. It's title is _Handbook of Mathematic
Functions_ and it's hard to imagine a decent technical library that doesn't
have a copy. It's published by the US Dept of Commerce. The book I usually
see referenced is _Numerical Approximations_ (from memory) by Hastings,
which I don't have. Ideally, P.J.Plauger is your best source (after all,
he is up on the current state of the art) and he visits here. But I could
understand if he didn't want to mentor you.
David Wade wrote: I suggest you look for our very own P.J.Plauger's book: P.J. Plauger, The Standard C Library, Prentice Hall, 1992, ISBN 0-13-131509-9
It was actually listed in the Bibliography of the FAQ at http://c-faq.com/sx2/index.html
You might find some of the other references useful.
You might also find having a copy of the C standard to hand useful, information on where you can get the various versions can be found here http://clc-wiki.net/wiki/Basics_Of_The_C_Standard --
Both these tell you about using the library, not about implementing it....
Wrong. To quote from Amazon http://www.amazon.com/gp/product/013...ebsdprimeiropA
about PJP's book:
| Book Description
| Prentice Hall's most important C programming title in years. A
| companion volume to Kernighan & Ritchie's C PROGRAMMING LANGUAGE. A
| collection of reusable functions (code for building data structures,
| code for performing math functions and scientific calculations, etc.)
| which will save C programmers time and money especially when working
| on large programming projects. The C Library is part of the ANSI
| (American National Standard Institute) for the C Language. This new
| book contains the complete code for the library...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
It is also very useful to have the definition of what you are trying to
implement, hence my suggestion of the standard. Flash Gordon Living in interesting times. Web site - http://home.flash-gordon.me.uk/ comp.lang.c posting guidlines and intro - http://clc-wiki.net/wiki/Intro_to_clc
Please snip peoples sigs unless you are commenting on them.
--
Flash Gordon
Living in interesting times.
Web site - http://home.flash-gordon.me.uk/
comp.lang.c posting guidlines and intro - http://clc-wiki.net/wiki/Intro_to_clc
On 2006-02-15, David Wade <g8***@yahoo.com> wrote: Folks,
Having spent some considerable effort in sorting out the floating point code in the I370 port pf GCC, I would now like a floating point library to go with it. From what I have seen most implementations use "Computer Approximations" by "P Hart" (hope I got that right) for all the constants. Unfortunately my local library can't get me a copy. The IEE library in London does not seem to have a copy. Any other suggestions on a good place to start? I have looked at the FAQ but that only seems to have extensions. Any thoughts on a good way to proceed,,,
Dave Wade
There is an open-source (BSD-ish, but with less license verbage) math
library [including all functions declared in math.h] that originated
with SunPro - It does require [as far as I can tell] IEEE floating
point, and the compiler has to handle primitives such as division,
multiplication, and so on.
No idea where to find it, except for of course my own system's
/usr/src/lib/msun/src
Or there's always glibc.
"Jordan Abel" <ra*******@gmail.com> wrote in message
news:sl**********************@random.yi.org... On 2006-02-15, David Wade <g8***@yahoo.com> wrote: Folks,
Having spent some considerable effort in sorting out the floating point code in the I370 port pf GCC, I would now like a floating point library
to go with it. From what I have seen most implementations use "Computer Approximations" by "P Hart" (hope I got that right) for all the
constants. Unfortunately my local library can't get me a copy. The IEE library in London does not seem to have a copy. Any other suggestions on a good
place to start? I have looked at the FAQ but that only seems to have
extensions. Any thoughts on a good way to proceed,,,
Dave Wade There is an open-source (BSD-ish, but with less license verbage) math library [including all functions declared in math.h] that originated with SunPro - It does require [as far as I can tell] IEEE floating point, and the compiler has to handle primitives such as division, multiplication, and so on.
Thats a major problem as I370 does not have IEEE float....
No idea where to find it, except for of course my own system's /usr/src/lib/msun/src
Or there's always glibc.
"Flash Gordon" <sp**@flash-gordon.me.uk> wrote in message
news:3o************@news.flash-gordon.me.uk... David Wade wrote: I suggest you look for our very own P.J.Plauger's book: P.J. Plauger, The Standard C Library, Prentice Hall, 1992, ISBN 0-13-131509-9
It was actually listed in the Bibliography of the FAQ at http://c-faq.com/sx2/index.html
You might find some of the other references useful.
You might also find having a copy of the C standard to hand useful, information on where you can get the various versions can be found here http://clc-wiki.net/wiki/Basics_Of_The_C_Standard -- Both these tell you about using the library, not about implementing
it.... Wrong. To quote from Amazon http://www.amazon.com/gp/product/013...ebsdprimeiropA about PJP's book: | Book Description | Prentice Hall's most important C programming title in years. A | companion volume to Kernighan & Ritchie's C PROGRAMMING LANGUAGE. A | collection of reusable functions (code for building data structures, | code for performing math functions and scientific calculations, etc.) | which will save C programmers time and money especially when working | on large programming projects. The C Library is part of the ANSI | (American National Standard Institute) for the C Language. This new | book contains the complete code for the library... ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Arghhhh! How did I miss that. I can't even say that the description in
amazon.co.uk is different.
That looks a really usefull starting point... It is also very useful to have the definition of what you are trying to implement, hence my suggestion of the standard.
I agree, but the standard is pretty brief on the maths functions. Most only
warrent a one liner. However at it does have the range values that are
valid... Flash Gordon
Thanks,
Dave
>"osmium" <r1********@comcast.net> wrote in message
news:45************@individual.net... "David Wade" writes:
Having spent some considerable effort in sorting out the floating point code in the I370 port pf GCC, I would now like a floating point library
to go with it. From what I have seen most implementations use "Computer Approximations" by "P Hart" (hope I got that right) for all the
constants. Unfortunately my local library can't get me a copy. The IEE library in London does not seem to have a copy. Any other suggestions on a good
place to start? I have looked at the FAQ but that only seems to have
extensions. Any thoughts on a good way to proceed,,, No, it's John Hart. Lucky me (I guess), I have a copy. I think AMS55
would be a decent place to start. It's title is _Handbook of Mathematic Functions_ and it's hard to imagine a decent technical library that
doesn't have a copy. It's published by the US Dept of Commerce.
Oddly I can't see this in the IEE library...
The book I usually see referenced is _Numerical Approximations_ (from memory) by Hastings,
Do you mean "Approximations for digital computers" That is in the IEE
library...
which I don't have. Ideally, P.J.Plauger is your best source (after all, he is up on the current state of the art) and he visits here. But I could understand if he didn't want to mentor you.
Any way some stuff to go on here....
"David Wade" wrote: I think AMS55 would be a decent place to start. It's title is _Handbook of Mathematic Functions_ and it's hard to imagine a decent technical library that doesn't have a copy. It's published by the US Dept of Commerce.
Oddly I can't see this in the IEE library...
It's on the net, too. http://www.convertit.com/Go/ConvertI...ence/AMS55.ASP
Typing a number into <page> works. It's a scanned copy. The book I usually see referenced is _Numerical Approximations_ (from memory) by Hastings,
Do you mean "Approximations for digital computers" That is in the IEE library...
Yes, that's the one.
> It's on the net, too.
http://www.convertit.com/Go/ConvertI...ence/AMS55.ASP
Typing a number into <page> works. It's a scanned copy.
That looks more usefull. Thanks for that... The book I usually see referenced is _Numerical Approximations_ (from memory) by Hastings,
Do you mean "Approximations for digital computers" That is in the IEE library...
Yes, that's the one.
Rod Pemberton wrote: "David Wade" <g8***@yahoo.com> wrote in message news:T4******************************@eclipse.net. uk... Folks,
Having spent some considerable effort in sorting out the floating point code in the I370 port pf GCC, I would now like a floating point library to go with it. From what I have seen most implementations use "Computer Approximations" by "P Hart" (hope I got that right) for all the constants. Unfortunately my local library can't get me a copy. The IEE library in London does not seem to have a copy. Any other suggestions on a good place to start? I have looked at the FAQ but that only seems to have extensions. Any thoughts on a good way to proceed,,,
Dave Wade
Have you looked at Sun Microsystems freely distributable math library, fdlibm?
You could also use the math library SLATEC. You'll need to convert them from Fortran to C using F2C.
Rod Pemberton
Netlib's main pages: http://netlib.bell-labs.com/netlib/master/readme.html http://netlib.bell-labs.com/netlib/master/index.html
Direct links to fdlibm,f2c,slatec: http://netlib.bell-labs.com/netlib/fdlibm/index.html http://netlib.bell-labs.com/netlib/f2c/index.html http://netlib.bell-labs.com/netlib/slatec/index.html
They might also be available here: http://www.netlib.org/slatec http://www.netlib.org/fdlibm http://www.netlib.org/f2c
Rod,
The only problem with fdlibm is that some funcions (especially the LOG
functions) only work properley with binary float, whereas IBM float is
Hex floating point. (that is the exponent is a power of 16, not of
two). This means that code that multiplys or divides by two by
manipulating the exponent directly does not work. I guess its fixable
though, and the code does have pretty good explainations of what is
happening, and good examples of suitable constants for use in the
polynomial approximations, which are too a greater accuracy than those
in AMS55.
Dave.
P.S. SALTEC appears to assume you already have basic trig :-(
Dave wrote: The only problem with fdlibm is that some funcions (especially the LOG functions) only work properley with binary float, whereas IBM float is Hex floating point. (that is the exponent is a power of 16, not of two). This means that code that multiplys or divides by two by manipulating the exponent directly does not work. I guess its fixable though, and the code does have pretty good explainations of what is happening, and good examples of suitable constants for use in the polynomial approximations, which are too a greater accuracy than those in AMS55.
Sometimes I write math functions, when I have nothing else to do.
/* BEGIN constants.c output */
sq_rt(2) is 1.414214
l_og(2) is 0.693147
e_xp(1) is 2.718282
pi is 3.141593
sq_rt(2) * sq_rt(2) - 2.0 is -4.440892e-016
sqrt(2) * sqrt(2) - 2.0 is 4.440892e-016
pow(e_xp(1), l_og(2)) - 2.0 is -2.220446e-016
pow(exp(1), log(2)) - 2.0 is -2.220446e-016
3.141592653589793238462643383279502884197169399375 1 - fs_pi()
is 0.000000e+000
/* END constants.c output */
/* BEGIN constants.c */
#include <stdio.h>
#include <float.h>
#include <errno.h>
#include <math.h>
double sq_rt(double x);
double l_og(double x);
double e_xp(double x);
double fs_pi(void);
int main(void)
{
puts("\n/* BEGIN constants.c output */\n");
printf("sq_rt(2) is %f\n", sq_rt(2));
printf(" l_og(2) is %f\n", l_og(2));
printf(" e_xp(1) is %f\n", e_xp(1));
printf(" pi is %f\n\n", fs_pi( ));
printf("sq_rt(2) * sq_rt(2) - 2.0 is %e\n",
sq_rt(2) * sq_rt(2) - 2.0);
printf(" sqrt(2) * sqrt(2) - 2.0 is %e\n\n",
sqrt(2) * sqrt(2) - 2.0);
printf("pow(e_xp(1), l_og(2)) - 2.0 is %e\n",
pow(e_xp(1), l_og(2)) - 2.0);
printf(" pow(exp(1), log(2)) - 2.0 is %e\n\n",
pow(exp(1), log(2)) - 2.0);
printf("3.1415926535897932384626433832795028841971 693993751"
" - fs_pi()\nis %e\n",
3.141592653589793238462643383279502884197169399375 1
- fs_pi());
puts("\n/* END constants.c output */");
return 0;
}
double sq_rt(double x)
{
int n;
double a, b;
if (DBL_MAX >= x && x > 0) {
for (n = 0; x > 2; x /= 4) {
++n;
}
while (0.5 > x) {
--n;
x *= 4;
}
a = x;
b = (1 + x) / 2;
do {
x = b;
b = (a / x + x) / 2;
} while (x > b);
while (n > 0) {
x *= 2;
--n;
}
while (0 > n) {
x /= 2;
++n;
}
} else {
if (x != 0) {
errno = EDOM;
x = HUGE_VAL;
}
}
return x;
}
double l_og(double x)
{
int n;
double a, b, c, epsilon;
static double A, B, C;
if (DBL_MAX >= x && x > 0) {
if (1 > A) {
A = sq_rt(2);
B = A / 2;
C = l_og(A);
}
for (n = 0; x > A; x /= 2) {
++n;
}
while (B > x) {
--n;
x *= 2;
}
a = (x - 1) / (x + 1);
x = C * n + a;
c = a * a;
n = 1;
epsilon = DBL_EPSILON * x;
if (0 > a) {
if (epsilon > 0) {
epsilon = -epsilon;
}
do {
n += 2;
a *= c;
b = a / n;
x += b;
} while (epsilon > b);
} else {
if (0 > epsilon) {
epsilon = -epsilon;
}
do {
n += 2;
a *= c;
b = a / n;
x += b;
} while (b > epsilon);
}
x *= 2;
} else {
errno = x != 0 ? EDOM : ERANGE;
x = -HUGE_VAL;
}
return x;
}
double e_xp(double x)
{
unsigned n, square;
double b, e;
static double x_max;
if (1 > x_max) {
x_max = l_og(DBL_MAX);
}
if (x_max >= x && x >= -x_max) {
for (square = 0; x > 1; x /= 2) {
++square;
}
while (-1 > x) {
++square;
x /= 2;
}
e = b = n = 1;
do {
b /= n++;
b *= x;
e += b;
b /= n++;
b *= x;
e += b;
} while (b > DBL_EPSILON / 4);
while (square-- != 0) {
e *= e;
}
} else {
errno = x > DBL_MAX || -DBL_MAX > x ? EDOM : ERANGE;
e = 0 > x ? 0 : HUGE_VAL;
}
return e;
}
double fs_pi(void)
{
unsigned n;
double p, a, b;
p = 0;
n = 1;
a = 3;
do {
a /= 9;
b = a / n;
n += 2;
a /= 9;
b -= a / n;
n += 2;
p += b;
} while (b > DBL_EPSILON / 4);
n = 1;
a = 2;
do {
a /= 4;
b = a / n;
n += 2;
a /= 4;
b -= a / n;
n += 2;
p += b;
} while (b > DBL_EPSILON / 2);
return 4 * p;
}
/* END constants.c */
--
pete
"pete" <pf*****@mindspring.com> wrote in message
news:43***********@mindspring.com... Dave wrote:
The only problem with fdlibm is that some funcions (especially the LOG functions) only work properley with binary float, whereas IBM float is Hex floating point. (that is the exponent is a power of 16, not of two). This means that code that multiplys or divides by two by manipulating the exponent directly does not work. I guess its fixable though, and the code does have pretty good explainations of what is happening, and good examples of suitable constants for use in the polynomial approximations, which are too a greater accuracy than those in AMS55.
Sometimes I write math functions, when I have nothing else to do.
<snip>
Pete,
Those functions are nice. Martin Baute has said he could use some help
with math functions. He's writing a Public Domain C library hosted on
Sourceforge: http://sourceforge.net/projects/pdclib/
Rod Pemberton
Rod Pemberton wrote: "pete" <pf*****@mindspring.com> wrote in message news:43***********@mindspring.com... Dave wrote:
The only problem with fdlibm is that some funcions (especially the LOG functions) only work properley with binary float, whereas IBM float is Hex floating point. (that is the exponent is a power of 16, not of two). This means that code that multiplys or divides by two by manipulating the exponent directly does not work. I guess its fixable though, and the code does have pretty good explainations of what is happening, and good examples of suitable constants for use in the polynomial approximations, which are too a greater accuracy than those in AMS55. Sometimes I write math functions, when I have nothing else to do. <snip>
Pete,
Those functions are nice.
I'm glad you like them.
Most of them are just transcriptions of some Taylor
and Maclaurin series from my math book.
Martin Baute has said he could use some help with math functions. He's writing a Public Domain C library hosted on Sourceforge:
http://sourceforge.net/projects/pdclib/
I just downloaded their standard library.
I'll take a look at it.
--
pete
"Rod Pemberton" <do*********@sorry.bitbucket.cmm> wrote in message
news:dt**********@news1.greatnowhere.com... "pete" <pf*****@mindspring.com> wrote in message news:43***********@mindspring.com... Dave wrote:
The only problem with fdlibm is that some funcions (especially the
LOG functions) only work properley with binary float, whereas IBM float is Hex floating point. (that is the exponent is a power of 16, not of two). This means that code that multiplys or divides by two by manipulating the exponent directly does not work. I guess its fixable though, and the code does have pretty good explainations of what is happening, and good examples of suitable constants for use in the polynomial approximations, which are too a greater accuracy than those in AMS55. Sometimes I write math functions, when I have nothing else to do. <snip>
Pete,
Those functions are nice. Martin Baute has said he could use some help with math functions. He's writing a Public Domain C library hosted on Sourceforge:
They will work, but they are a bit on the slow side when running on an
emulated mainframe...
I have been using the library from http://sourceforge.net/projects/pdos
Which again is missing any maths... http://sourceforge.net/projects/pdclib/
Rod Pemberton
David Wade wrote: "Rod Pemberton" <do*********@sorry.bitbucket.cmm> wrote in message news:dt**********@news1.greatnowhere.com... "pete" <pf*****@mindspring.com> wrote in message news:43***********@mindspring.com...
Sometimes I write math functions, when I have nothing else to do. <snip>
Pete,
Those functions are nice. Martin Baute has said he could use some help with math functions. He's writing a Public Domain C library hosted on Sourceforge:
They will work, but they are a bit on the slow side when running on an emulated mainframe...
I'm not quite sure why I wrote them.
But if you remove all the statements with errno,
and change all the instances of HUGE_VAL to DBL_MAX,
then you have portable freestanding code.
--
pete
In article <11**********************@g14g2000cwa.googlegroups .com> "Dave" <g8***@yahoo.com> writes:
.... The only problem with fdlibm is that some funcions (especially the LOG functions) only work properley with binary float, whereas IBM float is Hex floating point. (that is the exponent is a power of 16, not of two).
You should look at W.J. Cody and W. Waite. It goes in full detail over
the implementation of the elementary functions, and it is not binary
biased. (Although I do not like their implementation of some of the
functions.)
They also give programs (in Fortran) that test the functions.
--
dik t. winter, cwi, kruislaan 413, 1098 sj amsterdam, nederland, +31205924131
home: bovenover 215, 1025 jn amsterdam, nederland; http://www.cwi.nl/~dik/ This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: planetthoughtful |
last post by:
Hi All,
As always, my posts come with a 'Warning: Newbie lies ahead!'
disclaimer...
I'm wondering if it's possible, using raw_input(), to provide a
'default' value with the prompt?
I would...
|
by: Lee |
last post by:
Once the business logic has been written and the basic elements are
built into a page, what is the recommended way to provide the site
innards to graphics design people without providing source...
|
by: Dale Strickland-Clark |
last post by:
We have a system we're developing which runs as a server. It has an xml-rpc
interface which I've extended to provide some debugging facilities. This
has already proved very useful and will continue...
|
by: mr.hong |
last post by:
Hi,
I am using freeBSD.
I know std:set can be used in C++ for set colleciton .
If I use only C for developing some applicaiton on freeBSD, is there
any unix extension to standard C...
|
by: Adam Atlas |
last post by:
Does anyone know if it would be possible to create a CPython extension
-- or use the ctypes module -- to access Python's own embedding API
(http://docs.python.org/api/initialization.html &c.)?...
| |
by: BLUE |
last post by:
I want to pass chunks of an xml file or an entire xml file to my WS.
I'm surprised to see fro MSDN that no System.Xml class is serializable
(XmlDocument, XmlElement and XmlNode):
- I should use a...
|
by: Alexander Dong Back Kim |
last post by:
Hi all,
I'm looking for a library that provides a threadpool. I know
"threadpool" from boost. Is there any other library?
Cheers,
Alex
|
by: watches0898 |
last post by:
Edwards Garments Company is one popular industry specific designer
specializing in work wear that ranges from chef coats to chef hats to
separates to housecleaning uniforms. Edwards Garments...
|
by: Peter Olcott |
last post by:
So far the only way that I found to do this was by making a
single global instance of the container class and providing
access to the contained class, through this single global
instance. Are...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |