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>& v );
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  typename VT::CompositeType tmp( ~v );
172 
173  if( tmp.size() == 0UL ) {
174  os << "( )\n";
175  }
176  else if( TF == rowVector ) {
177  os << "(";
178  for( size_t i=0UL; i<tmp.size(); ++i )
179  os << " " << tmp[i];
180  os << " )\n";
181  }
182  else {
183  for( size_t i=0UL; i<tmp.size(); ++i )
184  os << "( " << std::setw( 11UL ) << tmp[i] << " )\n";
185  }
186 
187  return os;
188 }
189 //*************************************************************************************************
190 
191 } // namespace blaze
192 
193 #endif
const bool rowVector
Transpose flag for row vectors.
Definition: TransposeFlag.h:73
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2588
Header file for the vector transpose flag types.
Header file for the multiplication trait.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
Base class for N-dimensional vectors.The Vector class is a base class for all arbitrarily sized (N-di...
Definition: Forward.h:164
const DMatTransExpr< MT,!SO > trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:944
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.