Blaze 3.9
SVecSVecEqualExpr.h
Go to the documentation of this file.
1//=================================================================================================
33//=================================================================================================
34
35#ifndef _BLAZE_MATH_EXPRESSIONS_SVECSVECEQUALEXPR_H_
36#define _BLAZE_MATH_EXPRESSIONS_SVECSVECEQUALEXPR_H_
37
38
39//*************************************************************************************************
40// Includes
41//*************************************************************************************************
42
43#include <blaze/math/Aliases.h>
49
50
51namespace blaze {
52
53//=================================================================================================
54//
55// GLOBAL BINARY RELATIONAL OPERATORS
56//
57//=================================================================================================
58
59//*************************************************************************************************
72template< RelaxationFlag RF // Relaxation flag
73 , typename VT1 // Type of the left-hand side sparse vector
74 , bool TF1 // Transpose flag of the left-hand side sparse vector
75 , typename VT2 // Type of the right-hand side sparse vector
76 , bool TF2 > // Transpose flag of the right-hand side sparse vector
77inline bool equal( const SparseVector<VT1,TF1>& lhs, const SparseVector<VT2,TF2>& rhs )
78{
79 using CT1 = CompositeType_t<VT1>;
80 using CT2 = CompositeType_t<VT2>;
81
82 // Early exit in case the vector sizes don't match
83 if( (*lhs).size() != (*rhs).size() ) return false;
84
85 // Evaluation of the two sparse vector operands
86 CT1 a( *lhs );
87 CT2 b( *rhs );
88
89 // In order to compare the two vectors, the data values of the lower-order data
90 // type are converted to the higher-order data type within the equal function.
91 const auto lend( a.end() );
92 const auto rend( b.end() );
93
94 auto lelem( a.begin() );
95 auto relem( b.begin() );
96
97 while( lelem != lend && relem != rend )
98 {
99 if( isDefault<RF>( lelem->value() ) ) { ++lelem; continue; }
100 if( isDefault<RF>( relem->value() ) ) { ++relem; continue; }
101
102 if( lelem->index() != relem->index() || !equal<RF>( lelem->value(), relem->value() ) ) {
103 return false;
104 }
105 else {
106 ++lelem;
107 ++relem;
108 }
109 }
110
111 while( lelem != lend ) {
112 if( !isDefault<RF>( lelem->value() ) )
113 return false;
114 ++lelem;
115 }
116
117 while( relem != rend ) {
118 if( !isDefault<RF>( relem->value() ) )
119 return false;
120 ++relem;
121 }
122
123 return true;
124}
126//*************************************************************************************************
127
128
129//*************************************************************************************************
137template< typename VT1 // Type of the left-hand side sparse vector
138 , bool TF1 // Transpose flag of the left-hand side sparse vector
139 , typename VT2 // Type of the right-hand side sparse vector
140 , bool TF2 > // Transpose flag of the right-hand side sparse vector
141inline bool operator==( const SparseVector<VT1,TF1>& lhs, const SparseVector<VT2,TF2>& rhs )
142{
143 return equal<relaxed>( lhs, rhs );
144}
145//*************************************************************************************************
146
147
148//*************************************************************************************************
156template< typename VT1 // Type of the left-hand side sparse vector
157 , bool TF1 // Transpose flag of the left-hand side sparse vector
158 , typename VT2 // Type of the right-hand side sparse vector
159 , bool TF2 > // Transpose flag of the right-hand side sparse vector
160inline bool operator!=( const SparseVector<VT1,TF1>& lhs, const SparseVector<VT2,TF2>& rhs )
161{
162 return !equal<relaxed>( lhs, rhs );
163}
164//*************************************************************************************************
165
166} // namespace blaze
167
168#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 sparse vectors.
Definition: SparseVector.h:72
Header file for the SparseVector base class.
RelaxationFlag
Relaxation flag for strict or relaxed semantics.
Definition: RelaxationFlag.h:66
bool operator!=(const SparseVector< VT1, TF1 > &lhs, const SparseVector< VT2, TF2 > &rhs)
Inequality operator for the comparison of two sparse vectors.
Definition: SVecSVecEqualExpr.h:160
bool operator==(const SparseVector< VT1, TF1 > &lhs, const SparseVector< VT2, TF2 > &rhs)
Equality operator for the comparison of two sparse vectors.
Definition: SVecSVecEqualExpr.h:141
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.