Blaze 3.9
DVecSVecEqualExpr.h
Go to the documentation of this file.
1//=================================================================================================
33//=================================================================================================
34
35#ifndef _BLAZE_MATH_EXPRESSIONS_DVECSVECEQUALEXPR_H_
36#define _BLAZE_MATH_EXPRESSIONS_DVECSVECEQUALEXPR_H_
37
38
39//*************************************************************************************************
40// Includes
41//*************************************************************************************************
42
43#include <blaze/math/Aliases.h>
50#include <blaze/util/Types.h>
51
52
53namespace blaze {
54
55//=================================================================================================
56//
57// GLOBAL BINARY RELATIONAL OPERATORS
58//
59//=================================================================================================
60
61//*************************************************************************************************
75template< RelaxationFlag RF // Relaxation flag
76 , typename VT1 // Type of the left-hand side dense vector
77 , bool TF1 // Transpose flag of the left-hand side dense vector
78 , typename VT2 // Type of the right-hand side sparse vector
79 , bool TF2 > // Transpose flag of the right-hand side sparse vector
80inline bool equal( const DenseVector<VT1,TF1>& lhs, const SparseVector<VT2,TF2>& rhs )
81{
82 using CT1 = CompositeType_t<VT1>;
83 using CT2 = CompositeType_t<VT2>;
84
85 // Early exit in case the vector sizes don't match
86 if( (*lhs).size() != (*rhs).size() ) return false;
87
88 // Evaluation of the dense vector and sparse vector operand
89 CT1 a( *lhs );
90 CT2 b( *rhs );
91
92 // In order to compare the two vectors, the data values of the lower-order data
93 // type are converted to the higher-order data type within the equal function.
94 size_t i( 0UL );
95
96 for( auto element=b.begin(); element!=b.end(); ++element, ++i ) {
97 for( ; i<element->index(); ++i ) {
98 if( !isDefault<RF>( a[i] ) ) return false;
99 }
100 if( !equal<RF>( element->value(), a[i] ) ) return false;
101 }
102 for( ; i<a.size(); ++i ) {
103 if( !isDefault<RF>( a[i] ) ) return false;
104 }
105
106 return true;
107}
109//*************************************************************************************************
110
111
112//*************************************************************************************************
126template< RelaxationFlag RF // Relaxation flag
127 , typename VT1 // Type of the left-hand side sparse vector
128 , bool TF1 // Transpose flag of the left-hand side sparse vector
129 , typename VT2 // Type of the right-hand side dense vector
130 , bool TF2 > // Transpose flag of the right-hand side dense vector
131inline bool equal( const SparseVector<VT1,TF1>& lhs, const DenseVector<VT2,TF2>& rhs )
132{
133 return equal<RF>( rhs, lhs );
134}
136//*************************************************************************************************
137
138
139//*************************************************************************************************
147template< typename VT1 // Type of the left-hand side dense vector
148 , bool TF1 // Transpose flag of the left-hand side dense vector
149 , typename VT2 // Type of the right-hand side sparse vector
150 , bool TF2 > // Transpose flag of the right-hand side sparse vector
151inline bool operator==( const DenseVector<VT1,TF1>& lhs, const SparseVector<VT2,TF2>& rhs )
152{
153 return equal<relaxed>( lhs, rhs );
154}
155//*************************************************************************************************
156
157
158//*************************************************************************************************
166template< typename VT1 // Type of the left-hand side sparse vector
167 , bool TF1 // Transpose flag of the left-hand side sparse vector
168 , typename VT2 // Type of the right-hand side dense vector
169 , bool TF2 > // Transpose flag of the right-hand side dense vector
170inline bool operator==( const SparseVector<VT1,TF1>& lhs, const DenseVector<VT2,TF2>& rhs )
171{
172 return equal<relaxed>( rhs, lhs );
173}
174//*************************************************************************************************
175
176
177//*************************************************************************************************
185template< typename VT1 // Type of the left-hand side dense vector
186 , bool TF1 // Transpose flag of the left-hand side dense vector
187 , typename VT2 // Type of the right-hand side sparse vector
188 , bool TF2 > // Transpose flag of the right-hand side sparse vector
189inline bool operator!=( const DenseVector<VT1,TF1>& lhs, const SparseVector<VT2,TF2>& rhs )
190{
191 return !equal<relaxed>( lhs, rhs );
192}
193//*************************************************************************************************
194
195
196//*************************************************************************************************
204template< typename VT1 // Type of the left-hand side sparse vector
205 , bool TF1 // Transpose flag of the left-hand side sparse vector
206 , typename VT2 // Type of the right-hand side dense vector
207 , bool TF2 > // Transpose flag of the right-hand side dense vector
208inline bool operator!=( const SparseVector<VT1,TF1>& lhs, const DenseVector<VT2,TF2>& rhs )
209{
210 return !equal<relaxed>( rhs, lhs );
211}
212//*************************************************************************************************
213
214} // namespace blaze
215
216#endif
Header file for auxiliary alias declarations.
Header file for the isDefault shim.
Deactivation of problematic macros.
Header file for the relaxation flag enumeration.
Base class for N-dimensional dense vectors.
Definition: DenseVector.h:77
Base class for sparse vectors.
Definition: SparseVector.h:72
Header file for the DenseVector base class.
Header file for the SparseVector base class.
bool operator!=(const SparseVector< VT1, TF1 > &lhs, const DenseVector< VT2, TF2 > &rhs)
Inequality operator for the comparison of a sparse vector and a dense vector.
Definition: DVecSVecEqualExpr.h:208
bool operator==(const SparseVector< VT1, TF1 > &lhs, const DenseVector< VT2, TF2 > &rhs)
Equality operator for the comparison of a sparse vector and a dense vector.
Definition: DVecSVecEqualExpr.h:170
RelaxationFlag
Relaxation flag for strict or relaxed semantics.
Definition: RelaxationFlag.h:66
bool equal(const SharedValue< T1 > &lhs, const SharedValue< T2 > &rhs)
Equality check for a two shared values.
Definition: SharedValue.h:343
Header file for the equal shim.
Header file for basic type definitions.