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 
59 #include <blaze/util/DisableIf.h>
60 #include <blaze/util/EnableIf.h>
62 #include <blaze/util/mpl/Or.h>
63 #include <blaze/util/Types.h>
64 
65 
66 namespace blaze {
67 
68 //=================================================================================================
69 //
70 // GLOBAL FUNCTION
71 //
72 //=================================================================================================
73 
74 //*************************************************************************************************
133 template< typename MT // Type of the dense matrix
134  , bool SO > // Storage order
135 inline typename SubmatrixExprTrait<MT,unaligned>::Type
136  submatrix( Matrix<MT,SO>& matrix, size_t row, size_t column, size_t m, size_t n )
137 {
139 
140  return submatrix<unaligned>( ~matrix, row, column, m, n );
141 }
142 //*************************************************************************************************
143 
144 
145 //*************************************************************************************************
204 template< typename MT // Type of the dense matrix
205  , bool SO > // Storage order
206 inline typename SubmatrixExprTrait<const MT,unaligned>::Type
207  submatrix( const Matrix<MT,SO>& matrix, size_t row, size_t column, size_t m, size_t n )
208 {
210 
211  return submatrix<unaligned>( ~matrix, row, column, m, n );
212 }
213 //*************************************************************************************************
214 
215 
216 //*************************************************************************************************
298 template< bool AF // Alignment flag
299  , typename MT // Type of the dense matrix
300  , bool SO > // Storage order
301 inline typename DisableIf< Or< IsComputation<MT>, IsTransExpr<MT> >
302  , typename SubmatrixExprTrait<MT,AF>::Type >::Type
303  submatrix( Matrix<MT,SO>& matrix, size_t row, size_t column, size_t m, size_t n )
304 {
306 
308  return ReturnType( ~matrix, row, column, m, n );
309 }
310 //*************************************************************************************************
311 
312 
313 //*************************************************************************************************
395 template< bool AF // Alignment flag
396  , typename MT // Type of the dense matrix
397  , bool SO > // Storage order
398 inline typename DisableIf< Or< IsComputation<MT>, IsTransExpr<MT> >
399  , typename SubmatrixExprTrait<const MT,AF>::Type >::Type
400  submatrix( const Matrix<MT,SO>& matrix, size_t row, size_t column, size_t m, size_t n )
401 {
403 
405  return ReturnType( ~matrix, row, column, m, n );
406 }
407 //*************************************************************************************************
408 
409 
410 
411 
412 //=================================================================================================
413 //
414 // GLOBAL RESTRUCTURING OPERATORS
415 //
416 //=================================================================================================
417 
418 //*************************************************************************************************
433 template< bool AF // Alignment flag
434  , typename MT // Type of the matrix
435  , bool SO > // Storage order
436 inline typename EnableIf< IsMatMatAddExpr<MT>, typename SubmatrixExprTrait<MT,AF>::Type >::Type
437  submatrix( const Matrix<MT,SO>& matrix, size_t row, size_t column, size_t m, size_t n )
438 {
440 
441  return submatrix<AF>( (~matrix).leftOperand() , row, column, m, n ) +
442  submatrix<AF>( (~matrix).rightOperand(), row, column, m, n );
443 }
445 //*************************************************************************************************
446 
447 
448 //*************************************************************************************************
463 template< bool AF // Alignment flag
464  , typename MT // Type of the matrix
465  , bool SO > // Storage order
466 inline typename EnableIf< IsMatMatSubExpr<MT>, typename SubmatrixExprTrait<MT,AF>::Type >::Type
467  submatrix( const Matrix<MT,SO>& matrix, size_t row, size_t column, size_t m, size_t n )
468 {
470 
471  return submatrix<AF>( (~matrix).leftOperand() , row, column, m, n ) -
472  submatrix<AF>( (~matrix).rightOperand(), row, column, m, n );
473 }
475 //*************************************************************************************************
476 
477 
478 //*************************************************************************************************
493 template< bool AF // Alignment flag
494  , typename MT // Type of the matrix
495  , bool SO > // Storage order
496 inline typename EnableIf< IsMatMatMultExpr<MT>, typename SubmatrixExprTrait<MT,AF>::Type >::Type
497  submatrix( const Matrix<MT,SO>& matrix, size_t row, size_t column, size_t m, size_t n )
498 {
500 
501  typename MT::LeftOperand left ( (~matrix).leftOperand() );
502  typename MT::RightOperand right( (~matrix).rightOperand() );
503 
504  return submatrix<AF>( left, row, 0UL, m, left.columns() ) *
505  submatrix<AF>( right, 0UL, column, right.rows(), n );
506 }
508 //*************************************************************************************************
509 
510 
511 //*************************************************************************************************
526 template< bool AF // Alignment flag
527  , typename MT // Type of the matrix
528  , bool SO > // Storage order
529 inline typename EnableIf< IsVecTVecMultExpr<MT>, typename SubmatrixExprTrait<MT,AF>::Type >::Type
530  submatrix( const Matrix<MT,SO>& matrix, size_t row, size_t column, size_t m, size_t n )
531 {
533 
534  return subvector<AF>( (~matrix).leftOperand(), row, m ) *
535  subvector<AF>( (~matrix).rightOperand(), column, n );
536 }
538 //*************************************************************************************************
539 
540 
541 //*************************************************************************************************
556 template< bool AF // Alignment flag
557  , typename MT // Type of the matrix
558  , bool SO > // Storage order
559 inline typename EnableIf< IsMatScalarMultExpr<MT>, typename SubmatrixExprTrait<MT,AF>::Type >::Type
560  submatrix( const Matrix<MT,SO>& matrix, size_t row, size_t column, size_t m, size_t n )
561 {
563 
564  return submatrix<AF>( (~matrix).leftOperand(), row, column, m, n ) * (~matrix).rightOperand();
565 }
567 //*************************************************************************************************
568 
569 
570 //*************************************************************************************************
585 template< bool AF // Alignment flag
586  , typename MT // Type of the matrix
587  , bool SO > // Storage order
588 inline typename EnableIf< IsMatScalarDivExpr<MT>, typename SubmatrixExprTrait<MT,AF>::Type >::Type
589  submatrix( const Matrix<MT,SO>& matrix, size_t row, size_t column, size_t m, size_t n )
590 {
592 
593  return submatrix<AF>( (~matrix).leftOperand(), row, column, m, n ) / (~matrix).rightOperand();
594 }
596 //*************************************************************************************************
597 
598 
599 //*************************************************************************************************
614 template< bool AF // Alignment flag
615  , typename MT // Type of the matrix
616  , bool SO > // Storage order
617 inline typename EnableIf< IsMatAbsExpr<MT>, typename SubmatrixExprTrait<MT,AF>::Type >::Type
618  submatrix( const Matrix<MT,SO>& matrix, size_t row, size_t column, size_t m, size_t n )
619 {
621 
622  return abs( submatrix<AF>( (~matrix).operand(), row, column, m, n ) );
623 }
625 //*************************************************************************************************
626 
627 
628 //*************************************************************************************************
643 template< bool AF // Alignment flag
644  , typename MT // Type of the matrix
645  , bool SO > // Storage order
646 inline typename EnableIf< IsMatEvalExpr<MT>, typename SubmatrixExprTrait<MT,AF>::Type >::Type
647  submatrix( const Matrix<MT,SO>& matrix, size_t row, size_t column, size_t m, size_t n )
648 {
650 
651  return eval( submatrix<AF>( (~matrix).operand(), row, column, m, n ) );
652 }
654 //*************************************************************************************************
655 
656 
657 //*************************************************************************************************
672 template< bool AF // Alignment flag
673  , typename MT // Type of the matrix
674  , bool SO > // Storage order
675 inline typename EnableIf< IsMatSerialExpr<MT>, typename SubmatrixExprTrait<MT,AF>::Type >::Type
676  submatrix( const Matrix<MT,SO>& matrix, size_t row, size_t column, size_t m, size_t n )
677 {
679 
680  return serial( submatrix<AF>( (~matrix).operand(), row, column, m, n ) );
681 }
683 //*************************************************************************************************
684 
685 
686 //*************************************************************************************************
701 template< bool AF // Alignment flag
702  , typename MT // Type of the matrix
703  , bool SO > // Storage order
704 inline typename EnableIf< IsMatTransExpr<MT>, typename SubmatrixExprTrait<MT,AF>::Type >::Type
705  submatrix( const Matrix<MT,SO>& matrix, size_t row, size_t column, size_t m, size_t n )
706 {
708 
709  return trans( submatrix<AF>( (~matrix).operand(), column, row, n, m ) );
710 }
712 //*************************************************************************************************
713 
714 } // namespace blaze
715 
716 #endif
Header file for the subvector/submatrix alignment flag values.
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:903
Header file for the IsTransExpr type trait class.
const DMatSerialExpr< MT, SO > serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:690
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 IsMatSerialExpr 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.
Header file for the serial shim.
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:2407
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:672
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:136
const DMatTransExpr< MT,!SO > trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:907
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.