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 
57 #include <blaze/util/DisableIf.h>
58 #include <blaze/util/EnableIf.h>
60 #include <blaze/util/mpl/Or.h>
61 #include <blaze/util/Types.h>
62 
63 
64 namespace blaze {
65 
66 //=================================================================================================
67 //
68 // GLOBAL FUNCTION
69 //
70 //=================================================================================================
71 
72 //*************************************************************************************************
131 template< typename MT // Type of the dense matrix
132  , bool SO > // Storage order
133 inline typename SubmatrixExprTrait<MT,unaligned>::Type
134  submatrix( Matrix<MT,SO>& matrix, size_t row, size_t column, size_t m, size_t n )
135 {
137 
138  return submatrix<unaligned>( ~matrix, row, column, m, n );
139 }
140 //*************************************************************************************************
141 
142 
143 //*************************************************************************************************
202 template< typename MT // Type of the dense matrix
203  , bool SO > // Storage order
204 inline typename SubmatrixExprTrait<const MT,unaligned>::Type
205  submatrix( const Matrix<MT,SO>& matrix, size_t row, size_t column, size_t m, size_t n )
206 {
208 
209  return submatrix<unaligned>( ~matrix, row, column, m, n );
210 }
211 //*************************************************************************************************
212 
213 
214 //*************************************************************************************************
296 template< bool AF // Alignment flag
297  , typename MT // Type of the dense matrix
298  , bool SO > // Storage order
299 inline typename DisableIf< Or< IsComputation<MT>, IsTransExpr<MT> >
300  , typename SubmatrixExprTrait<MT,AF>::Type >::Type
301  submatrix( Matrix<MT,SO>& matrix, size_t row, size_t column, size_t m, size_t n )
302 {
304 
306  return ReturnType( ~matrix, row, column, m, n );
307 }
308 //*************************************************************************************************
309 
310 
311 //*************************************************************************************************
393 template< bool AF // Alignment flag
394  , typename MT // Type of the dense matrix
395  , bool SO > // Storage order
396 inline typename DisableIf< Or< IsComputation<MT>, IsTransExpr<MT> >
397  , typename SubmatrixExprTrait<const MT,AF>::Type >::Type
398  submatrix( const Matrix<MT,SO>& matrix, size_t row, size_t column, size_t m, size_t n )
399 {
401 
403  return ReturnType( ~matrix, row, column, m, n );
404 }
405 //*************************************************************************************************
406 
407 
408 
409 
410 //=================================================================================================
411 //
412 // GLOBAL RESTRUCTURING OPERATORS
413 //
414 //=================================================================================================
415 
416 //*************************************************************************************************
431 template< bool AF // Alignment flag
432  , typename MT // Type of the matrix
433  , bool SO > // Storage order
434 inline typename EnableIf< IsMatMatAddExpr<MT>, typename SubmatrixExprTrait<MT,AF>::Type >::Type
435  submatrix( const Matrix<MT,SO>& matrix, size_t row, size_t column, size_t m, size_t n )
436 {
438 
439  return submatrix<AF>( (~matrix).leftOperand() , row, column, m, n ) +
440  submatrix<AF>( (~matrix).rightOperand(), row, column, m, n );
441 }
443 //*************************************************************************************************
444 
445 
446 //*************************************************************************************************
461 template< bool AF // Alignment flag
462  , typename MT // Type of the matrix
463  , bool SO > // Storage order
464 inline typename EnableIf< IsMatMatSubExpr<MT>, typename SubmatrixExprTrait<MT,AF>::Type >::Type
465  submatrix( const Matrix<MT,SO>& matrix, size_t row, size_t column, size_t m, size_t n )
466 {
468 
469  return submatrix<AF>( (~matrix).leftOperand() , row, column, m, n ) -
470  submatrix<AF>( (~matrix).rightOperand(), row, column, m, n );
471 }
473 //*************************************************************************************************
474 
475 
476 //*************************************************************************************************
491 template< bool AF // Alignment flag
492  , typename MT // Type of the matrix
493  , bool SO > // Storage order
494 inline typename EnableIf< IsMatMatMultExpr<MT>, typename SubmatrixExprTrait<MT,AF>::Type >::Type
495  submatrix( const Matrix<MT,SO>& matrix, size_t row, size_t column, size_t m, size_t n )
496 {
498 
499  typename MT::LeftOperand left ( (~matrix).leftOperand() );
500  typename MT::RightOperand right( (~matrix).rightOperand() );
501 
502  return submatrix<AF>( left, row, 0UL, m, left.columns() ) *
503  submatrix<AF>( right, 0UL, column, right.rows(), n );
504 }
506 //*************************************************************************************************
507 
508 
509 //*************************************************************************************************
524 template< bool AF // Alignment flag
525  , typename MT // Type of the matrix
526  , bool SO > // Storage order
527 inline typename EnableIf< IsVecTVecMultExpr<MT>, typename SubmatrixExprTrait<MT,AF>::Type >::Type
528  submatrix( const Matrix<MT,SO>& matrix, size_t row, size_t column, size_t m, size_t n )
529 {
531 
532  return subvector<AF>( (~matrix).leftOperand(), row, m ) *
533  subvector<AF>( (~matrix).rightOperand(), column, n );
534 }
536 //*************************************************************************************************
537 
538 
539 //*************************************************************************************************
554 template< bool AF // Alignment flag
555  , typename MT // Type of the matrix
556  , bool SO > // Storage order
557 inline typename EnableIf< IsMatScalarMultExpr<MT>, typename SubmatrixExprTrait<MT,AF>::Type >::Type
558  submatrix( const Matrix<MT,SO>& matrix, size_t row, size_t column, size_t m, size_t n )
559 {
561 
562  return submatrix<AF>( (~matrix).leftOperand(), row, column, m, n ) * (~matrix).rightOperand();
563 }
565 //*************************************************************************************************
566 
567 
568 //*************************************************************************************************
583 template< bool AF // Alignment flag
584  , typename MT // Type of the matrix
585  , bool SO > // Storage order
586 inline typename EnableIf< IsMatScalarDivExpr<MT>, typename SubmatrixExprTrait<MT,AF>::Type >::Type
587  submatrix( const Matrix<MT,SO>& matrix, size_t row, size_t column, size_t m, size_t n )
588 {
590 
591  return submatrix<AF>( (~matrix).leftOperand(), row, column, m, n ) / (~matrix).rightOperand();
592 }
594 //*************************************************************************************************
595 
596 
597 //*************************************************************************************************
612 template< bool AF // Alignment flag
613  , typename MT // Type of the matrix
614  , bool SO > // Storage order
615 inline typename EnableIf< IsMatAbsExpr<MT>, typename SubmatrixExprTrait<MT,AF>::Type >::Type
616  submatrix( const Matrix<MT,SO>& matrix, size_t row, size_t column, size_t m, size_t n )
617 {
619 
620  return abs( submatrix<AF>( (~matrix).operand(), row, column, m, n ) );
621 }
623 //*************************************************************************************************
624 
625 
626 //*************************************************************************************************
641 template< bool AF // Alignment flag
642  , typename MT // Type of the matrix
643  , bool SO > // Storage order
644 inline typename EnableIf< IsMatEvalExpr<MT>, typename SubmatrixExprTrait<MT,AF>::Type >::Type
645  submatrix( const Matrix<MT,SO>& matrix, size_t row, size_t column, size_t m, size_t n )
646 {
648 
649  return eval( submatrix<AF>( (~matrix).operand(), row, column, m, n ) );
650 }
652 //*************************************************************************************************
653 
654 
655 //*************************************************************************************************
670 template< bool AF // Alignment flag
671  , typename MT // Type of the matrix
672  , bool SO > // Storage order
673 inline typename EnableIf< IsMatTransExpr<MT>, typename SubmatrixExprTrait<MT,AF>::Type >::Type
674  submatrix( const Matrix<MT,SO>& matrix, size_t row, size_t column, size_t m, size_t n )
675 {
677 
678  return trans( submatrix<AF>( (~matrix).operand(), column, row, n, m ) );
679 }
681 //*************************************************************************************************
682 
683 } // namespace blaze
684 
685 #endif
Header file for the subvector/submatrix alignment flag values.
const DMatTransExpr< MT,!SO > trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:751
DisableIf< Or< IsComputation< MT >, IsTransExpr< MT > >, typename ColumnExprTrait< MT >::Type >::Type column(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific column of the given matrix.
Definition: Column.h:103
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:764
Header file for the IsTransExpr type trait class.
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 DisableIf class template.
Header file for the IsVecTVecMultExpr type trait class.
Header file for the Or class template.
Header file for the IsMatMatMultExpr type trait class.
Header file for the IsMatScalarMultExpr type trait class.
Evaluation of the expression type type of a submatrix operation.Via this type trait it is possible to...
Definition: SubmatrixExprTrait.h:78
Header file for the IsMatEvalExpr type trait class.
Header file for the EnableIf class template.
DisableIf< Or< IsComputation< MT >, IsTransExpr< MT > >, typename RowExprTrait< MT >::Type >::Type row(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific row of the given matrix.
Definition: Row.h:103
Header file for the Matrix base class.
Header file for the SubmatrixExprTrait class template.
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2383
Header file for the IsMatScalarDivExpr type trait class.
const DMatEvalExpr< MT, SO > eval(const DenseMatrix< MT, SO > &dm)
Forces the evaluation of the given dense matrix expression dm.
Definition: DMatEvalExpr.h:584
Header file for the IsMatMatSubExpr type trait class.
SubmatrixExprTrait< MT, unaligned >::Type submatrix(Matrix< MT, SO > &matrix, size_t row, size_t column, size_t m, size_t n)
Creating a view on a specific submatrix of the given matrix.
Definition: Submatrix.h:134
Header file for the IsComputation 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.
Header file for the FunctionTrace class.