1 /* -*- mode: C -*- */ 2 /* 3 IGraph library. 4 Copyright (C) 2009-2012 Gabor Csardi <csardi.gabor@gmail.com> 5 334 Harvard street, Cambridge, MA 02139 USA 6 7 This program is free software; you can redistribute it and/or modify 8 it under the terms of the GNU General Public License as published by 9 the Free Software Foundation; either version 2 of the License, or 10 (at your option) any later version. 11 12 This program is distributed in the hope that it will be useful, 13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 GNU General Public License for more details. 16 17 You should have received a copy of the GNU General Public License 18 along with this program; if not, write to the Free Software 19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 20 02110-1301 USA 21 22 */ 23 24 #ifndef IGRAPH_VECTOR_H 25 #define IGRAPH_VECTOR_H 26 27 #include "igraph_decls.h" 28 #include "igraph_types.h" 29 #include "igraph_complex.h" 30 31 __BEGIN_DECLS 32 33 /* -------------------------------------------------- */ 34 /* Flexible vector */ 35 /* -------------------------------------------------- */ 36 37 #define BASE_IGRAPH_REAL 38 #include "igraph_pmt.h" 39 #include "igraph_vector_type.h" 40 #include "igraph_pmt_off.h" 41 #undef BASE_IGRAPH_REAL 42 43 #define BASE_FLOAT 44 #include "igraph_pmt.h" 45 #include "igraph_vector_type.h" 46 #include "igraph_pmt_off.h" 47 #undef BASE_FLOAT 48 49 #define BASE_LONG 50 #include "igraph_pmt.h" 51 #include "igraph_vector_type.h" 52 #include "igraph_pmt_off.h" 53 #undef BASE_LONG 54 55 #define BASE_CHAR 56 #include "igraph_pmt.h" 57 #include "igraph_vector_type.h" 58 #include "igraph_pmt_off.h" 59 #undef BASE_CHAR 60 61 #define BASE_BOOL 62 #include "igraph_pmt.h" 63 #include "igraph_vector_type.h" 64 #include "igraph_pmt_off.h" 65 #undef BASE_BOOL 66 67 #define BASE_INT 68 #include "igraph_pmt.h" 69 #include "igraph_vector_type.h" 70 #include "igraph_pmt_off.h" 71 #undef BASE_INT 72 73 #define BASE_COMPLEX 74 #include "igraph_pmt.h" 75 #include "igraph_vector_type.h" 76 #include "igraph_pmt_off.h" 77 #undef BASE_COMPLEX 78 79 #define BASE_IGRAPH_REAL 80 #include "igraph_pmt.h" 81 #include "igraph_vector_pmt.h" 82 #include "igraph_pmt_off.h" 83 #undef BASE_IGRAPH_REAL 84 85 #define BASE_FLOAT 86 #include "igraph_pmt.h" 87 #include "igraph_vector_pmt.h" 88 #include "igraph_pmt_off.h" 89 #undef BASE_FLOAT 90 91 #define BASE_LONG 92 #include "igraph_pmt.h" 93 #include "igraph_vector_pmt.h" 94 #include "igraph_pmt_off.h" 95 #undef BASE_LONG 96 97 #define BASE_CHAR 98 #include "igraph_pmt.h" 99 #include "igraph_vector_pmt.h" 100 #include "igraph_pmt_off.h" 101 #undef BASE_CHAR 102 103 #define BASE_BOOL 104 #include "igraph_pmt.h" 105 #include "igraph_vector_pmt.h" 106 #include "igraph_pmt_off.h" 107 #undef BASE_BOOL 108 109 #define BASE_INT 110 #include "igraph_pmt.h" 111 #include "igraph_vector_pmt.h" 112 #include "igraph_pmt_off.h" 113 #undef BASE_INT 114 115 #define BASE_COMPLEX 116 #include "igraph_pmt.h" 117 #include "igraph_vector_pmt.h" 118 #include "igraph_pmt_off.h" 119 #undef BASE_COMPLEX 120 121 /* -------------------------------------------------- */ 122 /* Helper macros */ 123 /* -------------------------------------------------- */ 124 125 #ifndef IGRAPH_VECTOR_NULL 126 #define IGRAPH_VECTOR_NULL { 0,0,0 } 127 #endif 128 129 #ifndef IGRAPH_VECTOR_INIT_FINALLY 130 #define IGRAPH_VECTOR_INIT_FINALLY(v, size) \ 131 do { IGRAPH_CHECK(igraph_vector_init(v, size)); \ 132 IGRAPH_FINALLY(igraph_vector_destroy, v); } while (0) 133 #endif 134 #ifndef IGRAPH_VECTOR_BOOL_INIT_FINALLY 135 #define IGRAPH_VECTOR_BOOL_INIT_FINALLY(v, size) \ 136 do { IGRAPH_CHECK(igraph_vector_bool_init(v, size)); \ 137 IGRAPH_FINALLY(igraph_vector_bool_destroy, v); } while (0) 138 #endif 139 #ifndef IGRAPH_VECTOR_CHAR_INIT_FINALLY 140 #define IGRAPH_VECTOR_CHAR_INIT_FINALLY(v, size) \ 141 do { IGRAPH_CHECK(igraph_vector_char_init(v, size)); \ 142 IGRAPH_FINALLY(igraph_vector_char_destroy, v); } while (0) 143 #endif 144 #ifndef IGRAPH_VECTOR_INT_INIT_FINALLY 145 #define IGRAPH_VECTOR_INT_INIT_FINALLY(v, size) \ 146 do { IGRAPH_CHECK(igraph_vector_int_init(v, size)); \ 147 IGRAPH_FINALLY(igraph_vector_int_destroy, v); } while (0) 148 #endif 149 #ifndef IGRAPH_VECTOR_LONG_INIT_FINALLY 150 #define IGRAPH_VECTOR_LONG_INIT_FINALLY(v, size) \ 151 do { IGRAPH_CHECK(igraph_vector_long_init(v, size)); \ 152 IGRAPH_FINALLY(igraph_vector_long_destroy, v); } while (0) 153 #endif 154 155 /* -------------------------------------------------- */ 156 /* Type-specific vector functions */ 157 /* -------------------------------------------------- */ 158 159 IGRAPH_EXPORT int igraph_vector_floor(const igraph_vector_t *from, igraph_vector_long_t *to); 160 IGRAPH_EXPORT int igraph_vector_round(const igraph_vector_t *from, igraph_vector_long_t *to); 161 162 IGRAPH_EXPORT igraph_bool_t igraph_vector_e_tol(const igraph_vector_t *lhs, 163 const igraph_vector_t *rhs, 164 igraph_real_t tol); 165 166 IGRAPH_EXPORT int igraph_vector_zapsmall(igraph_vector_t *v, igraph_real_t tol); 167 168 IGRAPH_EXPORT int igraph_vector_order(const igraph_vector_t* v, const igraph_vector_t *v2, 169 igraph_vector_t* res, igraph_real_t maxval); 170 IGRAPH_EXPORT int igraph_vector_order1(const igraph_vector_t* v, 171 igraph_vector_t* res, igraph_real_t maxval); 172 IGRAPH_EXPORT int igraph_vector_order1_int(const igraph_vector_t* v, 173 igraph_vector_int_t* res, igraph_real_t maxval); 174 IGRAPH_EXPORT int igraph_vector_order2(igraph_vector_t *v); 175 IGRAPH_EXPORT int igraph_vector_rank(const igraph_vector_t *v, igraph_vector_t *res, 176 long int nodes); 177 IGRAPH_EXPORT int igraph_vector_is_nan(const igraph_vector_t *v, 178 igraph_vector_bool_t *is_nan); 179 IGRAPH_EXPORT igraph_bool_t igraph_vector_is_any_nan(const igraph_vector_t *v); 180 181 __END_DECLS 182 183 #endif 184