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>
32 
33 
34 namespace blaze {
35 
36 //=================================================================================================
37 //
38 // CLASS DEFINITION
39 //
40 //=================================================================================================
41 
42 //*************************************************************************************************
54 template< typename VT // Type of the vector
55  , bool TF > // Transpose flag
56 struct Vector
57 {
58  //**Type definitions****************************************************************************
59  typedef VT VectorType;
60  //**********************************************************************************************
61 
62  //**Non-const conversion operator***************************************************************
67  inline VectorType& operator~() {
68  return *static_cast<VectorType*>( this );
69  }
70  //**********************************************************************************************
71 
72  //**Const conversion operators******************************************************************
77  inline const VectorType& operator~() const {
78  return *static_cast<const VectorType*>( this );
79  }
80  //**********************************************************************************************
81 };
82 //*************************************************************************************************
83 
84 
85 
86 
87 //=================================================================================================
88 //
89 // GLOBAL FUNCTIONS
90 //
91 //=================================================================================================
92 
93 //*************************************************************************************************
96 template< typename VT, bool TF >
97 inline size_t size( const Vector<VT,TF>& v );
98 
99 template< typename VT1, bool TF1, typename VT2, bool TF2 >
100 inline void assign( Vector<VT1,TF1>& lhs, const Vector<VT2,TF2>& rhs );
101 
102 template< typename VT1, bool TF1, typename VT2, bool TF2 >
103 inline void addAssign( Vector<VT1,TF1>& lhs, const Vector<VT2,TF2>& rhs );
104 
105 template< typename VT1, bool TF1, typename VT2, bool TF2 >
106 inline void subAssign( Vector<VT1,TF1>& lhs, const Vector<VT2,TF2>& rhs );
107 
108 template< typename VT1, bool TF1, typename VT2, bool TF2 >
109 inline void multAssign( Vector<VT1,TF1>& lhs, const Vector<VT2,TF2>& rhs );
111 //*************************************************************************************************
112 
113 
114 //*************************************************************************************************
121 template< typename VT // Type of the vector
122  , bool TF > // Transpose flag of the vector
123 inline size_t size( Vector<VT,TF>& v )
124 {
125  return (~v).size();
126 }
127 //*************************************************************************************************
128 
129 
130 //*************************************************************************************************
144 template< typename VT1 // Type of the left-hand side vector
145  , bool TF1 // Transpose flag of the left-hand side vector
146  , typename VT2 // Type of the right-hand side vector
147  , bool TF2 > // Transpose flag of the right-hand side vector
148 inline void assign( Vector<VT1,TF1>& lhs, const Vector<VT2,TF2>& rhs )
149 {
151 
152  BLAZE_INTERNAL_ASSERT( (~lhs).size() == (~rhs).size(), "Invalid vector sizes" );
153  (~lhs).assign( ~rhs );
154 }
155 //*************************************************************************************************
156 
157 
158 //*************************************************************************************************
172 template< typename VT1 // Type of the left-hand side vector
173  , bool TF1 // Transpose flag of the left-hand side vector
174  , typename VT2 // Type of the right-hand side vector
175  , bool TF2 > // Transpose flag of the right-hand side vector
176 inline void addAssign( Vector<VT1,TF1>& lhs, const Vector<VT2,TF2>& rhs )
177 {
179 
180  BLAZE_INTERNAL_ASSERT( (~lhs).size() == (~rhs).size(), "Invalid vector sizes" );
181  (~lhs).addAssign( ~rhs );
182 }
183 //*************************************************************************************************
184 
185 
186 //*************************************************************************************************
200 template< typename VT1 // Type of the left-hand side vector
201  , bool TF1 // Transpose flag of the left-hand side vector
202  , typename VT2 // Type of the right-hand side vector
203  , bool TF2 > // Transpose flag of the right-hand side vector
204 inline void subAssign( Vector<VT1,TF1>& lhs, const Vector<VT2,TF2>& rhs )
205 {
207 
208  BLAZE_INTERNAL_ASSERT( (~lhs).size() == (~rhs).size(), "Invalid vector sizes" );
209  (~lhs).subAssign( ~rhs );
210 }
211 //*************************************************************************************************
212 
213 
214 //*************************************************************************************************
228 template< typename VT1 // Type of the left-hand side vector
229  , bool TF1 // Transpose flag of the left-hand side vector
230  , typename VT2 // Type of the right-hand side vector
231  , bool TF2 > // Transpose flag of the right-hand side vector
232 inline void multAssign( Vector<VT1,TF1>& lhs, const Vector<VT2,TF2>& rhs )
233 {
235 
236  BLAZE_INTERNAL_ASSERT( (~lhs).size() == (~rhs).size(), "Invalid vector sizes" );
237  (~lhs).multAssign( ~rhs );
238 }
239 //*************************************************************************************************
240 
241 } // namespace blaze
242 
243 #endif