Blaze  3.6
SubmatrixData.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_VIEWS_SUBMATRIX_SUBMATRIXDATA_H_
36 #define _BLAZE_MATH_VIEWS_SUBMATRIX_SUBMATRIXDATA_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <blaze/util/MaybeUnused.h>
44 #include <blaze/util/Types.h>
45 
46 
47 namespace blaze {
48 
49 //=================================================================================================
50 //
51 // CLASS DEFINITION
52 //
53 //=================================================================================================
54 
55 //*************************************************************************************************
63 template< size_t... CSAs > // Compile time submatrix arguments
65 {};
66 //*************************************************************************************************
67 
68 
69 
70 
71 //=================================================================================================
72 //
73 // CLASS TEMPLATE SPECIALIZATION FOR ZERO COMPILE TIME ARGUMENTS
74 //
75 //=================================================================================================
76 
77 //*************************************************************************************************
86 template<>
87 class SubmatrixData<>
88 {
89  public:
90  //**Compile time flags**************************************************************************
92 
96  static constexpr bool compileTimeArgs = false;
97  //**********************************************************************************************
98 
99  //**Constructors********************************************************************************
102  template< typename... RSAs >
103  explicit inline SubmatrixData( size_t rindex, size_t cindex, size_t m, size_t n, RSAs... args );
104 
105  SubmatrixData( const SubmatrixData& ) = default;
107  //**********************************************************************************************
108 
109  //**Destructor**********************************************************************************
112  ~SubmatrixData() = default;
114  //**********************************************************************************************
115 
116  //**Assignment operators************************************************************************
119  SubmatrixData& operator=( const SubmatrixData& ) = delete;
121  //**********************************************************************************************
122 
123  //**Utility functions***************************************************************************
126  inline size_t row () const noexcept;
127  inline size_t column () const noexcept;
128  inline size_t rows () const noexcept;
129  inline size_t columns() const noexcept;
131  //**********************************************************************************************
132 
133  private:
134  //**Member variables****************************************************************************
137  const size_t row_;
138  const size_t column_;
139  const size_t m_;
140  const size_t n_;
141 
142  //**********************************************************************************************
143 };
145 //*************************************************************************************************
146 
147 
148 //*************************************************************************************************
158 template< typename... RSAs > // Optional submatrix arguments
159 inline SubmatrixData<>::SubmatrixData( size_t rindex, size_t cindex, size_t m, size_t n, RSAs... args )
160  : row_ ( rindex ) // The first row of the submatrix
161  , column_( cindex ) // The first column of the submatrix
162  , m_ ( m ) // The number of rows of the submatrix
163  , n_ ( n ) // The number of columns of the submatrix
164 {
165  MAYBE_UNUSED( args... );
166 }
168 //*************************************************************************************************
169 
170 
171 //*************************************************************************************************
177 inline size_t SubmatrixData<>::row() const noexcept
178 {
179  return row_;
180 }
182 //*************************************************************************************************
183 
184 
185 //*************************************************************************************************
191 inline size_t SubmatrixData<>::column() const noexcept
192 {
193  return column_;
194 }
196 //*************************************************************************************************
197 
198 
199 //*************************************************************************************************
205 inline size_t SubmatrixData<>::rows() const noexcept
206 {
207  return m_;
208 }
210 //*************************************************************************************************
211 
212 
213 //*************************************************************************************************
219 inline size_t SubmatrixData<>::columns() const noexcept
220 {
221  return n_;
222 }
224 //*************************************************************************************************
225 
226 
227 
228 
229 //=================================================================================================
230 //
231 // CLASS TEMPLATE SPECIALIZATION FOR FOUR COMPILE TIME ARGUMENTS
232 //
233 //=================================================================================================
234 
235 //*************************************************************************************************
244 template< size_t I // Index of the first row
245  , size_t J // Index of the first column
246  , size_t M // Number of rows
247  , size_t N > // Number of columns
248 class SubmatrixData<I,J,M,N>
249 {
250  public:
251  //**Compile time flags**************************************************************************
253 
257  static constexpr bool compileTimeArgs = true;
258  //**********************************************************************************************
259 
260  //**Constructors********************************************************************************
263  template< typename... RSAs >
264  explicit inline SubmatrixData( RSAs... args );
265 
266  SubmatrixData( const SubmatrixData& ) = default;
268  //**********************************************************************************************
269 
270  //**Destructor**********************************************************************************
273  ~SubmatrixData() = default;
275  //**********************************************************************************************
276 
277  //**Assignment operators************************************************************************
280  SubmatrixData& operator=( const SubmatrixData& ) = delete;
282  //**********************************************************************************************
283 
284  //**Utility functions***************************************************************************
287  static inline constexpr size_t row () noexcept;
288  static inline constexpr size_t column () noexcept;
289  static inline constexpr size_t rows () noexcept;
290  static inline constexpr size_t columns() noexcept;
292  //**********************************************************************************************
293 };
295 //*************************************************************************************************
296 
297 
298 //*************************************************************************************************
304 template< size_t I // Index of the first row
305  , size_t J // Index of the first column
306  , size_t M // Number of rows
307  , size_t N > // Number of columns
308 template< typename... RSAs > // Optional submatrix arguments
309 inline SubmatrixData<I,J,M,N>::SubmatrixData( RSAs... args )
310 {
311  MAYBE_UNUSED( args... );
312 }
314 //*************************************************************************************************
315 
316 
317 //*************************************************************************************************
323 template< size_t I // Index of the first row
324  , size_t J // Index of the first column
325  , size_t M // Number of rows
326  , size_t N > // Number of columns
327 inline constexpr size_t SubmatrixData<I,J,M,N>::row() noexcept
328 {
329  return I;
330 }
332 //*************************************************************************************************
333 
334 
335 //*************************************************************************************************
341 template< size_t I // Index of the first row
342  , size_t J // Index of the first column
343  , size_t M // Number of rows
344  , size_t N > // Number of columns
345 inline constexpr size_t SubmatrixData<I,J,M,N>::column() noexcept
346 {
347  return J;
348 }
350 //*************************************************************************************************
351 
352 
353 //*************************************************************************************************
359 template< size_t I // Index of the first row
360  , size_t J // Index of the first column
361  , size_t M // Number of rows
362  , size_t N > // Number of columns
363 inline constexpr size_t SubmatrixData<I,J,M,N>::rows() noexcept
364 {
365  return M;
366 }
368 //*************************************************************************************************
369 
370 
371 //*************************************************************************************************
377 template< size_t I // Index of the first row
378  , size_t J // Index of the first column
379  , size_t M // Number of rows
380  , size_t N > // Number of columns
381 inline constexpr size_t SubmatrixData<I,J,M,N>::columns() noexcept
382 {
383  return N;
384 }
386 //*************************************************************************************************
387 
388 } // namespace blaze
389 
390 #endif
decltype(auto) column(Matrix< MT, SO > &matrix, RCAs... args)
Creating a view on a specific column of the given matrix.
Definition: Column.h:133
Header file for basic type definitions.
Header file for the MAYBE_UNUSED function template.
constexpr size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:514
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
constexpr void MAYBE_UNUSED(const Args &...)
Suppression of unused parameter warnings.
Definition: MaybeUnused.h:81
decltype(auto) row(Matrix< MT, SO > &, RRAs...)
Creating a view on a specific row of the given matrix.
Definition: Row.h:133
constexpr size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:498
Auxiliary class template for the data members of the Submatrix class.The auxiliary SubmatrixData clas...
Definition: SubmatrixData.h:64