All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Subvector.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_VIEWS_SUBVECTOR_H_
36 #define _BLAZE_MATH_VIEWS_SUBVECTOR_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
61 #include <blaze/util/DisableIf.h>
62 #include <blaze/util/EnableIf.h>
64 #include <blaze/util/mpl/Or.h>
65 #include <blaze/util/Types.h>
66 
67 
68 namespace blaze {
69 
70 //=================================================================================================
71 //
72 // GLOBAL FUNCTION
73 //
74 //=================================================================================================
75 
76 //*************************************************************************************************
132 template< typename VT // Type of the vector
133  , bool TF > // Transpose flag
134 inline typename SubvectorExprTrait<VT,unaligned>::Type
135  subvector( Vector<VT,TF>& vector, size_t index, size_t size )
136 {
138 
139  return subvector<unaligned>( ~vector, index, size );
140 }
141 //*************************************************************************************************
142 
143 
144 //*************************************************************************************************
200 template< typename VT // Type of the vector
201  , bool TF > // Transpose flag
202 inline typename SubvectorExprTrait<const VT,unaligned>::Type
203  subvector( const Vector<VT,TF>& vector, size_t index, size_t size )
204 {
206 
207  return subvector<unaligned>( ~vector, index, size );
208 }
209 //*************************************************************************************************
210 
211 
212 //*************************************************************************************************
285 template< bool AF // Alignment flag
286  , typename VT // Type of the dense vector
287  , bool TF > // Transpose flag
288 inline typename DisableIf< Or< IsComputation<VT>, IsTransExpr<VT> >
289  , typename SubvectorExprTrait<VT,AF>::Type >::Type
290  subvector( Vector<VT,TF>& vector, size_t index, size_t size )
291 {
293 
295  return ReturnType( ~vector, index, size );
296 }
297 //*************************************************************************************************
298 
299 
300 //*************************************************************************************************
373 template< bool AF // Alignment flag
374  , typename VT // Type of the dense vector
375  , bool TF > // Transpose flag
376 inline typename DisableIf< Or< IsComputation<VT>, IsTransExpr<VT> >
377  , typename SubvectorExprTrait<const VT,AF>::Type >::Type
378  subvector( const Vector<VT,TF>& vector, size_t index, size_t size )
379 {
381 
383  return ReturnType( ~vector, index, size );
384 }
385 //*************************************************************************************************
386 
387 
388 
389 
390 //=================================================================================================
391 //
392 // GLOBAL RESTRUCTURING OPERATORS
393 //
394 //=================================================================================================
395 
396 //*************************************************************************************************
409 template< bool AF // Alignment flag
410  , typename VT // Type of the vector
411  , bool TF > // Transpose flag
412 inline typename EnableIf< IsVecVecAddExpr<VT>, typename SubvectorExprTrait<VT,AF>::Type >::Type
413  subvector( const Vector<VT,TF>& vector, size_t index, size_t size )
414 {
416 
417  return subvector<AF>( (~vector).leftOperand() , index, size ) +
418  subvector<AF>( (~vector).rightOperand(), index, size );
419 }
421 //*************************************************************************************************
422 
423 
424 //*************************************************************************************************
437 template< bool AF // Alignment flag
438  , typename VT // Type of the vector
439  , bool TF > // Transpose flag
440 inline typename EnableIf< IsVecVecSubExpr<VT>, typename SubvectorExprTrait<VT,AF>::Type >::Type
441  subvector( const Vector<VT,TF>& vector, size_t index, size_t size )
442 {
444 
445  return subvector<AF>( (~vector).leftOperand() , index, size ) -
446  subvector<AF>( (~vector).rightOperand(), index, size );
447 }
449 //*************************************************************************************************
450 
451 
452 //*************************************************************************************************
465 template< bool AF // Alignment flag
466  , typename VT // Type of the vector
467  , bool TF > // Transpose flag
468 inline typename EnableIf< IsVecVecMultExpr<VT>, typename SubvectorExprTrait<VT,AF>::Type >::Type
469  subvector( const Vector<VT,TF>& vector, size_t index, size_t size )
470 {
472 
473  return subvector<AF>( (~vector).leftOperand() , index, size ) *
474  subvector<AF>( (~vector).rightOperand(), index, size );
475 }
477 //*************************************************************************************************
478 
479 
480 //*************************************************************************************************
493 template< bool AF // Alignment flag
494  , typename VT // Type of the vector
495  , bool TF > // Transpose flag
496 inline typename EnableIf< IsCrossExpr<VT>, typename SubvectorExprTrait<VT,unaligned>::Type >::Type
497  subvector( const Vector<VT,TF>& vector, size_t index, size_t size )
498 {
500 
501  typedef typename SubvectorExprTrait<VT,unaligned>::Type ReturnType;
502  return ReturnType( ~vector, index, size );
503 }
505 //*************************************************************************************************
506 
507 
508 //*************************************************************************************************
521 template< bool AF // Alignment flag
522  , typename VT // Type of the vector
523  , bool TF > // Transpose flag
524 inline typename EnableIf< IsMatVecMultExpr<VT>, typename SubvectorExprTrait<VT,AF>::Type >::Type
525  subvector( const Vector<VT,TF>& vector, size_t index, size_t size )
526 {
528 
529  typename VT::LeftOperand left ( (~vector).leftOperand() );
530  typename VT::RightOperand right( (~vector).rightOperand() );
531 
532  return submatrix<AF>( left, index, 0UL, size, left.columns() ) * right;
533 }
535 //*************************************************************************************************
536 
537 
538 //*************************************************************************************************
551 template< bool AF // Alignment flag
552  , typename VT // Type of the vector
553  , bool TF > // Transpose flag
554 inline typename EnableIf< IsTVecMatMultExpr<VT>, typename SubvectorExprTrait<VT,AF>::Type >::Type
555  subvector( const Vector<VT,TF>& vector, size_t index, size_t size )
556 {
558 
559  typename VT::LeftOperand left ( (~vector).leftOperand() );
560  typename VT::RightOperand right( (~vector).rightOperand() );
561 
562  return left * submatrix<AF>( right, 0UL, index, right.rows(), size );
563 }
565 //*************************************************************************************************
566 
567 
568 //*************************************************************************************************
581 template< bool AF // Alignment flag
582  , typename VT // Type of the vector
583  , bool TF > // Transpose flag
584 inline typename EnableIf< IsVecScalarMultExpr<VT>, typename SubvectorExprTrait<VT,AF>::Type >::Type
585  subvector( const Vector<VT,TF>& vector, size_t index, size_t size )
586 {
588 
589  return subvector<AF>( (~vector).leftOperand(), index, size ) * (~vector).rightOperand();
590 }
592 //*************************************************************************************************
593 
594 
595 //*************************************************************************************************
608 template< bool AF // Alignment flag
609  , typename VT // Type of the vector
610  , bool TF > // Transpose flag
611 inline typename EnableIf< IsVecScalarDivExpr<VT>, typename SubvectorExprTrait<VT,AF>::Type >::Type
612  subvector( const Vector<VT,TF>& vector, size_t index, size_t size )
613 {
615 
616  return subvector<AF>( (~vector).leftOperand(), index, size ) / (~vector).rightOperand();
617 }
619 //*************************************************************************************************
620 
621 
622 //*************************************************************************************************
635 template< bool AF // Alignment flag
636  , typename VT // Type of the vector
637  , bool TF > // Transpose flag
638 inline typename EnableIf< IsVecAbsExpr<VT>, typename SubvectorExprTrait<VT,AF>::Type >::Type
639  subvector( const Vector<VT,TF>& vector, size_t index, size_t size )
640 {
642 
643  return abs( subvector<AF>( (~vector).operand(), index, size ) );
644 }
646 //*************************************************************************************************
647 
648 
649 //*************************************************************************************************
662 template< bool AF // Alignment flag
663  , typename VT // Type of the vector
664  , bool TF > // Transpose flag
665 inline typename EnableIf< IsVecEvalExpr<VT>, typename SubvectorExprTrait<VT,AF>::Type >::Type
666  subvector( const Vector<VT,TF>& vector, size_t index, size_t size )
667 {
669 
670  return eval( subvector<AF>( (~vector).operand(), index, size ) );
671 }
673 //*************************************************************************************************
674 
675 
676 //*************************************************************************************************
689 template< bool AF // Alignment flag
690  , typename VT // Type of the vector
691  , bool TF > // Transpose flag
692 inline typename EnableIf< IsVecSerialExpr<VT>, typename SubvectorExprTrait<VT,AF>::Type >::Type
693  subvector( const Vector<VT,TF>& vector, size_t index, size_t size )
694 {
696 
697  return serial( subvector<AF>( (~vector).operand(), index, size ) );
698 }
700 //*************************************************************************************************
701 
702 
703 //*************************************************************************************************
716 template< bool AF // Alignment flag
717  , typename VT // Type of the vector
718  , bool TF > // Transpose flag
719 inline typename EnableIf< IsVecTransExpr<VT>, typename SubvectorExprTrait<VT,AF>::Type >::Type
720  subvector( const Vector<VT,TF>& vector, size_t index, size_t size )
721 {
723 
724  return trans( subvector<AF>( (~vector).operand(), index, size ) );
725 }
727 //*************************************************************************************************
728 
729 } // namespace blaze
730 
731 #endif
Evaluation of the expression type type of a subvector operation.Via this type trait it is possible to...
Definition: SubvectorExprTrait.h:78
Header file for the subvector/submatrix alignment flag values.
Header file for the IsTVecMatMultExpr type trait class.
Header file for the IsVecVecMultExpr type trait class.
Header file for the IsCrossExpr type trait class.
Header file for the IsVecVecSubExpr type trait class.
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 IsMatVecMultExpr type trait class.
Header file for the IsVecSerialExpr type trait class.
Header file for the IsVecEvalExpr type trait class.
Header file for the IsVecVecAddExpr type trait class.
Header file for the DisableIf class template.
Header file for the Or class template.
Header file for the IsVecScalarDivExpr type trait class.
Header file for the IsVecAbsExpr type trait class.
Header file for the EnableIf class template.
Header file for the serial shim.
Header file for the IsVecTransExpr type trait class.
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2407
SubvectorExprTrait< VT, unaligned >::Type subvector(Vector< VT, TF > &vector, size_t index, size_t size)
Creating a view on a specific subvector of the given vector.
Definition: Subvector.h:135
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 IsVecScalarMultExpr type trait class.
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 SubvectorExprTrait class template.
Header file for the Vector CRTP base class.
Header file for the FunctionTrace class.