File: sacmacros.h

package info (click to toggle)
saclib 2.2.8-6.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 11,872 kB
  • sloc: ansic: 40,932; csh: 1,190; asm: 541; awk: 320; sh: 246; perl: 116; makefile: 98; sed: 48
file content (140 lines) | stat: -rw-r--r-- 4,219 bytes parent folder | download | duplicates (3)
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
/*===========================================================================
			  sacmacros.h

Header file for SACLIB macro definitions
===========================================================================*/
#ifndef SACMACROS_H
#define SACMACROS_H

#include "sacsys.h"
#include "sactypes.h"

/*---------------------------------------------------------------------------
		The canonical saclib version number.
---------------------------------------------------------------------------*/
#define SACMAJVERS 2
#define SACMINVERS 2
#define SACREVVERS 7

/*---------------------------------------------------------------------------
		Macros that are always defined.
---------------------------------------------------------------------------*/
#ifdef NO_SACLIB_MACROS
#define FIRST(L)       SPACEB1[(L)]
#define GCAGET(A,i)    (GCASPACEBp[(A)].array[(i)])
#define GCASET(A,i,a)  (GCASPACEBp[(A)].array[(i)] = (a))
#define ISNIL(a)       ((a) == NIL)
#define ISZERO(a)      ((a) == 0)
#define RED(L)         SPACEB[(L)]
#define SFIRST(L,a)    (SPACEB1[(L)] = (a))
#define SRED(L,Lp)     (SPACEB[(L)] = (Lp))
#endif
#define ILENGTH(A)     (((A) < BETA) ? 1 : LENGTH(A))
#define ILOG2A(A,n)    (((n)==0) ? 0 : ((n)-1)*ZETA + DLOG2((A)[(n)-1]))
#define ISIGNA(A,n)    ((n) == 0 ? 0 : (((A)[(n)-1] > 0) ? 1 : -1))

#define absm(a)        (((a) >= 0) ? (a) : -(a))
#define maxm(a,b)      (((a) > (b)) ? (a) : (b))
#define minm(a,b)      (((a) < (b)) ? (a) : (b))
#define signm(a)       ((a) > 0 ? 1 : ((a) < 0 ? -1 : 0))

/*---------------------------------------------------------------------------
			     Arrays.
---------------------------------------------------------------------------*/

#define FREEARRAY(A)   free((A))


/*---------------------------------------------------------------------------
		       Array polynomials.
---------------------------------------------------------------------------*/

/* MAP coefficient */
#define MAPCF(A,e)  (A[e])

/* MAP degree */
#define MAPDEG(A)   (A[-1])

/* MAP free memory */
#define MAPFREE(A)  FREEARRAY((A)-1)

/* MAP get memory */
#define MAPGET(n)   (GETARRAY((n)+2) + 1)

/* MAP leading coefficient */
#define MAPLDCF(A)  (MAPCF(A,MAPDEG(A)))

/* MAP zero test */
#define MAPZERO(A)  (MAPDEG(A) == 0 && MAPCF(A,0) == 0)


/*---------------------------------------------------------------------------
		 Finite ring array polynomials.
---------------------------------------------------------------------------*/

/* FRAP degree */
#define FRAPDEG(A) (A[-1][0])

/* FRAP size---the size of the array */
#define FRAPSIZE(A) (A[-1][1])

/* FRAP coefficient */
#define FRAPCF(A,i)  (A[i])

/* FRAP leading coefficient */
#define FRAPLDCF(A)  (FRAPCF(A,FRAPDEG(A)))

/* FRAP zero test */
#define FRAPZERO(A) (FRAPDEG(A) == 0 && MAPZERO(FRAPLDCF(A)))


/*---------------------------------------------------------------------------
			   Matrices.
---------------------------------------------------------------------------*/

/* matrix element */
#define MATELT(M,i,j)  (M[i][j])

#ifndef NO_SACLIB_MACROS


/*---------------------------------------------------------------------------
			List processing.
---------------------------------------------------------------------------*/

#define RED2(L)        RED(RED(L))
#define SECOND(L)      FIRST(RED(L))


/* Arithmetic */

#define ODD(a)         ((a) & 1)
#define EVEN(a)        (!ODD(a))
#define DAND(a,b)      ((a) & (b))
#define DOR(a,b)       ((a) | (b))
#define DNOT(a)        (~(a))
#define DNIMP(a,b)     ((a) & ~(b))
#define MDSUM(m,a,b)  (((a)+(b))%(m))


/***
 *
 * The following macros give troubles w.r.t. side effects and therefore
 * are commented out for the time being.
 *
 ***/

/*
#define ISATOM(a)      (-BETA < (a) && (a) < BETA)
#define ISLIST(a)      ((BETA < (a) && (a) < BETAp && ((a) & 1)) || (a) == BETA)
#define ISOBJECT(a)    (ISATOM(a) || ISLIST(a))
#define ISGCA(a)       (BETAp < (a) && (a) < BETApp)
#define ADV(L,a,Lp)    do {*(a)=FIRST(L); *(Lp)=RED(L);} while (0)
#define QREM(a,b,q,r)  do {*(q)=(a)/(b); *(r)=(a)%(b);} while (0)
#define MDDIF(m,a,b)   (((a)-(b)+(m))%(m))
#define MDNEG(m,a)     ((a)==0?0:(m)-(a))
*/

#endif /* NO_SACLIB_MACROS */

#endif /* SACMACROS_H */