File: igraph_pmt.h

package info (click to toggle)
igraph 0.10.2%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 16,176 kB
  • sloc: ansic: 121,500; cpp: 21,699; xml: 2,734; python: 411; makefile: 147; javascript: 20; sh: 9
file content (196 lines) | stat: -rw-r--r-- 6,856 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
185
186
187
188
189
190
191
192
193
194
195
196
/* -*- mode: C -*-  */
/*
   IGraph library.
   Copyright (C) 2007-2012  Gabor Csardi <csardi.gabor@gmail.com>
   334 Harvard street, Cambridge, MA 02139 USA

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc.,  51 Franklin Street, Fifth Floor, Boston, MA
   02110-1301 USA

*/

#define CONCAT2x(a,b) a ## _ ## b
#define CONCAT2(a,b) CONCAT2x(a,b)
#define CONCAT3x(a,b,c) a ## _ ## b ## _ ## c
#define CONCAT3(a,b,c) CONCAT3x(a,b,c)
#define CONCAT4x(a,b,c,d) a ## _ ## b ## _ ## c ## _ ## d
#define CONCAT4(a,b,c,d) CONCAT4x(a,b,c,d)
#define CONCAT5x(a,b,c,d,e) a ## _ ## b ## _ ## c ## _ ## d ## _ ## e
#define CONCAT5(a,b,c,d,e) CONCAT5x(a,b,c,d,e)

#if defined(BASE_IGRAPH_REAL)
    #define BASE igraph_real_t
    #define BASE_VECTOR igraph_vector_t
    #define BASE_MATRIX igraph_matrix_t
    #define SHORT
    #define OUT_FORMAT "%g"
    #define PRINTFUNC(val) igraph_real_printf(val)
    #define SNPRINTFUNC(str, size, val) igraph_real_snprintf(str, size, val)
    #define FPRINTFUNC_ALIGNED(file, width, val) igraph_real_fprintf_aligned(file, width, val)
    #define FPRINTFUNC(file, val) igraph_real_fprintf(file, val)
    #define ZERO 0.0
    #define ONE 1.0
    #define MULTIPLICITY 1

#elif defined(BASE_CHAR)
    #define BASE char
    #define BASE_VECTOR igraph_vector_char_t
    #define BASE_MATRIX igraph_matrix_char_t
    #define SHORT char
    #define OUT_FORMAT "%d"
    #define ZERO 0
    #define ONE 1
    #define MULTIPLICITY 1

#elif defined(BASE_BOOL)
    #define BASE igraph_bool_t
    #define BASE_VECTOR igraph_vector_bool_t
    #define BASE_MATRIX igraph_matrix_bool_t
    #define SHORT bool
    #define OUT_FORMAT "%d"
    #define ZERO 0
    #define ONE 1
    #define MULTIPLICITY 1
    #define NOTORDERED 1
    #define NOABS 1
    #define EQ(a,b) ((a && b) || (!a && !b))

#elif defined(BASE_INT)
    #define BASE igraph_integer_t
    #define BASE_VECTOR igraph_vector_int_t
    #define BASE_MATRIX igraph_matrix_int_t
    #define SHORT int
    #define OUT_FORMAT "%" IGRAPH_PRId
    #define ZERO 0
    #define ONE 1
    #define MULTIPLICITY 1

#elif defined(BASE_FORTRAN_INT)
    #define BASE int
    #define SHORT fortran_int
    #define OUT_FORMAT "%d"
    #define ZERO 0
    #define ONE 1
    #define MULTIPLICITY 1

#elif defined(BASE_PTR)
    #define BASE void*
    #define SHORT ptr
    #define ZERO 0
    #define MULTIPLICITY 1

#elif defined(BASE_COMPLEX)
    #undef complex
    #define BASE igraph_complex_t
    #define BASE_VECTOR igraph_vector_complex_t
    #define BASE_MATRIX igraph_matrix_complex_t
    #define SHORT complex
    #define PRINTFUNC(val) igraph_complex_printf(val)
    #define SNPRINTFUNC(str, size, val) igraph_complex_snprintf(str, size, val)
    #define FPRINTFUNC_ALIGNED(file, width, val) igraph_complex_fprintf_aligned(file, width, val)
    #define FPRINTFUNC(file, val) igraph_complex_fprintf(file, val)
    #define ZERO {{0.0, 0.0}}
    #define ONE {{1.0, 0.0}}
    #define MULTIPLICITY 2
    #define NOTORDERED 1
    #define NOABS 1
    #define SUM(a,b,c) ((a) = igraph_complex_add((b),(c)))
    #define DIFF(a,b,c) ((a) = igraph_complex_sub((b),(c)))
    #define PROD(a,b,c) ((a) = igraph_complex_mul((b),(c)))
    #define DIV(a,b,c) ((a) = igraph_complex_div((b),(c)))
    #define EQ(a,b) IGRAPH_COMPLEX_EQ((a),(b))
    #define SQ(a) IGRAPH_REAL(igraph_complex_mul((a),(a)))

#elif defined(BASE_GRAPH)
    #define BASE igraph_t

#else
    #error unknown BASE_ directive
#endif

#if defined(VECTOR_LIST)
    #if defined(BASE_IGRAPH_REAL)
        #define FUNCTION(c) CONCAT2x(igraph_vector_list,c)
        #define INTERNAL_FUNCTION(c) CONCAT2x(igraph_i_vector_list,c)
        #define TYPE igraph_vector_list_t
    #elif defined(BASE_BOOL)
        /* Special case because stdbool.h defines bool as a macro to _Bool which would
        * screw things up */
        #define FUNCTION(c) CONCAT2x(igraph_vector_bool_list,c)
        #define INTERNAL_FUNCTION(c) CONCAT2x(igraph_i_vector_bool_list,c)
        #define TYPE igraph_vector_bool_list_t
    #else
        #define FUNCTION(c) CONCAT4(igraph_vector,SHORT,list,c)
        #define INTERNAL_FUNCTION(c) CONCAT4(igraph_i_vector,SHORT,list,c)
        #define TYPE CONCAT3(igraph_vector,SHORT,list_t)
    #endif
#elif defined(MATRIX_LIST)
    #if defined(BASE_IGRAPH_REAL)
        #define FUNCTION(c) CONCAT2x(igraph_matrix_list,c)
        #define INTERNAL_FUNCTION(c) CONCAT2x(igraph_i_matrix_list,c)
        #define TYPE igraph_matrix_list_t
    #elif defined(BASE_BOOL)
        /* Special case because stdbool.h defines bool as a macro to _Bool which would
        * screw things up */
        #define FUNCTION(c) CONCAT2x(igraph_matrix_bool_list,c)
        #define INTERNAL_FUNCTION(c) CONCAT2x(igraph_i_matrix_bool_list,c)
        #define TYPE igraph_matrix_bool_list_t
    #else
        #define FUNCTION(c) CONCAT4(igraph_matrix,SHORT,list,c)
        #define INTERNAL_FUNCTION(c) CONCAT4(igraph_i_matrix,SHORT,list,c)
        #define TYPE CONCAT3(igraph_matrix,SHORT,list_t)
    #endif
#elif defined(GRAPH_LIST)
    #define FUNCTION(c) CONCAT2x(igraph_graph_list,c)
    #define INTERNAL_FUNCTION(c) CONCAT2x(igraph_i_graph_list,c)
    #define TYPE igraph_graph_list_t
#else
    #if defined(BASE_IGRAPH_REAL)
        #define FUNCTION(a,c) CONCAT2(a,c)
        #define TYPE(a) CONCAT2(a,t)
    #elif defined(BASE_BOOL)
        /* Special case because stdbool.h defines bool as a macro to _Bool which would
        * screw things up */
        #define FUNCTION(a,c) CONCAT3x(a,bool,c)
        #define TYPE(a) CONCAT3x(a,bool,t)
    #else
        #define FUNCTION(a,c) CONCAT3(a,SHORT,c)
        #define TYPE(a) CONCAT3(a,SHORT,t)
    #endif
#endif

#if defined(HEAP_TYPE_MIN)
    #define HEAPMORE <
    #define HEAPMOREEQ <=
    #define HEAPLESS >
    #define HEAPLESSEQ >=
    #undef FUNCTION
    #undef INTERNAL_FUNCTION
    #undef TYPE
    #if defined(BASE_IGRAPH_REAL)
        #define FUNCTION(dir,name) CONCAT3(dir,min,name)
        #define TYPE(dir) CONCAT3(dir,min,t)
    #else
        #define FUNCTION(a,c) CONCAT4(a,min,SHORT,c)
        #define TYPE(dir) CONCAT4(dir,min,SHORT,t)
    #endif
#endif

#if defined(HEAP_TYPE_MAX)
    #define HEAPMORE >
    #define HEAPMOREEQ >=
    #define HEAPLESS <
    #define HEAPLESSEQ <=
#endif