All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Vector.h
Go to the documentation of this file.
1 //=================================================================================================
20 //=================================================================================================
21 
22 #ifndef _BLAZE_MATH_EXPRESSIONS_VECTOR_H_
23 #define _BLAZE_MATH_EXPRESSIONS_VECTOR_H_
24 
25 
26 //*************************************************************************************************
27 // Includes
28 //*************************************************************************************************
29 
30 #include <blaze/util/Assert.h>
31 
32 
33 namespace blaze {
34 
35 //=================================================================================================
36 //
37 // CLASS DEFINITION
38 //
39 //=================================================================================================
40 
41 //*************************************************************************************************
53 template< typename VT // Type of the vector
54  , bool TF > // Transpose flag
55 struct Vector
56 {
57  //**Type definitions****************************************************************************
58  typedef VT VectorType;
59  //**********************************************************************************************
60 
61  //**Non-const conversion operator***************************************************************
66  inline VectorType& operator~() {
67  return *static_cast<VectorType*>( this );
68  }
69  //**********************************************************************************************
70 
71  //**Const conversion operators******************************************************************
76  inline const VectorType& operator~() const {
77  return *static_cast<const VectorType*>( this );
78  }
79  //**********************************************************************************************
80 };
81 //*************************************************************************************************
82 
83 
84 
85 
86 //=================================================================================================
87 //
88 // GLOBAL FUNCTIONS
89 //
90 //=================================================================================================
91 
92 //*************************************************************************************************
95 template< typename VT, bool TF >
96 inline size_t size( const Vector<VT,TF>& v );
97 
98 template< typename VT1, bool TF1, typename VT2, bool TF2 >
99 inline void assign( Vector<VT1,TF1>& lhs, const Vector<VT2,TF2>& rhs );
100 
101 template< typename VT1, bool TF1, typename VT2, bool TF2 >
102 inline void addAssign( Vector<VT1,TF1>& lhs, const Vector<VT2,TF2>& rhs );
103 
104 template< typename VT1, bool TF1, typename VT2, bool TF2 >
105 inline void subAssign( Vector<VT1,TF1>& lhs, const Vector<VT2,TF2>& rhs );
106 
107 template< typename VT1, bool TF1, typename VT2, bool TF2 >
108 inline void multAssign( Vector<VT1,TF1>& lhs, const Vector<VT2,TF2>& rhs );
110 //*************************************************************************************************
111 
112 
113 //*************************************************************************************************
120 template< typename VT // Type of the vector
121  , bool TF > // Transpose flag of the vector
122 inline size_t size( Vector<VT,TF>& v )
123 {
124  return (~v).size();
125 }
126 //*************************************************************************************************
127 
128 
129 //*************************************************************************************************
143 template< typename VT1 // Type of the left-hand side vector
144  , bool TF1 // Transpose flag of the left-hand side vector
145  , typename VT2 // Type of the right-hand side vector
146  , bool TF2 > // Transpose flag of the right-hand side vector
147 inline void assign( Vector<VT1,TF1>& lhs, const Vector<VT2,TF2>& rhs )
148 {
149  BLAZE_INTERNAL_ASSERT( (~lhs).size() == (~rhs).size(), "Invalid vector sizes" );
150  (~lhs).assign( ~rhs );
151 }
152 //*************************************************************************************************
153 
154 
155 //*************************************************************************************************
169 template< typename VT1 // Type of the left-hand side vector
170  , bool TF1 // Transpose flag of the left-hand side vector
171  , typename VT2 // Type of the right-hand side vector
172  , bool TF2 > // Transpose flag of the right-hand side vector
173 inline void addAssign( Vector<VT1,TF1>& lhs, const Vector<VT2,TF2>& rhs )
174 {
175  BLAZE_INTERNAL_ASSERT( (~lhs).size() == (~rhs).size(), "Invalid vector sizes" );
176  (~lhs).addAssign( ~rhs );
177 }
178 //*************************************************************************************************
179 
180 
181 //*************************************************************************************************
195 template< typename VT1 // Type of the left-hand side vector
196  , bool TF1 // Transpose flag of the left-hand side vector
197  , typename VT2 // Type of the right-hand side vector
198  , bool TF2 > // Transpose flag of the right-hand side vector
199 inline void subAssign( Vector<VT1,TF1>& lhs, const Vector<VT2,TF2>& rhs )
200 {
201  BLAZE_INTERNAL_ASSERT( (~lhs).size() == (~rhs).size(), "Invalid vector sizes" );
202  (~lhs).subAssign( ~rhs );
203 }
204 //*************************************************************************************************
205 
206 
207 //*************************************************************************************************
221 template< typename VT1 // Type of the left-hand side vector
222  , bool TF1 // Transpose flag of the left-hand side vector
223  , typename VT2 // Type of the right-hand side vector
224  , bool TF2 > // Transpose flag of the right-hand side vector
225 inline void multAssign( Vector<VT1,TF1>& lhs, const Vector<VT2,TF2>& rhs )
226 {
227  BLAZE_INTERNAL_ASSERT( (~lhs).size() == (~rhs).size(), "Invalid vector sizes" );
228  (~lhs).multAssign( ~rhs );
229 }
230 //*************************************************************************************************
231 
232 } // namespace blaze
233 
234 #endif