TDVecSVecMultExpr.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_EXPRESSIONS_TDVECSVECMULTEXPR_H_
36 #define _BLAZE_MATH_EXPRESSIONS_TDVECSVECMULTEXPR_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <blaze/math/Aliases.h>
48 #include <blaze/math/Exception.h>
53 #include <blaze/util/Types.h>
55 
56 
57 namespace blaze {
58 
59 //=================================================================================================
60 //
61 // GLOBAL BINARY ARITHMETIC OPERATORS
62 //
63 //=================================================================================================
64 
65 //*************************************************************************************************
96 template< typename T1 // Type of the left-hand side dense vector
97  , typename T2 > // Type of the right-hand side sparse vector
98 inline const MultTrait_< ElementType_<T1>, ElementType_<T2> >
100 {
102 
103  typedef CompositeType_<T1> Lhs; // Composite type of the left-hand side dense vector expression
104  typedef CompositeType_<T2> Rhs; // Composite type of the right-hand side sparse vector expression
105  typedef RemoveReference_<Lhs> X1; // Auxiliary type for the left-hand side composite type
106  typedef RemoveReference_<Rhs> X2; // Auxiliary type for the right-hand side composite type
107  typedef ElementType_<X1> ET1; // Element type of the left-hand side dense vector expression
108  typedef ElementType_<X2> ET2; // Element type of the right-hand side sparse vector expression
109  typedef MultTrait_<ET1,ET2> MultType; // Multiplication result type
110  typedef ConstIterator_<X2> ConstIterator; // Iterator type of the right-hand sparse vector expression
111 
116 
117  if( (~lhs).size() != (~rhs).size() ) {
118  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
119  }
120 
121  Lhs left ( ~lhs );
122  Rhs right( ~rhs );
123 
124  ConstIterator element( right.begin() );
125  ConstIterator end ( right.end() );
126 
127  MultType sp = MultType();
128 
129  if( element != end ) {
130  sp = left[ element->index() ] * element->value();
131  ++element;
132  for( ; element!=end; ++element )
133  sp += left[ element->index() ] * element->value();
134  }
135 
136  return sp;
137 }
138 //*************************************************************************************************
139 
140 } // namespace blaze
141 
142 #endif
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.This macro encapsulates the default way o...
Definition: Exception.h:235
Header file for auxiliary alias declarations.
const DMatDMatMultExpr< T1, T2 > operator*(const DenseMatrix< T1, false > &lhs, const DenseMatrix< T2, false > &rhs)
Multiplication operator for the multiplication of two row-major dense matrices ( ).
Definition: DMatDMatMultExpr.h:7800
Header file for basic type definitions.
Header file for the SparseVector base class.
#define BLAZE_CONSTRAINT_MUST_BE_COLUMN_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a column dense or sparse vector type...
Definition: ColumnVector.h:61
BLAZE_ALWAYS_INLINE size_t size(const Vector< VT, TF > &vector) noexcept
Returns the current size/dimension of the vector.
Definition: Vector.h:258
Header file for the DenseVector base class.
typename MultTrait< T1, T2 >::Type MultTrait_
Auxiliary alias declaration for the MultTrait class template.The MultTrait_ alias declaration provide...
Definition: MultTrait.h:245
Constraint on the transpose flag of vector types.
typename T::CompositeType CompositeType_
Alias declaration for nested CompositeType type definitions.The CompositeType_ alias declaration prov...
Definition: Aliases.h:83
Header file for the multiplication trait.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2647
typename T::ElementType ElementType_
Alias declaration for nested ElementType type definitions.The ElementType_ alias declaration provides...
Definition: Aliases.h:163
Base class for N-dimensional dense vectors.The DenseVector class is a base class for all arbitrarily ...
Definition: DenseVector.h:70
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a sparse, N-dimensional vector type...
Definition: SparseVector.h:61
Constraint on the data type.
typename RemoveReference< T >::Type RemoveReference_
Auxiliary alias declaration for the RemoveReference type trait.The RemoveReference_ alias declaration...
Definition: RemoveReference.h:95
Header file for the exception macros of the math module.
BLAZE_ALWAYS_INLINE MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:254
Constraint on the data type.
Header file for the RemoveReference type trait.
typename T::ConstIterator ConstIterator_
Alias declaration for nested ConstIterator type definitions.The ConstIterator_ alias declaration prov...
Definition: Aliases.h:103
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a dense, N-dimensional vector type...
Definition: DenseVector.h:61
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:110
#define BLAZE_FUNCTION_TRACE
Function trace macro.This macro can be used to reliably trace function calls. In case function tracin...
Definition: FunctionTrace.h:157
#define BLAZE_CONSTRAINT_MUST_BE_ROW_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a row dense or sparse vector type (i...
Definition: RowVector.h:61
Constraint on the transpose flag of vector types.
Header file for the FunctionTrace class.