File: mloper.c

package info (click to toggle)
pact 980714-3
  • links: PTS
  • area: main
  • in suites: slink
  • size: 13,096 kB
  • ctags: 26,034
  • sloc: ansic: 109,076; lisp: 9,645; csh: 7,147; fortran: 1,050; makefile: 136; lex: 95; sh: 32
file content (184 lines) | stat: -rw-r--r-- 5,246 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
/*
 * MLOPER.C - field operation routines for PML
 *
 * Source Version: 2.0
 * Software Release #92-0043
 *
 */

#include "cpyright.h"

#include "pml.h"

PM_field
 REAL_Opers = {(PFByte) PM_fplus, (PFByte) PM_fminus, NULL,
                 (PFByte) PM_ftimes, (PFByte) PM_fdivide},
 Int_Opers = {(PFByte) PM_iplus, (PFByte) PM_iminus, NULL, 
              (PFByte) PM_itimes, (PFByte) PM_idivide},
 Long_Opers = {(PFByte) PM_lplus, (PFByte) PM_lminus, NULL, 
               (PFByte) PM_ltimes, (PFByte) PM_ldivide},
 *PM_REAL_Opers = &REAL_Opers,
 *PM_Int_Opers = &Int_Opers,
 *PM_Long_Opers = &Long_Opers;

/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/

/* PM_IPLUS - integer addition in C */

int PM_iplus(x, y)
   int x, y;
   {return(x+y);}

/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/

/* PM_LPLUS - long integer addition in C */

long PM_lplus(x, y)
   long x, y;
   {return(x+y);}

/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/

/* PM_FPLUS - floating point addition in C */

double PM_fplus(x, y)
   double x, y;
   {return(x+y);}

/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/

/* PM_IMINUS - integer subtraction in C */

int PM_iminus(x, y)
   int x, y;
   {return(x-y);}

/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/

/* PM_LMINUS - long integer subtraction in C */

long PM_lminus(x, y)
   long x, y;
   {return(x-y);}

/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/

/* PM_FMINUS - floating point subtraction in C */

double PM_fminus(x, y)
   double x, y;
   {return(x-y);}

/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/

/* PM_ITIMES - integer multiplication in C */

int PM_itimes(x, y)
   int x, y;
   {return(x*y);}

/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/

/* PM_LTIMES - long integer multiplication in C */

long PM_ltimes(x, y)
   long x, y;
   {return(x*y);}

/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/

/* PM_FTIMES - floating point multiplication in C */

double PM_ftimes(x, y)
   double x, y;
   {return(x*y);}

/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/

/* PM_IDIVIDE - integer division in C */

int PM_idivide(x, y)
   int x, y;
   {if (y != 0)
       return(x/y);
    else
       return(INT_MAX);}

/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/

/* PM_LDIVIDE - long integer division in C */

long PM_ldivide(x, y)
   long x, y;
   {if (y != 0)
       return(x/y);
    else
       return(LONG_MAX);}

/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/

/* PM_IMODULO - return the remainder after integer division in C */

int PM_imodulo(x, y)
   int x, y;
   {if (y != 0)
       return(x % y);
    else
       return(0);}

/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/

/* PM_LMODULO - return the remainder after long integer division in C */

long PM_lmodulo(x, y)
   long x, y;
   {if (y != 0)
       return(x % y);
    else
       return(0L);}

/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/

/* PM_FDIVIDE - floating point division in C */

double PM_fdivide(x, y)
   double x, y;
   {if (y != 0.0)
       return(x/y);
    else
       return(DBL_MAX);}

/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/

/* PM_FMIN - floating point min in C */

double PM_fmin(x, y)
   double x, y;
   {return(min(x, y));}

/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/

/* PM_FMAX - floating point max in C */

double PM_fmax(x, y)
   double x, y;
   {return(max(x, y));}

/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/