All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Vector.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_EXPRESSIONS_VECTOR_H_
36 #define _BLAZE_MATH_EXPRESSIONS_VECTOR_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <blaze/util/Assert.h>
46 
47 
48 namespace blaze {
49 
50 //=================================================================================================
51 //
52 // CLASS DEFINITION
53 //
54 //=================================================================================================
55 
56 //*************************************************************************************************
68 template< typename VT // Type of the vector
69  , bool TF > // Transpose flag
70 struct Vector
71 {
72  //**Type definitions****************************************************************************
73  typedef VT VectorType;
74  //**********************************************************************************************
75 
76  //**Non-const conversion operator***************************************************************
81  inline VectorType& operator~() {
82  return *static_cast<VectorType*>( this );
83  }
84  //**********************************************************************************************
85 
86  //**Const conversion operators******************************************************************
91  inline const VectorType& operator~() const {
92  return *static_cast<const VectorType*>( this );
93  }
94  //**********************************************************************************************
95 };
96 //*************************************************************************************************
97 
98 
99 
100 
101 //=================================================================================================
102 //
103 // GLOBAL FUNCTIONS
104 //
105 //=================================================================================================
106 
107 //*************************************************************************************************
110 template< typename VT, bool TF >
111 inline size_t size( const Vector<VT,TF>& v );
112 
113 template< typename VT, bool TF >
114 inline size_t capacity( const Vector<VT,TF>& v );
115 
116 template< typename VT, bool TF >
117 inline size_t nonZeros( const Vector<VT,TF>& v );
118 
119 template< typename VT1, bool TF1, typename VT2, bool TF2 >
120 inline void assign( Vector<VT1,TF1>& lhs, const Vector<VT2,TF2>& rhs );
121 
122 template< typename VT1, bool TF1, typename VT2, bool TF2 >
123 inline void addAssign( Vector<VT1,TF1>& lhs, const Vector<VT2,TF2>& rhs );
124 
125 template< typename VT1, bool TF1, typename VT2, bool TF2 >
126 inline void subAssign( Vector<VT1,TF1>& lhs, const Vector<VT2,TF2>& rhs );
127 
128 template< typename VT1, bool TF1, typename VT2, bool TF2 >
129 inline void multAssign( Vector<VT1,TF1>& lhs, const Vector<VT2,TF2>& rhs );
130 
131 template< typename VT1, bool TF1, typename VT2, bool TF2 >
132 inline bool isSame( const Vector<VT1,TF1>& a, const Vector<VT2,TF2>& b );
134 //*************************************************************************************************
135 
136 
137 //*************************************************************************************************
144 template< typename VT // Type of the vector
145  , bool TF > // Transpose flag of the vector
146 inline size_t size( Vector<VT,TF>& v )
147 {
148  return (~v).size();
149 }
150 //*************************************************************************************************
151 
152 
153 //*************************************************************************************************
160 template< typename VT // Type of the vector
161  , bool TF > // Transpose flag of the vector
162 inline size_t capacity( Vector<VT,TF>& v )
163 {
164  return (~v).capacity();
165 }
166 //*************************************************************************************************
167 
168 
169 //*************************************************************************************************
179 template< typename VT // Type of the vector
180  , bool TF > // Transpose flag of the vector
181 inline size_t nonZeros( Vector<VT,TF>& v )
182 {
183  return (~v).nonZeros();
184 }
185 //*************************************************************************************************
186 
187 
188 //*************************************************************************************************
202 template< typename VT1 // Type of the left-hand side vector
203  , bool TF1 // Transpose flag of the left-hand side vector
204  , typename VT2 // Type of the right-hand side vector
205  , bool TF2 > // Transpose flag of the right-hand side vector
206 inline void assign( Vector<VT1,TF1>& lhs, const Vector<VT2,TF2>& rhs )
207 {
209 
210  BLAZE_INTERNAL_ASSERT( (~lhs).size() == (~rhs).size(), "Invalid vector sizes" );
211  (~lhs).assign( ~rhs );
212 }
213 //*************************************************************************************************
214 
215 
216 //*************************************************************************************************
230 template< typename VT1 // Type of the left-hand side vector
231  , bool TF1 // Transpose flag of the left-hand side vector
232  , typename VT2 // Type of the right-hand side vector
233  , bool TF2 > // Transpose flag of the right-hand side vector
234 inline void addAssign( Vector<VT1,TF1>& lhs, const Vector<VT2,TF2>& rhs )
235 {
237 
238  BLAZE_INTERNAL_ASSERT( (~lhs).size() == (~rhs).size(), "Invalid vector sizes" );
239  (~lhs).addAssign( ~rhs );
240 }
241 //*************************************************************************************************
242 
243 
244 //*************************************************************************************************
258 template< typename VT1 // Type of the left-hand side vector
259  , bool TF1 // Transpose flag of the left-hand side vector
260  , typename VT2 // Type of the right-hand side vector
261  , bool TF2 > // Transpose flag of the right-hand side vector
262 inline void subAssign( Vector<VT1,TF1>& lhs, const Vector<VT2,TF2>& rhs )
263 {
265 
266  BLAZE_INTERNAL_ASSERT( (~lhs).size() == (~rhs).size(), "Invalid vector sizes" );
267  (~lhs).subAssign( ~rhs );
268 }
269 //*************************************************************************************************
270 
271 
272 //*************************************************************************************************
286 template< typename VT1 // Type of the left-hand side vector
287  , bool TF1 // Transpose flag of the left-hand side vector
288  , typename VT2 // Type of the right-hand side vector
289  , bool TF2 > // Transpose flag of the right-hand side vector
290 inline void multAssign( Vector<VT1,TF1>& lhs, const Vector<VT2,TF2>& rhs )
291 {
293 
294  BLAZE_INTERNAL_ASSERT( (~lhs).size() == (~rhs).size(), "Invalid vector sizes" );
295  (~lhs).multAssign( ~rhs );
296 }
297 //*************************************************************************************************
298 
299 
300 //*************************************************************************************************
333 template< typename VT1 // Type of the left-hand side vector
334  , bool TF1 // Transpose flag of the left-hand side vector
335  , typename VT2 // Type of the right-hand side vector
336  , bool TF2 > // Transpose flag of the right-hand side vector
337 inline bool isSame( const Vector<VT1,TF1>& a, const Vector<VT2,TF2>& b )
338 {
339  return ( IsSame<VT1,VT2>::value &&
340  reinterpret_cast<const void*>( &a ) == reinterpret_cast<const void*>( &b ) );
341 }
342 //*************************************************************************************************
343 
344 } // namespace blaze
345 
346 #endif
VectorType & operator~()
Conversion operator for non-constant vectors.
Definition: Vector.h:81
const VectorType & operator~() const
Conversion operator for constant vectors.
Definition: Vector.h:91
Header file for the IsSame and IsStrictlySame type traits.
Type relationship analysis.This class tests if the two data types A and B are equal. For this type comparison, the cv-qualifiers of both data types are ignored. If A and B are the same data type (ignoring the cv-qualifiers), then the value member enumeration is set to 1, the nested type definition Type is TrueType, and the class derives from TrueType. Otherwise value is set to 0, Type is FalseType, and the class derives from FalseType.
Definition: IsSame.h:158
bool isSame(const Matrix< MT1, SO1 > &a, const Matrix< MT2, SO2 > &b)
Returns whether the two given matrices represent the same observable state.
Definition: Matrix.h:409
size_t nonZeros(const Matrix< MT, SO > &m)
Returns the total number of non-zero elements in the matrix.
Definition: Matrix.h:224
void assign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the assignment of a matrix to a matrix.
Definition: Matrix.h:271
void multAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the multiplication assignment of a matrix to a matrix.
Definition: Matrix.h:361
Header file for run time assertion macros.
void addAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the addition assignment of a matrix to a matrix.
Definition: Matrix.h:301
void subAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the subtraction assignment of a matrix to matrix.
Definition: Matrix.h:331
VT VectorType
Type of the vector.
Definition: Vector.h:73
#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
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101
size_t capacity(const Matrix< MT, SO > &m)
Returns the maximum capacity of the matrix.
Definition: Matrix.h:186
Header file for the FunctionTrace class.