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>
45 
46 
47 namespace blaze {
48 
49 //=================================================================================================
50 //
51 // CLASS DEFINITION
52 //
53 //=================================================================================================
54 
55 //*************************************************************************************************
67 template< typename VT // Type of the vector
68  , bool TF > // Transpose flag
69 struct Vector
70 {
71  //**Type definitions****************************************************************************
72  typedef VT VectorType;
73  //**********************************************************************************************
74 
75  //**Non-const conversion operator***************************************************************
80  inline VectorType& operator~() {
81  return *static_cast<VectorType*>( this );
82  }
83  //**********************************************************************************************
84 
85  //**Const conversion operators******************************************************************
90  inline const VectorType& operator~() const {
91  return *static_cast<const VectorType*>( this );
92  }
93  //**********************************************************************************************
94 };
95 //*************************************************************************************************
96 
97 
98 
99 
100 //=================================================================================================
101 //
102 // GLOBAL FUNCTIONS
103 //
104 //=================================================================================================
105 
106 //*************************************************************************************************
109 template< typename VT, bool TF >
110 inline size_t size( const Vector<VT,TF>& v );
111 
112 template< typename VT1, bool TF1, typename VT2, bool TF2 >
113 inline void assign( Vector<VT1,TF1>& lhs, const Vector<VT2,TF2>& rhs );
114 
115 template< typename VT1, bool TF1, typename VT2, bool TF2 >
116 inline void addAssign( Vector<VT1,TF1>& lhs, const Vector<VT2,TF2>& rhs );
117 
118 template< typename VT1, bool TF1, typename VT2, bool TF2 >
119 inline void subAssign( Vector<VT1,TF1>& lhs, const Vector<VT2,TF2>& rhs );
120 
121 template< typename VT1, bool TF1, typename VT2, bool TF2 >
122 inline void multAssign( Vector<VT1,TF1>& lhs, const Vector<VT2,TF2>& rhs );
124 //*************************************************************************************************
125 
126 
127 //*************************************************************************************************
134 template< typename VT // Type of the vector
135  , bool TF > // Transpose flag of the vector
136 inline size_t size( Vector<VT,TF>& v )
137 {
138  return (~v).size();
139 }
140 //*************************************************************************************************
141 
142 
143 //*************************************************************************************************
157 template< typename VT1 // Type of the left-hand side vector
158  , bool TF1 // Transpose flag of the left-hand side vector
159  , typename VT2 // Type of the right-hand side vector
160  , bool TF2 > // Transpose flag of the right-hand side vector
161 inline void assign( Vector<VT1,TF1>& lhs, const Vector<VT2,TF2>& rhs )
162 {
164 
165  BLAZE_INTERNAL_ASSERT( (~lhs).size() == (~rhs).size(), "Invalid vector sizes" );
166  (~lhs).assign( ~rhs );
167 }
168 //*************************************************************************************************
169 
170 
171 //*************************************************************************************************
185 template< typename VT1 // Type of the left-hand side vector
186  , bool TF1 // Transpose flag of the left-hand side vector
187  , typename VT2 // Type of the right-hand side vector
188  , bool TF2 > // Transpose flag of the right-hand side vector
189 inline void addAssign( Vector<VT1,TF1>& lhs, const Vector<VT2,TF2>& rhs )
190 {
192 
193  BLAZE_INTERNAL_ASSERT( (~lhs).size() == (~rhs).size(), "Invalid vector sizes" );
194  (~lhs).addAssign( ~rhs );
195 }
196 //*************************************************************************************************
197 
198 
199 //*************************************************************************************************
213 template< typename VT1 // Type of the left-hand side vector
214  , bool TF1 // Transpose flag of the left-hand side vector
215  , typename VT2 // Type of the right-hand side vector
216  , bool TF2 > // Transpose flag of the right-hand side vector
217 inline void subAssign( Vector<VT1,TF1>& lhs, const Vector<VT2,TF2>& rhs )
218 {
220 
221  BLAZE_INTERNAL_ASSERT( (~lhs).size() == (~rhs).size(), "Invalid vector sizes" );
222  (~lhs).subAssign( ~rhs );
223 }
224 //*************************************************************************************************
225 
226 
227 //*************************************************************************************************
241 template< typename VT1 // Type of the left-hand side vector
242  , bool TF1 // Transpose flag of the left-hand side vector
243  , typename VT2 // Type of the right-hand side vector
244  , bool TF2 > // Transpose flag of the right-hand side vector
245 inline void multAssign( Vector<VT1,TF1>& lhs, const Vector<VT2,TF2>& rhs )
246 {
248 
249  BLAZE_INTERNAL_ASSERT( (~lhs).size() == (~rhs).size(), "Invalid vector sizes" );
250  (~lhs).multAssign( ~rhs );
251 }
252 //*************************************************************************************************
253 
254 } // namespace blaze
255 
256 #endif
VectorType & operator~()
Conversion operator for non-constant vectors.
Definition: Vector.h:80
const VectorType & operator~() const
Conversion operator for constant vectors.
Definition: Vector.h:90
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:179
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:269
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:209
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:239
VT VectorType
Type of the vector.
Definition: Vector.h:72
#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
Header file for the FunctionTrace class.