My Project
gsl_vector_dispatch.hh
Go to the documentation of this file.
1/* -*- mia-c++ -*-
2 *
3 * This file is part of MIA - a toolbox for medical image analysis
4 * Copyright (c) Leipzig, Madrid 1999-2017 Gert Wollny
5 *
6 * MIA is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with MIA; if not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20
21#define GSL_VECTOR_DISPATCH(TYPE) \
22 template <> \
23 struct gsl_vector_dispatch<TYPE> { \
24 typedef TYPE value_type; \
25 typedef TYPE *iterator; \
26 typedef const TYPE *const_iterator; \
27 typedef size_t size_type; \
28 typedef TYPE& reference; \
29 typedef const TYPE& const_reference; \
30 \
31 typedef gsl_value_type gsl_vector_##TYPE \
32 protected: \
33 static gsl_value_type *alloc(size_t n) { \
34 return gsl_vector_##TYPE##_alloc(n); \
35 } \
36 static gsl_value_type *calloc(size_t n) { \
37 return gsl_vector_##TYPE##_calloc(n); \
38 } \
39 static gsl_vector_type *alloc_from(gsl_vector_type *other) { \
40 return gsl_vector_#TYPE#_alloc_from_vector(other, 0, \
41 other->size, 1); \
42 } \
43 static void free(gsl_value_type *v) { \
44 gsl_vector_##TYPE##_free(v); \
45 } \
46 static value_type get(gsl_vector_type *v, size_t i) { \
47 gsl_vector_##TYPE##_get(v,i); \
48 } \
49 };