All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Submatrix.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_VIEWS_SUBMATRIX_H_
36 #define _BLAZE_MATH_VIEWS_SUBMATRIX_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
54 #include <blaze/util/EnableIf.h>
56 #include <blaze/util/Types.h>
57 
58 
59 namespace blaze {
60 
61 //=================================================================================================
62 //
63 // GLOBAL RESTRUCTURING OPERATORS
64 //
65 //=================================================================================================
66 
67 //*************************************************************************************************
82 template< typename MT // Type of the matrix
83  , bool SO > // Storage order
84 inline typename EnableIf< IsMatMatAddExpr<MT>, typename SubmatrixExprTrait<MT>::Type >::Type
85  submatrix( const Matrix<MT,SO>& matrix, size_t row, size_t column, size_t m, size_t n )
86 {
88 
89  return submatrix( (~matrix).leftOperand() , row, column, m, n ) +
90  submatrix( (~matrix).rightOperand(), row, column, m, n );
91 }
93 //*************************************************************************************************
94 
95 
96 //*************************************************************************************************
111 template< typename MT // Type of the matrix
112  , bool SO > // Storage order
113 inline typename EnableIf< IsMatMatSubExpr<MT>, typename SubmatrixExprTrait<MT>::Type >::Type
114  submatrix( const Matrix<MT,SO>& matrix, size_t row, size_t column, size_t m, size_t n )
115 {
117 
118  return submatrix( (~matrix).leftOperand() , row, column, m, n ) -
119  submatrix( (~matrix).rightOperand(), row, column, m, n );
120 }
122 //*************************************************************************************************
123 
124 
125 //*************************************************************************************************
140 template< typename MT // Type of the matrix
141  , bool SO > // Storage order
142 inline typename EnableIf< IsMatMatMultExpr<MT>, typename SubmatrixExprTrait<MT>::Type >::Type
143  submatrix( const Matrix<MT,SO>& matrix, size_t row, size_t column, size_t m, size_t n )
144 {
146 
147  typename MT::LeftOperand left ( (~matrix).leftOperand() );
148  typename MT::RightOperand right( (~matrix).rightOperand() );
149 
150  return submatrix( left, row, 0UL, m, left.columns() ) * submatrix( right, 0UL, column, right.rows(), n );
151 }
153 //*************************************************************************************************
154 
155 
156 //*************************************************************************************************
171 template< typename MT // Type of the matrix
172  , bool SO > // Storage order
173 inline typename EnableIf< IsVecTVecMultExpr<MT>, typename SubmatrixExprTrait<MT>::Type >::Type
174  submatrix( const Matrix<MT,SO>& matrix, size_t row, size_t column, size_t m, size_t n )
175 {
177 
178  return subvector( (~matrix).leftOperand(), row, m ) * subvector( (~matrix).rightOperand(), column, n );
179 }
181 //*************************************************************************************************
182 
183 
184 //*************************************************************************************************
199 template< typename MT // Type of the matrix
200  , bool SO > // Storage order
201 inline typename EnableIf< IsMatScalarMultExpr<MT>, typename SubmatrixExprTrait<MT>::Type >::Type
202  submatrix( const Matrix<MT,SO>& matrix, size_t row, size_t column, size_t m, size_t n )
203 {
205 
206  return submatrix( (~matrix).leftOperand(), row, column, m, n ) * (~matrix).rightOperand();
207 }
209 //*************************************************************************************************
210 
211 
212 //*************************************************************************************************
227 template< typename MT // Type of the matrix
228  , bool SO > // Storage order
229 inline typename EnableIf< IsMatScalarDivExpr<MT>, typename SubmatrixExprTrait<MT>::Type >::Type
230  submatrix( const Matrix<MT,SO>& matrix, size_t row, size_t column, size_t m, size_t n )
231 {
233 
234  return submatrix( (~matrix).leftOperand(), row, column, m, n ) / (~matrix).rightOperand();
235 }
237 //*************************************************************************************************
238 
239 
240 //*************************************************************************************************
255 template< typename MT // Type of the matrix
256  , bool SO > // Storage order
257 inline typename EnableIf< IsMatAbsExpr<MT>, typename SubmatrixExprTrait<MT>::Type >::Type
258  submatrix( const Matrix<MT,SO>& matrix, size_t row, size_t column, size_t m, size_t n )
259 {
261 
262  return abs( submatrix( (~matrix).operand(), row, column, m, n ) );
263 }
265 //*************************************************************************************************
266 
267 
268 //*************************************************************************************************
283 template< typename MT // Type of the matrix
284  , bool SO > // Storage order
285 inline typename EnableIf< IsMatEvalExpr<MT>, typename SubmatrixExprTrait<MT>::Type >::Type
286  submatrix( const Matrix<MT,SO>& matrix, size_t row, size_t column, size_t m, size_t n )
287 {
289 
290  return eval( submatrix( (~matrix).operand(), row, column, m, n ) );
291 }
293 //*************************************************************************************************
294 
295 
296 //*************************************************************************************************
311 template< typename MT // Type of the matrix
312  , bool SO > // Storage order
313 inline typename EnableIf< IsMatTransExpr<MT>, typename SubmatrixExprTrait<MT>::Type >::Type
314  submatrix( const Matrix<MT,SO>& matrix, size_t row, size_t column, size_t m, size_t n )
315 {
317 
318  return trans( submatrix( (~matrix).operand(), column, row, n, m ) );
319 }
321 //*************************************************************************************************
322 
323 } // namespace blaze
324 
325 #endif
DisableIf< Or< IsComputation< MT >, IsTransExpr< MT > >, DenseColumn< MT > >::Type column(DenseMatrix< MT, SO > &dm, size_t index)
Creating a view on a specific column of the given dense matrix.
Definition: DenseColumn.h:3026
const DMatTransExpr< MT,!SO > trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:446
const DMatAbsExpr< MT, SO > abs(const DenseMatrix< MT, SO > &dm)
Returns a matrix containing the absolute values of each single element of dm.
Definition: DMatAbsExpr.h:739
Header file for the IsMatMatAddExpr type trait class.
Header file for the IsMatTransExpr type trait class.
Header file for the IsMatAbsExpr type trait class.
Header file for the IsVecTVecMultExpr type trait class.
Header file for the IsMatMatMultExpr type trait class.
Header file for the IsMatScalarMultExpr type trait class.
Header file for the IsMatEvalExpr type trait class.
Header file for the EnableIf class template.
Header file for the Matrix base class.
Header file for the SubmatrixExprTrait class template.
Header file for the IsMatScalarDivExpr type trait class.
DisableIf< Or< IsComputation< MT >, IsTransExpr< MT > >, DenseRow< MT > >::Type row(DenseMatrix< MT, SO > &dm, size_t index)
Creating a view on a specific row of the given dense matrix.
Definition: DenseRow.h:3025
const DMatEvalExpr< MT, SO > eval(const DenseMatrix< MT, SO > &dm)
Forces the evaluation of the given dense matrix expression dm.
Definition: DMatEvalExpr.h:395
Header file for the IsMatMatSubExpr type trait class.
#define BLAZE_FUNCTION_TRACE
Function trace macro.This macro can be used to reliably trace function calls. In case function tracin...
Definition: FunctionTrace.h:157
Header file for basic type definitions.
DisableIf< Or< IsComputation< MT >, IsTransExpr< MT > >, DenseSubmatrix< MT > >::Type submatrix(DenseMatrix< MT, SO > &dm, size_t row, size_t column, size_t m, size_t n)
Creating a view on a specific submatrix of the given dense matrix.
Definition: DenseSubmatrix.h:4412
DisableIf< Or< IsComputation< VT >, IsTransExpr< VT > >, DenseSubvector< VT > >::Type subvector(DenseVector< VT, TF > &dv, size_t index, size_t size)
Creating a view on a specific subvector of the given dense vector.
Definition: DenseSubvector.h:2616
Header file for the FunctionTrace class.