1 | // -*- C++ -*- |
---|
2 | /*************************************************************************** |
---|
3 | * blitz/vector.h Declaration of the Vector<P_numtype> class |
---|
4 | * |
---|
5 | * $Id$ |
---|
6 | * |
---|
7 | * Copyright (C) 1997-2011 Todd Veldhuizen <tveldhui@acm.org> |
---|
8 | * |
---|
9 | * This file is a part of Blitz. |
---|
10 | * |
---|
11 | * Blitz is free software: you can redistribute it and/or modify |
---|
12 | * it under the terms of the GNU Lesser General Public License |
---|
13 | * as published by the Free Software Foundation, either version 3 |
---|
14 | * of the License, or (at your option) any later version. |
---|
15 | * |
---|
16 | * Blitz is distributed in the hope that it will be useful, |
---|
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
19 | * GNU Lesser General Public License for more details. |
---|
20 | * |
---|
21 | * You should have received a copy of the GNU Lesser General Public |
---|
22 | * License along with Blitz. If not, see <http://www.gnu.org/licenses/>. |
---|
23 | * |
---|
24 | * Suggestions: blitz-devel@lists.sourceforge.net |
---|
25 | * Bugs: blitz-support@lists.sourceforge.net |
---|
26 | * |
---|
27 | * For more information, please see the Blitz++ Home Page: |
---|
28 | * https://sourceforge.net/projects/blitz/ |
---|
29 | * |
---|
30 | ****************************************************************************/ |
---|
31 | |
---|
32 | /* |
---|
33 | * KNOWN BUGS |
---|
34 | * |
---|
35 | * 1. operator[](Vector<int>) won't match; compiler complains of no |
---|
36 | * suitable copy constructor for VectorPick<T> |
---|
37 | * 2. Vector<T>(_bz_VecExpr<E>) constructor generates warning |
---|
38 | * 3. operator+=,-=,..etc.(Random<D>) won't match; compiler complains of |
---|
39 | * no suitable copy constructor for _bz_VecExpr(...). |
---|
40 | */ |
---|
41 | |
---|
42 | #ifndef BZ_VECTOR_H |
---|
43 | #define BZ_VECTOR_H |
---|
44 | |
---|
45 | #include <blitz/blitz.h> |
---|
46 | #include <blitz/array.h> |
---|
47 | |
---|
48 | BZ_NAMESPACE(blitz) |
---|
49 | |
---|
50 | // Forward declarations |
---|
51 | // template<typename P_numtype> class VectorIter; |
---|
52 | // template<typename P_numtype> class VectorIterConst; |
---|
53 | // template<typename P_expr> class _bz_VecExpr; |
---|
54 | // template<typename P_numtype> class VectorPick; |
---|
55 | // template<typename P_numtype> class Random; |
---|
56 | |
---|
57 | // Declaration of class Vector<P_numtype>, which just is a rank-1 array. |
---|
58 | |
---|
59 | template<typename P_numtype> |
---|
60 | class Vector : public Array<P_numtype,1> |
---|
61 | { |
---|
62 | public: |
---|
63 | typedef Array<P_numtype,1> T_base; |
---|
64 | typedef typename T_base::T_numtype T_numtype; |
---|
65 | typedef typename T_base::T_index T_index; |
---|
66 | typedef typename T_base::T_array T_array; |
---|
67 | typedef typename T_base::T_iterator T_iterator; |
---|
68 | typedef typename T_base::iterator iterator; |
---|
69 | typedef typename T_base::const_iterator const_iterator; |
---|
70 | |
---|
71 | using T_base::rank_; |
---|
72 | |
---|
73 | template<typename T_expr> |
---|
74 | explicit Vector(_bz_ArrayExpr<T_expr> expr) : |
---|
75 | T_base(expr) {}; |
---|
76 | |
---|
77 | // forward constructors |
---|
78 | |
---|
79 | explicit Vector(int length0, |
---|
80 | GeneralArrayStorage<rank_> storage = GeneralArrayStorage<rank_>()) : |
---|
81 | T_base(length0, storage) {}; |
---|
82 | |
---|
83 | Vector(GeneralArrayStorage<rank_> storage = GeneralArrayStorage<rank_>()) : |
---|
84 | T_base(storage) {}; |
---|
85 | |
---|
86 | Vector(T_numtype* restrict dataFirst, TinyVector<int, rank_> shape, |
---|
87 | GeneralArrayStorage<rank_> storage = GeneralArrayStorage<rank_>()) : |
---|
88 | T_base(dataFirst, shape, storage) {}; |
---|
89 | |
---|
90 | Vector(Range r0, |
---|
91 | GeneralArrayStorage<rank_> storage = GeneralArrayStorage<rank_>()) : |
---|
92 | T_base(r0, storage) {}; |
---|
93 | |
---|
94 | Vector(const Array<T_numtype, rank_>& array) : T_base(array) {}; |
---|
95 | |
---|
96 | template<int N_rank2, typename R0, typename R1, typename R2, typename R3, typename R4, |
---|
97 | typename R5, typename R6, typename R7, typename R8, typename R9, typename R10> |
---|
98 | Vector(Array<T_numtype,N_rank2>& array, R0 r0, R1 r1, R2 r2, |
---|
99 | R3 r3, R4 r4, R5 r5, R6 r6, R7 r7, R8 r8, R9 r9, R10 r10) : |
---|
100 | T_base(array, r0,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10) {}; |
---|
101 | |
---|
102 | using T_base::operator=; |
---|
103 | |
---|
104 | }; |
---|
105 | |
---|
106 | |
---|
107 | BZ_NAMESPACE_END |
---|
108 | |
---|
109 | #endif // BZ_VECTOR_H |
---|