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_VECTOR_H_
36 #define _BLAZE_MATH_VECTOR_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <iomanip>
44 #include <ostream>
48 
49 
50 namespace blaze {
51 
52 //=================================================================================================
53 //
54 // GLOBAL OPERATORS
55 //
56 //=================================================================================================
57 
58 //*************************************************************************************************
61 template< typename T1, typename T2 >
62 inline const typename MultTrait<typename T1::ElementType,typename T2::ElementType>::Type
63  operator,( const Vector<T1,false>& lhs, const Vector<T2,false>& rhs );
64 
65 template< typename T1, typename T2 >
66 inline const typename MultTrait<typename T1::ElementType,typename T2::ElementType>::Type
67  operator,( const Vector<T1,false>& lhs, const Vector<T2,true>& rhs );
68 
69 template< typename T1, typename T2 >
70 inline const typename MultTrait<typename T1::ElementType,typename T2::ElementType>::Type
71  operator,( const Vector<T1,true>& lhs, const Vector<T2,false>& rhs );
72 
73 template< typename T1, typename T2 >
74 inline const typename MultTrait<typename T1::ElementType,typename T2::ElementType>::Type
75  operator,( const Vector<T1,true>& lhs, const Vector<T2,true>& rhs );
76 
77 template< typename VT, bool TF >
78 inline std::ostream& operator<<( std::ostream& os, const Vector<VT,TF>& dv );
80 //*************************************************************************************************
81 
82 
83 //*************************************************************************************************
92 template< typename T1 // Type of the left-hand side vector
93  , typename T2 > // Type of the right-hand side vector
94 inline const typename MultTrait<typename T1::ElementType,typename T2::ElementType>::Type
95  operator,( const Vector<T1,false>& lhs, const Vector<T2,false>& rhs )
96 {
97  return trans(~lhs) * (~rhs);
98 }
99 //*************************************************************************************************
100 
101 
102 //*************************************************************************************************
111 template< typename T1 // Type of the left-hand side vector
112  , typename T2 > // Type of the right-hand side vector
113 inline const typename MultTrait<typename T1::ElementType,typename T2::ElementType>::Type
114  operator,( const Vector<T1,false>& lhs, const Vector<T2,true>& rhs )
115 {
116  return trans(~lhs) * trans(~rhs);
117 }
118 //*************************************************************************************************
119 
120 
121 //*************************************************************************************************
130 template< typename T1 // Type of the left-hand side vector
131  , typename T2 > // Type of the right-hand side vector
132 inline const typename MultTrait<typename T1::ElementType,typename T2::ElementType>::Type
133  operator,( const Vector<T1,true>& lhs, const Vector<T2,false>& rhs )
134 {
135  return (~lhs) * (~rhs);
136 }
137 //*************************************************************************************************
138 
139 
140 //*************************************************************************************************
149 template< typename T1 // Type of the left-hand side vector
150  , typename T2 > // Type of the right-hand side vector
151 inline const typename MultTrait<typename T1::ElementType,typename T2::ElementType>::Type
152  operator,( const Vector<T1,true>& lhs, const Vector<T2,true>& rhs )
153 {
154  return (~lhs) * trans(~rhs);
155 }
156 //*************************************************************************************************
157 
158 
159 //*************************************************************************************************
167 template< typename VT // Type of the vector
168  , bool TF > // Transpose flag
169 inline std::ostream& operator<<( std::ostream& os, const Vector<VT,TF>& v )
170 {
171  if( (~v).size() == 0UL ) {
172  os << "( )\n";
173  }
174  else if( TF == rowVector ) {
175  os << "(";
176  for( size_t i=0UL; i<(~v).size(); ++i )
177  os << " " << (~v)[i];
178  os << " )\n";
179  }
180  else {
181  for( size_t i=0UL; i<(~v).size(); ++i )
182  os << "( " << std::setw( 11UL ) << (~v)[i] << " )\n";
183  }
184 
185  return os;
186 }
187 //*************************************************************************************************
188 
189 } // namespace blaze
190 
191 #endif
const bool rowVector
Transpose flag for row vectors.
Definition: TransposeFlag.h:73
const DMatTransExpr< MT,!SO > trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:446
Header file for the vector transpose flag types.
Header file for the multiplication trait.
Base class for N-dimensional vectors.The Vector class is a base class for all arbitrarily sized (N-di...
Definition: Forward.h:147
const MultTrait< typename T1::ElementType, typename T2::ElementType >::Type operator,(const Vector< T1, false > &lhs, const Vector< T2, false > &rhs)
Multiplication operator for the scalar product (inner product) of two vectors ( ).
Definition: Vector.h:95
Header file for the Vector CRTP base class.