Dear GPC-ers,
it seems that the complex arithmetic under GPC is not well implemented:
(i) there is only one complex type, the one whose real and imaginary part are double precision reals. For numerical applications complex numbers in single and extended precision are needed as well (in fact, just the availability of these three real precisions is what makes gnu-pascal attractive in this context).
(ii) the complex arithmetic of GPC lacks the elementary accuracy; see the following program
program complmult; var a : complex; b : double; begin b := 1e+160; a := cmplx(b,0); writeln('abs(b) = ',abs(b)); writeln('abs(a) = ',abs(a)); end.
Upon execution the results are
abs(b) = 1.000000000000000e+160 abs(a) = Inf
which is below even elementary standards. GNU g77 has none of the mentioned shortcomings, cannot one repair this?
Sincerely, K. Veselic.
Kresimir Veselic wrote:
Dear GPC-ers,
it seems that the complex arithmetic under GPC is not well implemented:
(i) there is only one complex type, the one whose real and imaginary part are double precision reals. For numerical applications complex numbers in single and extended precision are needed as well (in fact, just the availability of these three real precisions is what makes gnu-pascal attractive in this context).
(ii) the complex arithmetic of GPC lacks the elementary accuracy; see the following program
program complmult; var a : complex; b : double; begin b := 1e+160; a := cmplx(b,0); writeln('abs(b) = ',abs(b)); writeln('abs(a) = ',abs(a)); end.
Upon execution the results are
abs(b) = 1.000000000000000e+160 abs(a) = Inf
which is below even elementary standards. GNU g77 has none of the mentioned shortcomings, cannot one repair this?
(ii) has already been done. Please install the last version of gpc (2.1)
for (i) I agree. As a workaround I use the CEPHES library (which contains complex functions) with an import pascal unit. But direct inclusion in the compiler would be much better.
Maurice
Dear Mr. Lombardi, dear gpc-ers,
thanks for help. Is the CEPHES library automatically available with the standard GPC package?. The line uses CEPHES
does not work.
Thanks in advance, K. Veselic.
On Mon, 15 Jul 2002, Maurice Lombardi wrote:
Kresimir Veselic wrote:
Dear GPC-ers,
it seems that the complex arithmetic under GPC is not well implemented:
(i) there is only one complex type, the one whose real and imaginary part are double precision reals. For numerical applications complex numbers in single and extended precision are needed as well (in fact, just the availability of these three real precisions is what makes gnu-pascal attractive in this context).
(ii) the complex arithmetic of GPC lacks the elementary accuracy; see the following program
program complmult; var a : complex; b : double; begin b := 1e+160; a := cmplx(b,0); writeln('abs(b) = ',abs(b)); writeln('abs(a) = ',abs(a)); end.
Upon execution the results are
abs(b) = 1.000000000000000e+160 abs(a) = Inf
which is below even elementary standards. GNU g77 has none of the mentioned shortcomings, cannot one repair this?
(ii) has already been done. Please install the last version of gpc (2.1)
for (i) I agree. As a workaround I use the CEPHES library (which contains complex functions) with an import pascal unit. But direct inclusion in the compiler would be much better.
Maurice
-- Maurice Lombardi Laboratoire de Spectrometrie Physique, Universite Joseph Fourier de Grenoble, BP87 38402 Saint Martin d'Heres Cedex FRANCE Tel: 33 (0)4 76 51 47 51 Fax: 33 (0)4 76 63 54 95 mailto:Maurice.Lombardi@ujf-grenoble.fr