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. However, I am unable to compile the source - it gives me this error:
alan.pas: In procedure `f_b': 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
Boris Herman wrote:
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. However, I am unable to compile the source - it gives me this error:
alan.pas: In procedure `f_b': 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
Hi
work on a more complex project. However, I am unable to compile the source - it gives me this error:
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
Boris Herman wrote:
work on a more complex project. However, I am unable to compile the source - it gives me this error:
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 wrote:
work on a more complex project. However, I am unable to compile the source - it gives me this error:
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
Hello
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
Boris Herman wrote:
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;
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
Le Jeudi 29 Mai 2003 00:29, Frank Heckenbach a écrit :
Boris Herman wrote:
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;
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.
On Thu, 22 May 2003, Boris Herman wrote:
Hello
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;
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
Frank Heckenbach wrote:
Boris Herman wrote:
[snip]
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.
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@empirenet.com
Gale Paeper wrote:
<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
Hi
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
Boris Herman wrote:
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