xfail scan-tree-dump-not throw in g++.dg/pr99966.C on hppa*64*-*-*
[official-gcc.git] / gcc / m2 / gm2-libs-iso / ShortComplexMath.mod
blobabd4067fcc9aa20fcb2a52ca664a92057dfcd319
1 (* ShortComplexMath.mod implements access to the ShortComplex intrincics.
3 Copyright (C) 2009-2024 Free Software Foundation, Inc.
4 Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
6 This file is part of GNU Modula-2.
8 GNU Modula-2 is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
11 any later version.
13 GNU Modula-2 is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 Under Section 7 of GPL version 3, you are granted additional
19 permissions described in the GCC Runtime Library Exception, version
20 3.1, as published by the Free Software Foundation.
22 You should have received a copy of the GNU General Public License and
23 a copy of the GCC Runtime Library Exception along with this program;
24 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
25 <http://www.gnu.org/licenses/>. *)
27 IMPLEMENTATION MODULE ShortComplexMath ;
29 IMPORT cbuiltin ;
32 (* Returns the length of z *)
34 PROCEDURE __ATTRIBUTE__ __BUILTIN__ ((__builtin_cabsf)) abs (z: SHORTCOMPLEX): SHORTREAL;
35 BEGIN
36 RETURN cbuiltin.cabsf (z)
37 END abs ;
40 (* Returns the angle that z subtends to the positive real axis *)
42 PROCEDURE __ATTRIBUTE__ __BUILTIN__ ((__builtin_cargf)) arg (z: SHORTCOMPLEX): SHORTREAL;
43 BEGIN
44 RETURN cbuiltin.cargf (z)
45 END arg ;
48 (* Returns the complex conjugate of z *)
50 PROCEDURE __ATTRIBUTE__ __BUILTIN__ ((__builtin_conjf)) conj (z: SHORTCOMPLEX): SHORTCOMPLEX;
51 BEGIN
52 RETURN cbuiltin.conjf (z)
53 END conj ;
56 (* Returns the value of the number base raised to the power exponent *)
58 PROCEDURE __ATTRIBUTE__ __BUILTIN__ ((__builtin_cpowerf)) power (base: SHORTCOMPLEX; exponent: SHORTREAL): SHORTCOMPLEX;
59 BEGIN
60 RETURN cbuiltin.cpowf (base, exponent)
61 END power ;
64 (* Returns the principal square root of z *)
66 PROCEDURE __ATTRIBUTE__ __BUILTIN__ ((__builtin_csqrtf)) sqrt (z: SHORTCOMPLEX): SHORTCOMPLEX;
67 BEGIN
68 RETURN cbuiltin.csqrtf (z)
69 END sqrt ;
72 (* Returns the complex exponential of z *)
74 PROCEDURE __ATTRIBUTE__ __BUILTIN__ ((__builtin_cexpf)) exp (z: SHORTCOMPLEX): SHORTCOMPLEX;
75 BEGIN
76 RETURN cbuiltin.cexpf (z)
77 END exp ;
80 (* Returns the principal value of the natural logarithm of z *)
82 PROCEDURE __ATTRIBUTE__ __BUILTIN__ ((__builtin_clnf)) ln (z: SHORTCOMPLEX): SHORTCOMPLEX;
83 BEGIN
84 RETURN cbuiltin.clogf (z)
85 END ln ;
88 (* Returns the sine of z *)
90 PROCEDURE __ATTRIBUTE__ __BUILTIN__ ((__builtin_csinf)) sin (z: SHORTCOMPLEX): SHORTCOMPLEX;
91 BEGIN
92 RETURN cbuiltin.csinf (z)
93 END sin ;
96 (* Returns the cosine of z *)
98 PROCEDURE __ATTRIBUTE__ __BUILTIN__ ((__builtin_ccosf)) cos (z: SHORTCOMPLEX): SHORTCOMPLEX;
99 BEGIN
100 RETURN cbuiltin.ccosf (z)
101 END cos ;
104 (* Returns the tangent of z *)
106 PROCEDURE __ATTRIBUTE__ __BUILTIN__ ((__builtin_ctanf)) tan (z: SHORTCOMPLEX): SHORTCOMPLEX;
107 BEGIN
108 RETURN cbuiltin.ctanf (z)
109 END tan ;
112 (* Returns the arcsine of z *)
114 PROCEDURE __ATTRIBUTE__ __BUILTIN__ ((__builtin_carcsinf)) arcsin (z: SHORTCOMPLEX): SHORTCOMPLEX;
115 BEGIN
116 RETURN cbuiltin.casinf (z)
117 END arcsin ;
120 (* Returns the arccosine of z *)
122 PROCEDURE __ATTRIBUTE__ __BUILTIN__ ((__builtin_carccosf)) arccos (z: SHORTCOMPLEX): SHORTCOMPLEX;
123 BEGIN
124 RETURN cbuiltin.cacosf (z)
125 END arccos ;
128 (* Returns the arctangent of z *)
130 PROCEDURE __ATTRIBUTE__ __BUILTIN__ ((__builtin_carctanf)) arctan (z: SHORTCOMPLEX): SHORTCOMPLEX;
131 BEGIN
132 RETURN cbuiltin.catanf (z)
133 END arctan ;
136 (* Returns the complex number with the specified polar coordinates *)
138 PROCEDURE polarToComplex (abs, arg: SHORTREAL): SHORTCOMPLEX;
139 BEGIN
140 RETURN CMPLX (abs*cbuiltin.cosf(arg), abs*cbuiltin.sinf(arg))
141 END polarToComplex ;
144 (* Returns the scalar product of scalar with z *)
146 PROCEDURE scalarMult (scalar: SHORTREAL; z: SHORTCOMPLEX): SHORTCOMPLEX;
147 BEGIN
148 RETURN CMPLX (RE(z)*scalar, IM(z)*scalar)
149 END scalarMult ;
152 (* Returns TRUE if the current coroutine is in the exceptional
153 execution state because of the raising of an exception in a
154 routine from this module; otherwise returns FALSE.
157 PROCEDURE IsCMathException (): BOOLEAN;
158 BEGIN
159 (* --fixme-- we should really attempt to catch sigfpe in these procedures *)
160 RETURN( FALSE )
161 END IsCMathException ;
164 END ShortComplexMath.