]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /** |
2 | * -*- c++ -*- | |
3 | * | |
4 | * \file c_array.hpp | |
5 | * | |
6 | * \brief provides specializations of matrix and vector traits for c arrays and c matrices. | |
7 | * | |
8 | * Copyright (c) 2009, Gunter Winkler | |
9 | * | |
10 | * Distributed under the Boost Software License, Version 1.0. (See | |
11 | * accompanying file LICENSE_1_0.txt or copy at | |
12 | * http://www.boost.org/LICENSE_1_0.txt) | |
13 | * | |
14 | * \author Gunter Winkler (guwi17 at gmx dot de) | |
15 | */ | |
16 | ||
17 | #ifndef BOOST_NUMERIC_UBLAS_TRAITS_C_ARRAY_HPP | |
18 | #define BOOST_NUMERIC_UBLAS_TRAITS_C_ARRAY_HPP | |
19 | ||
20 | ||
21 | #include <boost/numeric/ublas/traits.hpp> | |
22 | #include <boost/numeric/ublas/traits/const_iterator_type.hpp> | |
23 | #include <boost/numeric/ublas/traits/iterator_type.hpp> | |
24 | ||
25 | namespace boost { namespace numeric { namespace ublas { | |
26 | ||
27 | namespace detail { | |
28 | ||
29 | ||
30 | ||
31 | } | |
32 | ||
33 | ||
34 | template < class T, int M, int N > | |
35 | struct matrix_view_traits < T[M][N] > { | |
36 | typedef T matrix_type[M][N]; | |
37 | ||
38 | typedef std::size_t size_type; | |
39 | typedef std::ptrdiff_t difference_type; | |
40 | ||
41 | typedef row_major_tag orientation_category; | |
42 | typedef dense_tag storage_category; | |
43 | ||
44 | typedef T value_type; | |
45 | typedef const T &const_reference; | |
46 | typedef const T *const_pointer; | |
47 | ||
48 | typedef const matrix_reference<const matrix_type> const_closure_type; | |
49 | ||
50 | typedef T row_type[N]; | |
51 | ||
52 | typedef const row_type *const_iterator1; | |
53 | typedef const_pointer const_iterator2; | |
54 | ||
55 | }; | |
56 | ||
57 | template < class T, int M, int N > | |
58 | struct mutable_matrix_traits < T[M][N] > { | |
59 | typedef T matrix_type[M][N]; | |
60 | ||
61 | typedef T *reference; | |
62 | ||
63 | typedef matrix_reference<matrix_type> closure_type; | |
64 | ||
65 | }; | |
66 | ||
67 | template < class T, int N > | |
68 | struct vector_view_traits < T[N] > { | |
69 | typedef T vector_type[N]; | |
70 | ||
71 | typedef std::size_t size_type; | |
72 | typedef std::ptrdiff_t difference_type; | |
73 | ||
74 | typedef dense_tag storage_category; | |
75 | ||
76 | typedef T value_type; | |
77 | typedef const T &const_reference; | |
78 | typedef const T *const_pointer; | |
79 | ||
80 | typedef const vector_reference<const vector_type> const_closure_type; | |
81 | ||
82 | typedef const_pointer const_iterator; | |
83 | ||
84 | /// iterator pointing to the first element | |
85 | static | |
86 | const_iterator begin(const vector_type & v) { | |
87 | return & (v[0]); | |
88 | } | |
89 | /// iterator pointing behind the last element | |
90 | static | |
91 | const_iterator end(const vector_type & v) { | |
92 | return & (v[N]); | |
93 | } | |
94 | }; | |
95 | ||
96 | template < class T, int N > | |
97 | struct mutable_vector_traits < T[N] > { | |
98 | ||
99 | typedef T &reference; | |
100 | typedef T *pointer; | |
101 | typedef vector_reference< T[N] > closure_type; | |
102 | ||
103 | }; | |
104 | ||
105 | ||
106 | ||
107 | ||
108 | }}} // Namespace boost::numeric::ublas | |
109 | ||
110 | #endif |