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 
55 #include <blaze/util/EnableIf.h>
57 #include <blaze/util/Types.h>
58 
59 
60 namespace blaze {
61 
62 //=================================================================================================
63 //
64 // GLOBAL RESTRUCTURING OPERATORS
65 //
66 //=================================================================================================
67 
68 //*************************************************************************************************
81 template< typename VT // Type of the vector
82  , bool TF > // Transpose flag
83 inline typename EnableIf< IsVecVecAddExpr<VT>, typename SubvectorExprTrait<VT>::Type >::Type
84  subvector( const Vector<VT,TF>& vector, size_t index, size_t size )
85 {
87 
88  return subvector( (~vector).leftOperand() , index, size ) +
89  subvector( (~vector).rightOperand(), index, size );
90 }
92 //*************************************************************************************************
93 
94 
95 //*************************************************************************************************
108 template< typename VT // Type of the vector
109  , bool TF > // Transpose flag
110 inline typename EnableIf< IsVecVecSubExpr<VT>, typename SubvectorExprTrait<VT>::Type >::Type
111  subvector( const Vector<VT,TF>& vector, size_t index, size_t size )
112 {
114 
115  return subvector( (~vector).leftOperand() , index, size ) -
116  subvector( (~vector).rightOperand(), index, size );
117 }
119 //*************************************************************************************************
120 
121 
122 //*************************************************************************************************
135 template< typename VT // Type of the vector
136  , bool TF > // Transpose flag
137 inline typename EnableIf< IsVecVecMultExpr<VT>, typename SubvectorExprTrait<VT>::Type >::Type
138  subvector( const Vector<VT,TF>& vector, size_t index, size_t size )
139 {
141 
142  return subvector( (~vector).leftOperand() , index, size ) *
143  subvector( (~vector).rightOperand(), index, size );
144 }
146 //*************************************************************************************************
147 
148 
149 //*************************************************************************************************
162 template< typename VT // Type of the vector
163  , bool TF > // Transpose flag
164 inline typename EnableIf< IsMatVecMultExpr<VT>, typename SubvectorExprTrait<VT>::Type >::Type
165  subvector( const Vector<VT,TF>& vector, size_t index, size_t size )
166 {
168 
169  typename VT::LeftOperand left ( (~vector).leftOperand() );
170  typename VT::RightOperand right( (~vector).rightOperand() );
171 
172  return submatrix( left, index, 0UL, size, left.columns() ) * right;
173 }
175 //*************************************************************************************************
176 
177 
178 //*************************************************************************************************
191 template< typename VT // Type of the vector
192  , bool TF > // Transpose flag
193 inline typename EnableIf< IsTVecMatMultExpr<VT>, typename SubvectorExprTrait<VT>::Type >::Type
194  subvector( const Vector<VT,TF>& vector, size_t index, size_t size )
195 {
197 
198  typename VT::LeftOperand left ( (~vector).leftOperand() );
199  typename VT::RightOperand right( (~vector).rightOperand() );
200 
201  return left * submatrix( right, 0UL, index, right.rows(), size );
202 }
204 //*************************************************************************************************
205 
206 
207 //*************************************************************************************************
220 template< typename VT // Type of the vector
221  , bool TF > // Transpose flag
222 inline typename EnableIf< IsVecScalarMultExpr<VT>, typename SubvectorExprTrait<VT>::Type >::Type
223  subvector( const Vector<VT,TF>& vector, size_t index, size_t size )
224 {
226 
227  return subvector( (~vector).leftOperand(), index, size ) * (~vector).rightOperand();
228 }
230 //*************************************************************************************************
231 
232 
233 //*************************************************************************************************
246 template< typename VT // Type of the vector
247  , bool TF > // Transpose flag
248 inline typename EnableIf< IsVecScalarDivExpr<VT>, typename SubvectorExprTrait<VT>::Type >::Type
249  subvector( const Vector<VT,TF>& vector, size_t index, size_t size )
250 {
252 
253  return subvector( (~vector).leftOperand(), index, size ) / (~vector).rightOperand();
254 }
256 //*************************************************************************************************
257 
258 
259 //*************************************************************************************************
272 template< typename VT // Type of the vector
273  , bool TF > // Transpose flag
274 inline typename EnableIf< IsVecAbsExpr<VT>, typename SubvectorExprTrait<VT>::Type >::Type
275  subvector( const Vector<VT,TF>& vector, size_t index, size_t size )
276 {
278 
279  return abs( subvector( (~vector).operand(), index, size ) );
280 }
282 //*************************************************************************************************
283 
284 
285 //*************************************************************************************************
298 template< typename VT // Type of the vector
299  , bool TF > // Transpose flag
300 inline typename EnableIf< IsVecEvalExpr<VT>, typename SubvectorExprTrait<VT>::Type >::Type
301  subvector( const Vector<VT,TF>& vector, size_t index, size_t size )
302 {
304 
305  return eval( subvector( (~vector).operand(), index, size ) );
306 }
308 //*************************************************************************************************
309 
310 
311 //*************************************************************************************************
324 template< typename VT // Type of the vector
325  , bool TF > // Transpose flag
326 inline typename EnableIf< IsVecTransExpr<VT>, typename SubvectorExprTrait<VT>::Type >::Type
327  subvector( const Vector<VT,TF>& vector, size_t index, size_t size )
328 {
330 
331  return trans( subvector( (~vector).operand(), index, size ) );
332 }
334 //*************************************************************************************************
335 
336 } // namespace blaze
337 
338 #endif
Header file for the IsTVecMatMultExpr type trait class.
Header file for the IsVecVecMultExpr 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:446
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:739
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 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 DMatEvalExpr< MT, SO > eval(const DenseMatrix< MT, SO > &dm)
Forces the evaluation of the given dense matrix expression dm.
Definition: DMatEvalExpr.h:395
Header file for the IsVecScalarMultExpr 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.
DisableIf< Or< IsComputation< MT >, IsTransExpr< MT > >, DenseSubmatrix< MT > >::Type submatrix(DenseMatrix< MT, SO > &dm, size_t row, size_t column, size_t m, size_t n)
Creating a view on a specific submatrix of the given dense matrix.
Definition: DenseSubmatrix.h:4412
Header file for the Vector CRTP base class.
DisableIf< Or< IsComputation< VT >, IsTransExpr< VT > >, DenseSubvector< VT > >::Type subvector(DenseVector< VT, TF > &dv, size_t index, size_t size)
Creating a view on a specific subvector of the given dense vector.
Definition: DenseSubvector.h:2616
Header file for the FunctionTrace class.