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 
60 #include <blaze/util/DisableIf.h>
61 #include <blaze/util/EnableIf.h>
63 #include <blaze/util/mpl/Or.h>
64 #include <blaze/util/Types.h>
65 
66 
67 namespace blaze {
68 
69 //=================================================================================================
70 //
71 // GLOBAL FUNCTION
72 //
73 //=================================================================================================
74 
75 //*************************************************************************************************
134 template< typename MT // Type of the dense matrix
135  , bool SO > // Storage order
136 inline typename SubmatrixExprTrait<MT,unaligned>::Type
137  submatrix( Matrix<MT,SO>& matrix, size_t row, size_t column, size_t m, size_t n )
138 {
140 
141  return submatrix<unaligned>( ~matrix, row, column, m, n );
142 }
143 //*************************************************************************************************
144 
145 
146 //*************************************************************************************************
205 template< typename MT // Type of the dense matrix
206  , bool SO > // Storage order
207 inline typename SubmatrixExprTrait<const MT,unaligned>::Type
208  submatrix( const Matrix<MT,SO>& matrix, size_t row, size_t column, size_t m, size_t n )
209 {
211 
212  return submatrix<unaligned>( ~matrix, row, column, m, n );
213 }
214 //*************************************************************************************************
215 
216 
217 //*************************************************************************************************
299 template< bool AF // Alignment flag
300  , typename MT // Type of the dense matrix
301  , bool SO > // Storage order
302 inline typename DisableIf< Or< IsComputation<MT>, IsTransExpr<MT> >
303  , typename SubmatrixExprTrait<MT,AF>::Type >::Type
304  submatrix( Matrix<MT,SO>& matrix, size_t row, size_t column, size_t m, size_t n )
305 {
307 
309  return ReturnType( ~matrix, row, column, m, n );
310 }
311 //*************************************************************************************************
312 
313 
314 //*************************************************************************************************
396 template< bool AF // Alignment flag
397  , typename MT // Type of the dense matrix
398  , bool SO > // Storage order
399 inline typename DisableIf< Or< IsComputation<MT>, IsTransExpr<MT> >
400  , typename SubmatrixExprTrait<const MT,AF>::Type >::Type
401  submatrix( const Matrix<MT,SO>& matrix, size_t row, size_t column, size_t m, size_t n )
402 {
404 
406  return ReturnType( ~matrix, row, column, m, n );
407 }
408 //*************************************************************************************************
409 
410 
411 
412 
413 //=================================================================================================
414 //
415 // GLOBAL RESTRUCTURING OPERATORS
416 //
417 //=================================================================================================
418 
419 //*************************************************************************************************
434 template< bool AF // Alignment flag
435  , typename MT // Type of the matrix
436  , bool SO > // Storage order
437 inline typename EnableIf< IsMatMatAddExpr<MT>, typename SubmatrixExprTrait<MT,AF>::Type >::Type
438  submatrix( const Matrix<MT,SO>& matrix, size_t row, size_t column, size_t m, size_t n )
439 {
441 
442  return submatrix<AF>( (~matrix).leftOperand() , row, column, m, n ) +
443  submatrix<AF>( (~matrix).rightOperand(), row, column, m, n );
444 }
446 //*************************************************************************************************
447 
448 
449 //*************************************************************************************************
464 template< bool AF // Alignment flag
465  , typename MT // Type of the matrix
466  , bool SO > // Storage order
467 inline typename EnableIf< IsMatMatSubExpr<MT>, typename SubmatrixExprTrait<MT,AF>::Type >::Type
468  submatrix( const Matrix<MT,SO>& matrix, size_t row, size_t column, size_t m, size_t n )
469 {
471 
472  return submatrix<AF>( (~matrix).leftOperand() , row, column, m, n ) -
473  submatrix<AF>( (~matrix).rightOperand(), row, column, m, n );
474 }
476 //*************************************************************************************************
477 
478 
479 //*************************************************************************************************
494 template< bool AF // Alignment flag
495  , typename MT // Type of the matrix
496  , bool SO > // Storage order
497 inline typename EnableIf< IsMatMatMultExpr<MT>, typename SubmatrixExprTrait<MT,AF>::Type >::Type
498  submatrix( const Matrix<MT,SO>& matrix, size_t row, size_t column, size_t m, size_t n )
499 {
501 
502  typename MT::LeftOperand left ( (~matrix).leftOperand() );
503  typename MT::RightOperand right( (~matrix).rightOperand() );
504 
505  return submatrix<AF>( left, row, 0UL, m, left.columns() ) *
506  submatrix<AF>( right, 0UL, column, right.rows(), n );
507 }
509 //*************************************************************************************************
510 
511 
512 //*************************************************************************************************
527 template< bool AF // Alignment flag
528  , typename MT // Type of the matrix
529  , bool SO > // Storage order
530 inline typename EnableIf< IsVecTVecMultExpr<MT>, typename SubmatrixExprTrait<MT,AF>::Type >::Type
531  submatrix( const Matrix<MT,SO>& matrix, size_t row, size_t column, size_t m, size_t n )
532 {
534 
535  return subvector<AF>( (~matrix).leftOperand(), row, m ) *
536  subvector<AF>( (~matrix).rightOperand(), column, n );
537 }
539 //*************************************************************************************************
540 
541 
542 //*************************************************************************************************
557 template< bool AF // Alignment flag
558  , typename MT // Type of the matrix
559  , bool SO > // Storage order
560 inline typename EnableIf< IsMatScalarMultExpr<MT>, typename SubmatrixExprTrait<MT,AF>::Type >::Type
561  submatrix( const Matrix<MT,SO>& matrix, size_t row, size_t column, size_t m, size_t n )
562 {
564 
565  return submatrix<AF>( (~matrix).leftOperand(), row, column, m, n ) * (~matrix).rightOperand();
566 }
568 //*************************************************************************************************
569 
570 
571 //*************************************************************************************************
586 template< bool AF // Alignment flag
587  , typename MT // Type of the matrix
588  , bool SO > // Storage order
589 inline typename EnableIf< IsMatScalarDivExpr<MT>, typename SubmatrixExprTrait<MT,AF>::Type >::Type
590  submatrix( const Matrix<MT,SO>& matrix, size_t row, size_t column, size_t m, size_t n )
591 {
593 
594  return submatrix<AF>( (~matrix).leftOperand(), row, column, m, n ) / (~matrix).rightOperand();
595 }
597 //*************************************************************************************************
598 
599 
600 //*************************************************************************************************
615 template< bool AF // Alignment flag
616  , typename MT // Type of the matrix
617  , bool SO > // Storage order
618 inline typename EnableIf< IsMatAbsExpr<MT>, typename SubmatrixExprTrait<MT,AF>::Type >::Type
619  submatrix( const Matrix<MT,SO>& matrix, size_t row, size_t column, size_t m, size_t n )
620 {
622 
623  return abs( submatrix<AF>( (~matrix).operand(), row, column, m, n ) );
624 }
626 //*************************************************************************************************
627 
628 
629 //*************************************************************************************************
644 template< bool AF // Alignment flag
645  , typename MT // Type of the matrix
646  , bool SO > // Storage order
647 inline typename EnableIf< IsMatEvalExpr<MT>, typename SubmatrixExprTrait<MT,AF>::Type >::Type
648  submatrix( const Matrix<MT,SO>& matrix, size_t row, size_t column, size_t m, size_t n )
649 {
651 
652  return eval( submatrix<AF>( (~matrix).operand(), row, column, m, n ) );
653 }
655 //*************************************************************************************************
656 
657 
658 //*************************************************************************************************
673 template< bool AF // Alignment flag
674  , typename MT // Type of the matrix
675  , bool SO > // Storage order
676 inline typename EnableIf< IsMatSerialExpr<MT>, typename SubmatrixExprTrait<MT,AF>::Type >::Type
677  submatrix( const Matrix<MT,SO>& matrix, size_t row, size_t column, size_t m, size_t n )
678 {
680 
681  return serial( submatrix<AF>( (~matrix).operand(), row, column, m, n ) );
682 }
684 //*************************************************************************************************
685 
686 
687 //*************************************************************************************************
702 template< bool AF // Alignment flag
703  , typename MT // Type of the matrix
704  , bool SO > // Storage order
705 inline typename EnableIf< IsMatTransExpr<MT>, typename SubmatrixExprTrait<MT,AF>::Type >::Type
706  submatrix( const Matrix<MT,SO>& matrix, size_t row, size_t column, size_t m, size_t n )
707 {
709 
710  return trans( submatrix<AF>( (~matrix).operand(), column, row, n, m ) );
711 }
713 //*************************************************************************************************
714 
715 } // namespace blaze
716 
717 #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:909
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:695
Header file for the IsMatMatAddExpr type trait class.
Header file for the IsMatTransExpr type trait class.
Header file for all restructuring subvector functions.
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:2477
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:677
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:137
const DMatTransExpr< MT,!SO > trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:932
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.