1 /*
2 * Copyright (c) 2007, Michael Lehn
3 *
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * 1) Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2) Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
16 * 3) Neither the name of the FLENS development group nor the names of
17 * its contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 #ifndef FLENS_MATRIXTYPES_HERMITIAN_IMPL_HEMATRIX_H
34 #define FLENS_MATRIXTYPES_HERMITIAN_IMPL_HEMATRIX_H 1
35
36 #include <cxxblas/typedefs.h>
37 #include <flens/typedefs.h>
38 #include <flens/matrixtypes/hermitian/hermitianmatrix.h>
39
40 namespace flens {
41
42 // forward declarations
43 template <typename FS>
44 class GeMatrix;
45
46 template <typename FS>
47 class SyMatrix;
48
49 template <typename FS>
50 class TrMatrix;
51
52 template <typename FS>
53 class HeMatrix
54 : public HermitianMatrix<HeMatrix<FS> >
55 {
56 public:
57 typedef FS Engine;
58 typedef typename Engine::ElementType ElementType;
59 typedef typename Engine::IndexType IndexType;
60
61 // view types from Engine
62 typedef typename Engine::ConstView EngineConstView;
63 typedef typename Engine::View EngineView;
64 typedef typename Engine::NoView EngineNoView;
65
66 typedef typename Engine::ConstArrayView ConstArrayView;
67 typedef typename Engine::ArrayView ArrayView;
68 typedef typename Engine::Array Array;
69
70 // view types
71 typedef DenseVector<ConstArrayView> ConstVectorView;
72 typedef DenseVector<ArrayView> VectorView;
73 typedef DenseVector<Array> Vector;
74
75 typedef GeMatrix<EngineConstView> ConstGeneralView;
76 typedef GeMatrix<EngineView> GeneralView;
77 typedef GeMatrix<EngineNoView> GeneralNoView;
78
79 typedef HeMatrix<EngineConstView> ConstView;
80 typedef HeMatrix<EngineView> View;
81 typedef HeMatrix<EngineNoView> NoView;
82
83 typedef SyMatrix<EngineConstView> ConstSymmetricView;
84 typedef SyMatrix<EngineView> SymmetricView;
85 typedef SyMatrix<EngineNoView> SymmetricNoView;
86
87 typedef TrMatrix<EngineConstView> ConstTriangularView;
88 typedef TrMatrix<EngineView> TriangularView;
89 typedef TrMatrix<EngineNoView> TriangularNoView;
90
91 HeMatrix();
92
93 explicit
94 HeMatrix(IndexType dim);
95
96 HeMatrix(IndexType dim,
97 IndexType firstRow, IndexType firstCol);
98
99 HeMatrix(const Engine &engine, StorageUpLo upLo);
100
101 HeMatrix(const HeMatrix &rhs);
102
103 template <typename RHS>
104 HeMatrix(const HeMatrix<RHS> &rhs);
105
106 template <typename RHS>
107 HeMatrix(HeMatrix<RHS> &rhs);
108
109 template <typename RHS>
110 HeMatrix(const Matrix<RHS> &rhs);
111
112 // -- operators --------------------------------------------------------
113
114 const ElementType &
115 operator()(IndexType row, IndexType col) const;
116
117 ElementType &
118 operator()(IndexType row, IndexType col);
119
120 // -- views ------------------------------------------------------------
121
122 // general views
123 ConstGeneralView
124 general() const;
125
126 GeneralView
127 general();
128
129 // -- methods ----------------------------------------------------------
130
131 IndexType
132 dim() const;
133
134 IndexType
135 firstRow() const;
136
137 IndexType
138 lastRow() const;
139
140 IndexType
141 firstCol() const;
142
143 IndexType
144 lastCol() const;
145
146 const ElementType *
147 data() const;
148
149 ElementType *
150 data();
151
152 IndexType
153 leadingDimension() const;
154
155 // -- implementation ---------------------------------------------------
156
157 const Engine &
158 engine() const;
159
160 Engine &
161 engine();
162
163 StorageUpLo
164 upLo() const;
165
166 StorageUpLo &
167 upLo();
168
169 private:
170 Engine _engine;
171 StorageUpLo _upLo;
172 };
173
174 } // namespace flens
175
176 #endif // FLENS_MATRIXTYPES_HERMITIAN_IMPL_HEMATRIX_H
2 * Copyright (c) 2007, Michael Lehn
3 *
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * 1) Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2) Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
16 * 3) Neither the name of the FLENS development group nor the names of
17 * its contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 #ifndef FLENS_MATRIXTYPES_HERMITIAN_IMPL_HEMATRIX_H
34 #define FLENS_MATRIXTYPES_HERMITIAN_IMPL_HEMATRIX_H 1
35
36 #include <cxxblas/typedefs.h>
37 #include <flens/typedefs.h>
38 #include <flens/matrixtypes/hermitian/hermitianmatrix.h>
39
40 namespace flens {
41
42 // forward declarations
43 template <typename FS>
44 class GeMatrix;
45
46 template <typename FS>
47 class SyMatrix;
48
49 template <typename FS>
50 class TrMatrix;
51
52 template <typename FS>
53 class HeMatrix
54 : public HermitianMatrix<HeMatrix<FS> >
55 {
56 public:
57 typedef FS Engine;
58 typedef typename Engine::ElementType ElementType;
59 typedef typename Engine::IndexType IndexType;
60
61 // view types from Engine
62 typedef typename Engine::ConstView EngineConstView;
63 typedef typename Engine::View EngineView;
64 typedef typename Engine::NoView EngineNoView;
65
66 typedef typename Engine::ConstArrayView ConstArrayView;
67 typedef typename Engine::ArrayView ArrayView;
68 typedef typename Engine::Array Array;
69
70 // view types
71 typedef DenseVector<ConstArrayView> ConstVectorView;
72 typedef DenseVector<ArrayView> VectorView;
73 typedef DenseVector<Array> Vector;
74
75 typedef GeMatrix<EngineConstView> ConstGeneralView;
76 typedef GeMatrix<EngineView> GeneralView;
77 typedef GeMatrix<EngineNoView> GeneralNoView;
78
79 typedef HeMatrix<EngineConstView> ConstView;
80 typedef HeMatrix<EngineView> View;
81 typedef HeMatrix<EngineNoView> NoView;
82
83 typedef SyMatrix<EngineConstView> ConstSymmetricView;
84 typedef SyMatrix<EngineView> SymmetricView;
85 typedef SyMatrix<EngineNoView> SymmetricNoView;
86
87 typedef TrMatrix<EngineConstView> ConstTriangularView;
88 typedef TrMatrix<EngineView> TriangularView;
89 typedef TrMatrix<EngineNoView> TriangularNoView;
90
91 HeMatrix();
92
93 explicit
94 HeMatrix(IndexType dim);
95
96 HeMatrix(IndexType dim,
97 IndexType firstRow, IndexType firstCol);
98
99 HeMatrix(const Engine &engine, StorageUpLo upLo);
100
101 HeMatrix(const HeMatrix &rhs);
102
103 template <typename RHS>
104 HeMatrix(const HeMatrix<RHS> &rhs);
105
106 template <typename RHS>
107 HeMatrix(HeMatrix<RHS> &rhs);
108
109 template <typename RHS>
110 HeMatrix(const Matrix<RHS> &rhs);
111
112 // -- operators --------------------------------------------------------
113
114 const ElementType &
115 operator()(IndexType row, IndexType col) const;
116
117 ElementType &
118 operator()(IndexType row, IndexType col);
119
120 // -- views ------------------------------------------------------------
121
122 // general views
123 ConstGeneralView
124 general() const;
125
126 GeneralView
127 general();
128
129 // -- methods ----------------------------------------------------------
130
131 IndexType
132 dim() const;
133
134 IndexType
135 firstRow() const;
136
137 IndexType
138 lastRow() const;
139
140 IndexType
141 firstCol() const;
142
143 IndexType
144 lastCol() const;
145
146 const ElementType *
147 data() const;
148
149 ElementType *
150 data();
151
152 IndexType
153 leadingDimension() const;
154
155 // -- implementation ---------------------------------------------------
156
157 const Engine &
158 engine() const;
159
160 Engine &
161 engine();
162
163 StorageUpLo
164 upLo() const;
165
166 StorageUpLo &
167 upLo();
168
169 private:
170 Engine _engine;
171 StorageUpLo _upLo;
172 };
173
174 } // namespace flens
175
176 #endif // FLENS_MATRIXTYPES_HERMITIAN_IMPL_HEMATRIX_H