Discussion:
problems with GPC/Mac OS X
Boris Herman
2003-05-22 08:10:51 UTC
Permalink
Hello

I have DLed the newest version listed and the Dec2002 Developer Tools
from Apple and have proceeded to work on a more complex project.
alan.pas:577: internal error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://www.gnu-pascal.de/todo.html> for instructions.
Any ideas?

If anyone cares to look into it I have attached the source, the
preprocessed source and the data file needed to run it.

Regards,
Boris
-------------- next part --------------
A non-text attachment was scrubbed...
Name: alan.zip
Type: application/zip
Size: 11266 bytes
Desc: not available
URL: <http://www.g-n-u.de/pipermail/gpc/attachments/20030522/4e7ae5ba/attachment.zip>
Adriaan van Os
2003-05-22 09:28:36 UTC
Permalink
Post by Boris Herman
Hello
I have DLed the newest version listed and the Dec2002 Developer Tools
from Apple and have proceeded to work on a more complex project.
alan.pas:577: internal error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://www.gnu-pascal.de/todo.html> for instructions.
Any ideas?
Try to increase the stacksize limit (a known problem of Mac OS X), e.g.

[G4:~/gnu/testgpc/alan] adriaan% limit stacksize 2048
[G4:~/gnu/testgpc/alan] adriaan% gpc --automake -o alan alan.pas
alan.pas: In procedure `pisi1':
alan.pas:713: error: undeclared identifier `arcsin' (first use in this
routine)
alan.pas:713: error: (Each undeclared identifier is reported only once
alan.pas:713: error: for each routine it appears in.)
alan.pas: In procedure `pisi2':
alan.pas:765: error: undeclared identifier `arcsin' (first use in this
routine)

Regards,

Adriaan van Os
Boris Herman
2003-05-22 13:47:07 UTC
Permalink
Hi
Post by Adriaan van Os
work on a more complex project. However, I am unable to compile the
alan.pas:577: internal error: Segmentation fault
Try to increase the stacksize limit (a known problem of Mac OS X), e.g.
alan.pas:713: error: undeclared identifier `arcsin' (first use in this
routine)
Thanks! That did it. I had to implement an arcsin function myself as
there isn't a "math" unit for GPC, right?

Regards,
Boris
Frank Heckenbach
2003-05-22 14:47:54 UTC
Permalink
Post by Boris Herman
Post by Adriaan van Os
work on a more complex project. However, I am unable to compile the
alan.pas:577: internal error: Segmentation fault
Try to increase the stacksize limit (a known problem of Mac OS X), e.g.
alan.pas:713: error: undeclared identifier `arcsin' (first use in this
routine)
Thanks! That did it. I had to implement an arcsin function myself as
there isn't a "math" unit for GPC, right?
You could declare the libm function external.

double asin (double x);

becomes:

function ArcSin (x: Real): Real; external name 'asin';

If there's interest, I could add ArcSin and ArcCos to the runtime
library.

Frank
--
Frank Heckenbach, frank at g-n-u.de, http://fjf.gnu.de/, 7977168E
GPC To-Do list, latest features, fixed bugs:
http://www.gnu-pascal.de/todo.html
GPC download signing key: 51FF C1F0 1A77 C6C2 4482 4DDC 117A 9773 7F88 1707
Eike Lange
2003-05-22 16:58:17 UTC
Permalink
Post by Frank Heckenbach
If there's interest, I could add ArcSin and ArcCos to the runtime
library.
This would be great!

Eike
Gale Paeper
2003-05-29 01:59:26 UTC
Permalink
[snip]
Post by Frank Heckenbach
Post by Boris Herman
Thanks! That did it. I had to implement an arcsin function myself as
there isn't a "math" unit for GPC, right?
For a Pascal "math" unit for GPC on Mac OS X, Apple has already supplied
a solution in the fp.p unit of the Universal Interfaces. The comment
from fp.p [.pas] pretty much explains the functionality:

{*******************************************************************************
*
*
* A collection of numerical functions designed to facilitate a wide
*
* range of numerical programming as required by C9X.
*
*
*
* The <fp.h> declares many functions in support of numerical
programming. *
* It provides a superset of <math.h> and <SANE.h> functions. Some
*
* functionality previously found in <SANE.h> and not in the FPCE
<fp.h> *
* can be found in this <fp.h> under the heading "__NOEXTENSIONS__".
*
*
*
* All of these functions are IEEE 754 aware and treat exceptions,
NaNs, *
* positive and negative zero and infinity consistent with the
floating- *
* point standard.
*
*
*
*******************************************************************************}

Thanks to the efforts of Adriaan van Os and Peter N Lewis, a Mac OS X
GPC compatible version of Apple's Universal Interfaces which includes
fp.pas is available in two download packages which installs the
GPCInterfaces (i.e., the GPC compatible translation of Apple's Universal
Interfaces) for use with Mac OS X GPC. The Mac OS X GPC binary install
package <http://www.microbizz.nl/gpc321d11.bin.tar> includes
GPCInterfaces as part of the installation or a GPCInterfaces only
install package <http://www.microbizz.nl/GPCInterfacesA.tar> will add
the GPCInterfaces to a Mac OS X configuration if it doesn't already have
a copy installed.
Post by Frank Heckenbach
You could declare the libm function external.
double asin (double x);
If I'm not mistaken, the gcc math.h for Mac OS X is configured to use
Apple's math.h. Since the math.h subset of the GPCInterfaces fp.pas
ends up linking with Apple's math.h implementation, there isn't any need
to do this. The original poster can get the asin implemetation on Mac
OS X just by using the fp.pas unit from GPCInterfaces. Since fp.pas
contains a trunc function which is incompatible with Pascal's trunc
fuction, it would be less troublesome to either selectively import the
specificly need routines from fp.pas or to selectively rename the import
of the fp.pas trunc routine to avoid conflicts with Pascal's trunc function.

Gale Paeper
gpaeper at empirenet.com
Adriaan van Os
2003-05-22 14:16:03 UTC
Permalink
Post by Boris Herman
Post by Adriaan van Os
work on a more complex project. However, I am unable to compile the
alan.pas:577: internal error: Segmentation fault
Try to increase the stacksize limit (a known problem of Mac OS X),
e.g.
alan.pas:713: error: undeclared identifier `arcsin' (first use in
this routine)
Thanks! That did it. I had to implement an arcsin function myself as
there isn't a "math" unit for GPC, right?
There is a multi-precision math library (gmp) in the downloads section
of <www.gnu-pascal.de>. So far, I haven't tried it on Mac OS X, but you
may want to do so (it would be useful).

Also, you can download the Mac GPCPInterfaces from
<www.microbizz.nl/gpc.html> and then use the routines in fp.pas (it has
an asin routine).

Regards,

Adriaan van Os
Boris Herman
2003-05-22 19:40:38 UTC
Permalink
Hello
Post by Eike Lange
Post by Frank Heckenbach
If there's interest, I could add ArcSin and ArcCos to the runtime
library.
This would be great!
I've found out that I get more precision by using this self-written
function:

function ArcSin(x:double):double;
const c1=1e-6;
begin
if abs(x-1)<c1 then
ArcSin:=pi/2
else
if abs(1+x)<c1 then
ArcSin:=-pi/2
else
ArcSin:=ArcTan(x/sqrt(1-sqr(x)));
end;

Regards,
Boris
Frank Heckenbach
2003-05-28 22:29:14 UTC
Permalink
Post by Boris Herman
Post by Eike Lange
Post by Frank Heckenbach
If there's interest, I could add ArcSin and ArcCos to the runtime
library.
This would be great!
I've found out that I get more precision by using this self-written
function ArcSin(x:double):double;
const c1=1e-6;
begin
if abs(x-1)<c1 then
ArcSin:=pi/2
else
if abs(1+x)<c1 then
ArcSin:=-pi/2
else
ArcSin:=ArcTan(x/sqrt(1-sqr(x)));
end;
I hope Emil will comment on the numeric stability of this function
etc. I'm a bit worried about the c1 definition. It might be suitable
for the Double type on your platform, but I think a general function
should try to work with MinReal, EpsReal etc.

If this is worked out, I could include such a function (and a
corresponding ArcCos). Otherwise, I can still refer to the libm
functions ...

Frank
--
Frank Heckenbach, frank at g-n-u.de, http://fjf.gnu.de/, 7977168E
GPC To-Do list, latest features, fixed bugs:
http://www.gnu-pascal.de/todo.html
GPC download signing key: 51FF C1F0 1A77 C6C2 4482 4DDC 117A 9773 7F88 1707
Jean-Pierre Vial
2003-06-01 13:02:00 UTC
Permalink
Post by Frank Heckenbach
Post by Boris Herman
Post by Eike Lange
Post by Frank Heckenbach
If there's interest, I could add ArcSin and ArcCos to the runtime
library.
This would be great!
I've found out that I get more precision by using this self-written
function ArcSin(x:double):double;
const c1=1e-6;
begin
if abs(x-1)<c1 then
ArcSin:=pi/2
else
if abs(1+x)<c1 then
ArcSin:=-pi/2
else
ArcSin:=ArcTan(x/sqrt(1-sqr(x)));
end;
I hope Emil will comment on the numeric stability of this function
etc. I'm a bit worried about the c1 definition. It might be suitable
for the Double type on your platform, but I think a general function
should try to work with MinReal, EpsReal etc.
This code gives only something like simple precision on my machine (AMD
athlon, that is IEEE floating point arithmetic)

It would probably be much safer to rely upon the libm library, which is
(hopefully) optimized at assembly level for most hardwares. Assembly is the
only way to be both accurate and efficient.

If one wants to reinvent the wheel using only standard instructions in Pascal,
here is a solutions accurate to 1E-15 if the hardware has true IEEE double
precision.
Near 1, i use the Taylor expansion of arcsin(1-v^2)
Please note that this is not optimized, I invent a wheel much more like that
of a merovingian ox-cart than that of a Ferrari.
****************************************************************************
function arcsin(x : double):double;
var u,v,w : double;
begin
if (abs(x) < 0.99995) then arcsin:=arctan(x/sqrt(1-sqr(x)))
else begin
u:=1-abs(x);
v:=sqrt(u);
w:=1.5707963267948966192
-v*((u*0.26516504294495532165e-1 +0.11785113019775792073)*u
+1.4142135623730950488);
if (x>0) then arcsin:=w else arcsin := -w;
end;
end; { arcsin }
*****************************************************************************
One should trigger an exception if abs(x) > 1
This is not included here.
--
Jean-Pierre Vial
Boris Herman
2003-05-22 19:42:55 UTC
Permalink
Hi
Post by Adriaan van Os
alan.pas:577: internal error: Segmentation fault
Try to increase the stacksize limit (a known problem of Mac OS X), e.g.
[G4:~/gnu/testgpc/alan] adriaan% limit stacksize 2048
Is there a way to make this "stick" so I don't have to do it everytime
I open Terminal window?

Regards,
Boris
Adriaan van Os
2003-05-28 09:35:45 UTC
Permalink
Post by Boris Herman
Post by Adriaan van Os
alan.pas:577: internal error: Segmentation fault
Try to increase the stacksize limit (a known problem of Mac OS X),
e.g.
[G4:~/gnu/testgpc/alan] adriaan% limit stacksize 2048
Is there a way to make this "stick" so I don't have to do it everytime
I open Terminal window?
[G4:~] adriaan% echo "limit stacksize 2048" >> ~/.tcshrc

Regards,

Adriaan van Os
Adriaan van Os
2003-05-29 09:34:48 UTC
Permalink
<snip> The Mac OS X GPC binary install
package <http://www.microbizz.nl/gpc321d11.bin.tar> includes
GPCInterfaces as part of the installation
No, presently it's a separate download.
<anip> Since fp.pas
contains a trunc function which is incompatible with Pascal's trunc
fuction, it would be less troublesome to either selectively import the
specificly need routines from fp.pas or to selectively rename the
import
of the fp.pas trunc routine to avoid conflicts with Pascal's trunc
function.
Thanks for pointing this out, I will rename the trunc function in
fp.pas to truncd:

function truncd( x: double_t): double_t; external name 'trunc';

Expect a new release of GPCPInterfaces somewhere next week, together
with a gpc-20030507/gcc-3.3 based compiler.

Regards,

Adriaan van Os
Mirsad Todorovac
2003-05-31 14:59:27 UTC
Permalink
Post by Boris Herman
Hello
Post by Eike Lange
Post by Frank Heckenbach
If there's interest, I could add ArcSin and ArcCos to the runtime
library.
This would be great!
I've found out that I get more precision by using this self-written
function ArcSin(x:double):double;
const c1=1e-6;
begin
if abs(x-1)<c1 then
ArcSin:=pi/2
else
if abs(1+x)<c1 then
ArcSin:=-pi/2
else
ArcSin:=ArcTan(x/sqrt(1-sqr(x)));
end;
Hi, Boris,

Did you actually mean, that you get more precise ArcSin and ArcCos than
math (co)processors offer, or did you address imprecisions in the
math library?

How does your formula perform in calculation time compared to math
processor and library function?

Thanks.

(Sorry for delay with this question)

Mirsad
--
"I have a dream!" -- Martin Luther King Jr.
Loading...