Vector.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_VECTOR_H_
36 #define _BLAZE_MATH_VECTOR_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <iomanip>
44 #include <iosfwd>
45 #include <blaze/math/Aliases.h>
48 
49 
50 namespace blaze {
51 
52 //=================================================================================================
53 //
54 // GLOBAL OPERATORS
55 //
56 //=================================================================================================
57 
58 //*************************************************************************************************
61 template< typename T1, typename T2 >
62 inline decltype(auto) inner( const Vector<T1,false>& lhs, const Vector<T2,false>& rhs );
63 
64 template< typename T1, typename T2 >
65 inline decltype(auto) inner( const Vector<T1,false>& lhs, const Vector<T2,true>& rhs );
66 
67 template< typename T1, typename T2 >
68 inline decltype(auto) inner( const Vector<T1,true>& lhs, const Vector<T2,false>& rhs );
69 
70 template< typename T1, typename T2 >
71 inline decltype(auto) inner( const Vector<T1,true>& lhs, const Vector<T2,true>& rhs );
72 
73 template< typename T1, bool TF1, typename T2, bool TF2 >
74 inline decltype(auto) dot( const Vector<T1,TF1>& lhs, const Vector<T2,TF2>& rhs );
75 
76 template< typename T1, bool TF1, typename T2, bool TF2 >
77 inline decltype(auto) operator,( const Vector<T1,TF1>& lhs, const Vector<T2,TF2>& rhs );
78 
79 template< typename T1, typename T2 >
80 inline decltype(auto) outer( const Vector<T1,false>& lhs, const Vector<T2,false>& rhs );
81 
82 template< typename T1, typename T2 >
83 inline decltype(auto) outer( const Vector<T1,false>& lhs, const Vector<T2,true>& rhs );
84 
85 template< typename T1, typename T2 >
86 inline decltype(auto) outer( const Vector<T1,true>& lhs, const Vector<T2,false>& rhs );
87 
88 template< typename T1, typename T2 >
89 inline decltype(auto) outer( const Vector<T1,true>& lhs, const Vector<T2,true>& rhs );
90 
91 template< typename VT, bool TF >
92 inline std::ostream& operator<<( std::ostream& os, const Vector<VT,TF>& v );
94 //*************************************************************************************************
95 
96 
97 //*************************************************************************************************
106 template< typename T1 // Type of the left-hand side vector
107  , typename T2 > // Type of the right-hand side vector
108 inline decltype(auto) inner( const Vector<T1,false>& lhs, const Vector<T2,false>& rhs )
109 {
110  return trans(~lhs) * (~rhs);
111 }
112 //*************************************************************************************************
113 
114 
115 //*************************************************************************************************
124 template< typename T1 // Type of the left-hand side vector
125  , typename T2 > // Type of the right-hand side vector
126 inline decltype(auto) inner( const Vector<T1,false>& lhs, const Vector<T2,true>& rhs )
127 {
128  return trans(~lhs) * trans(~rhs);
129 }
130 //*************************************************************************************************
131 
132 
133 //*************************************************************************************************
142 template< typename T1 // Type of the left-hand side vector
143  , typename T2 > // Type of the right-hand side vector
144 inline decltype(auto) inner( const Vector<T1,true>& lhs, const Vector<T2,false>& rhs )
145 {
146  return (~lhs) * (~rhs);
147 }
148 //*************************************************************************************************
149 
150 
151 //*************************************************************************************************
160 template< typename T1 // Type of the left-hand side vector
161  , typename T2 > // Type of the right-hand side vector
162 inline decltype(auto) inner( const Vector<T1,true>& lhs, const Vector<T2,true>& rhs )
163 {
164  return (~lhs) * trans(~rhs);
165 }
166 //*************************************************************************************************
167 
168 
169 //*************************************************************************************************
178 template< typename T1 // Type of the left-hand side vector
179  , bool TF1 // Transpose flag of the left-hand side vector
180  , typename T2 // Type of the right-hand side vector
181  , bool TF2 > // Transpose flag of the right-hand side vector
182 inline decltype(auto) dot( const Vector<T1,TF1>& lhs, const Vector<T2,TF2>& rhs )
183 {
184  return inner( ~lhs, ~rhs );
185 }
186 //*************************************************************************************************
187 
188 
189 //*************************************************************************************************
198 template< typename T1 // Type of the left-hand side vector
199  , bool TF1 // Transpose flag of the left-hand side vector
200  , typename T2 // Type of the right-hand side vector
201  , bool TF2 > // Transpose flag of the right-hand side vector
202 inline decltype(auto) operator,( const Vector<T1,TF1>& lhs, const Vector<T2,TF2>& rhs )
203 {
204  return inner( ~lhs, ~rhs );
205 }
206 //*************************************************************************************************
207 
208 
209 //*************************************************************************************************
218 template< typename T1 // Type of the left-hand side vector
219  , typename T2 > // Type of the right-hand side vector
220 inline decltype(auto) outer( const Vector<T1,false>& lhs, const Vector<T2,false>& rhs )
221 {
222  return (~lhs) * trans(~rhs);
223 }
224 //*************************************************************************************************
225 
226 
227 //*************************************************************************************************
236 template< typename T1 // Type of the left-hand side vector
237  , typename T2 > // Type of the right-hand side vector
238 inline decltype(auto) outer( const Vector<T1,false>& lhs, const Vector<T2,true>& rhs )
239 {
240  return (~lhs) * (~rhs);
241 }
242 //*************************************************************************************************
243 
244 
245 //*************************************************************************************************
254 template< typename T1 // Type of the left-hand side vector
255  , typename T2 > // Type of the right-hand side vector
256 inline decltype(auto) outer( const Vector<T1,true>& lhs, const Vector<T2,false>& rhs )
257 {
258  return trans(~lhs) * trans(~rhs);
259 }
260 //*************************************************************************************************
261 
262 
263 //*************************************************************************************************
272 template< typename T1 // Type of the left-hand side vector
273  , typename T2 > // Type of the right-hand side vector
274 inline decltype(auto) outer( const Vector<T1,true>& lhs, const Vector<T2,true>& rhs )
275 {
276  return trans(~lhs) * (~rhs);
277 }
278 //*************************************************************************************************
279 
280 
281 //*************************************************************************************************
289 template< typename VT // Type of the vector
290  , bool TF > // Transpose flag
291 inline std::ostream& operator<<( std::ostream& os, const Vector<VT,TF>& v )
292 {
293  CompositeType_<VT> tmp( ~v );
294 
295  if( tmp.size() == 0UL ) {
296  os << "( )\n";
297  }
298  else if( TF == rowVector ) {
299  os << "(";
300  for( size_t i=0UL; i<tmp.size(); ++i )
301  os << " " << tmp[i];
302  os << " )\n";
303  }
304  else {
305  for( size_t i=0UL; i<tmp.size(); ++i )
306  os << "( " << std::setw( 11UL ) << tmp[i] << " )\n";
307  }
308 
309  return os;
310 }
311 //*************************************************************************************************
312 
313 } // namespace blaze
314 
315 #endif
decltype(auto) inner(const Vector< T1, false > &lhs, const Vector< T2, false > &rhs)
Multiplication operator for the scalar product (dot/inner product) of two vectors ( )...
Definition: Vector.h:108
Header file for auxiliary alias declarations.
const bool rowVector
Transpose flag for row vectors.
Definition: TransposeFlag.h:73
decltype(auto) dot(const Vector< T1, TF1 > &lhs, const Vector< T2, TF2 > &rhs)
Multiplication operator for the scalar product (dot/inner product) of two vectors ( )...
Definition: Vector.h:182
STL namespace.
Header file for the vector transpose flag types.
typename T::CompositeType CompositeType_
Alias declaration for nested CompositeType type definitions.The CompositeType_ alias declaration prov...
Definition: Aliases.h:83
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
decltype(auto) outer(const Vector< T1, false > &lhs, const Vector< T2, false > &rhs)
Multiplication operator for the outer product of two vectors ( ).
Definition: Vector.h:220
decltype(auto) trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:789
Base class for N-dimensional vectors.The Vector class is a base class for all arbitrarily sized (N-di...
Definition: Forward.h:177
Header file for the Vector CRTP base class.