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 
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 //*************************************************************************************************
130 template< typename VT // Type of the vector
131  , bool TF > // Transpose flag
132 inline typename SubvectorExprTrait<VT,unaligned>::Type
133  subvector( Vector<VT,TF>& vector, size_t index, size_t size )
134 {
136 
137  return subvector<unaligned>( ~vector, index, size );
138 }
139 //*************************************************************************************************
140 
141 
142 //*************************************************************************************************
198 template< typename VT // Type of the vector
199  , bool TF > // Transpose flag
200 inline typename SubvectorExprTrait<const VT,unaligned>::Type
201  subvector( const Vector<VT,TF>& vector, size_t index, size_t size )
202 {
204 
205  return subvector<unaligned>( ~vector, index, size );
206 }
207 //*************************************************************************************************
208 
209 
210 //*************************************************************************************************
283 template< bool AF // Alignment flag
284  , typename VT // Type of the dense vector
285  , bool TF > // Transpose flag
286 inline typename DisableIf< Or< IsComputation<VT>, IsTransExpr<VT> >
287  , typename SubvectorExprTrait<VT,AF>::Type >::Type
288  subvector( Vector<VT,TF>& vector, size_t index, size_t size )
289 {
291 
293  return ReturnType( ~vector, index, size );
294 }
295 //*************************************************************************************************
296 
297 
298 //*************************************************************************************************
371 template< bool AF // Alignment flag
372  , typename VT // Type of the dense vector
373  , bool TF > // Transpose flag
374 inline typename DisableIf< Or< IsComputation<VT>, IsTransExpr<VT> >
375  , typename SubvectorExprTrait<const VT,AF>::Type >::Type
376  subvector( const Vector<VT,TF>& vector, size_t index, size_t size )
377 {
379 
381  return ReturnType( ~vector, index, size );
382 }
383 //*************************************************************************************************
384 
385 
386 
387 
388 //=================================================================================================
389 //
390 // GLOBAL RESTRUCTURING OPERATORS
391 //
392 //=================================================================================================
393 
394 //*************************************************************************************************
407 template< bool AF // Alignment flag
408  , typename VT // Type of the vector
409  , bool TF > // Transpose flag
410 inline typename EnableIf< IsVecVecAddExpr<VT>, typename SubvectorExprTrait<VT,AF>::Type >::Type
411  subvector( const Vector<VT,TF>& vector, size_t index, size_t size )
412 {
414 
415  return subvector<AF>( (~vector).leftOperand() , index, size ) +
416  subvector<AF>( (~vector).rightOperand(), index, size );
417 }
419 //*************************************************************************************************
420 
421 
422 //*************************************************************************************************
435 template< bool AF // Alignment flag
436  , typename VT // Type of the vector
437  , bool TF > // Transpose flag
438 inline typename EnableIf< IsVecVecSubExpr<VT>, typename SubvectorExprTrait<VT,AF>::Type >::Type
439  subvector( const Vector<VT,TF>& vector, size_t index, size_t size )
440 {
442 
443  return subvector<AF>( (~vector).leftOperand() , index, size ) -
444  subvector<AF>( (~vector).rightOperand(), index, size );
445 }
447 //*************************************************************************************************
448 
449 
450 //*************************************************************************************************
463 template< bool AF // Alignment flag
464  , typename VT // Type of the vector
465  , bool TF > // Transpose flag
466 inline typename EnableIf< IsVecVecMultExpr<VT>, typename SubvectorExprTrait<VT,AF>::Type >::Type
467  subvector( const Vector<VT,TF>& vector, size_t index, size_t size )
468 {
470 
471  return subvector<AF>( (~vector).leftOperand() , index, size ) *
472  subvector<AF>( (~vector).rightOperand(), index, size );
473 }
475 //*************************************************************************************************
476 
477 
478 //*************************************************************************************************
491 template< bool AF // Alignment flag
492  , typename VT // Type of the vector
493  , bool TF > // Transpose flag
494 inline typename EnableIf< IsCrossExpr<VT>, typename SubvectorExprTrait<VT,unaligned>::Type >::Type
495  subvector( const Vector<VT,TF>& vector, size_t index, size_t size )
496 {
498 
499  typedef typename SubvectorExprTrait<VT,unaligned>::Type ReturnType;
500  return ReturnType( ~vector, index, size );
501 }
503 //*************************************************************************************************
504 
505 
506 //*************************************************************************************************
519 template< bool AF // Alignment flag
520  , typename VT // Type of the vector
521  , bool TF > // Transpose flag
522 inline typename EnableIf< IsMatVecMultExpr<VT>, typename SubvectorExprTrait<VT,AF>::Type >::Type
523  subvector( const Vector<VT,TF>& vector, size_t index, size_t size )
524 {
526 
527  typename VT::LeftOperand left ( (~vector).leftOperand() );
528  typename VT::RightOperand right( (~vector).rightOperand() );
529 
530  return submatrix<AF>( left, index, 0UL, size, left.columns() ) * right;
531 }
533 //*************************************************************************************************
534 
535 
536 //*************************************************************************************************
549 template< bool AF // Alignment flag
550  , typename VT // Type of the vector
551  , bool TF > // Transpose flag
552 inline typename EnableIf< IsTVecMatMultExpr<VT>, typename SubvectorExprTrait<VT,AF>::Type >::Type
553  subvector( const Vector<VT,TF>& vector, size_t index, size_t size )
554 {
556 
557  typename VT::LeftOperand left ( (~vector).leftOperand() );
558  typename VT::RightOperand right( (~vector).rightOperand() );
559 
560  return left * submatrix<AF>( right, 0UL, index, right.rows(), size );
561 }
563 //*************************************************************************************************
564 
565 
566 //*************************************************************************************************
579 template< bool AF // Alignment flag
580  , typename VT // Type of the vector
581  , bool TF > // Transpose flag
582 inline typename EnableIf< IsVecScalarMultExpr<VT>, typename SubvectorExprTrait<VT,AF>::Type >::Type
583  subvector( const Vector<VT,TF>& vector, size_t index, size_t size )
584 {
586 
587  return subvector<AF>( (~vector).leftOperand(), index, size ) * (~vector).rightOperand();
588 }
590 //*************************************************************************************************
591 
592 
593 //*************************************************************************************************
606 template< bool AF // Alignment flag
607  , typename VT // Type of the vector
608  , bool TF > // Transpose flag
609 inline typename EnableIf< IsVecScalarDivExpr<VT>, typename SubvectorExprTrait<VT,AF>::Type >::Type
610  subvector( const Vector<VT,TF>& vector, size_t index, size_t size )
611 {
613 
614  return subvector<AF>( (~vector).leftOperand(), index, size ) / (~vector).rightOperand();
615 }
617 //*************************************************************************************************
618 
619 
620 //*************************************************************************************************
633 template< bool AF // Alignment flag
634  , typename VT // Type of the vector
635  , bool TF > // Transpose flag
636 inline typename EnableIf< IsVecAbsExpr<VT>, typename SubvectorExprTrait<VT,AF>::Type >::Type
637  subvector( const Vector<VT,TF>& vector, size_t index, size_t size )
638 {
640 
641  return abs( subvector<AF>( (~vector).operand(), index, size ) );
642 }
644 //*************************************************************************************************
645 
646 
647 //*************************************************************************************************
660 template< bool AF // Alignment flag
661  , typename VT // Type of the vector
662  , bool TF > // Transpose flag
663 inline typename EnableIf< IsVecEvalExpr<VT>, typename SubvectorExprTrait<VT,AF>::Type >::Type
664  subvector( const Vector<VT,TF>& vector, size_t index, size_t size )
665 {
667 
668  return eval( subvector<AF>( (~vector).operand(), index, size ) );
669 }
671 //*************************************************************************************************
672 
673 
674 //*************************************************************************************************
687 template< bool AF // Alignment flag
688  , typename VT // Type of the vector
689  , bool TF > // Transpose flag
690 inline typename EnableIf< IsVecTransExpr<VT>, typename SubvectorExprTrait<VT,AF>::Type >::Type
691  subvector( const Vector<VT,TF>& vector, size_t index, size_t size )
692 {
694 
695  return trans( subvector<AF>( (~vector).operand(), index, size ) );
696 }
698 //*************************************************************************************************
699 
700 } // namespace blaze
701 
702 #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.
const DMatTransExpr< MT,!SO > trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:751
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:764
Header file for the IsTransExpr type trait class.
Header file for the IsMatVecMultExpr 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 IsVecTransExpr type trait class.
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2383
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:133
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 IsVecScalarMultExpr type trait class.
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.