35 #ifndef _BLAZE_MATH_EXPRESSIONS_DMATDMATEQUALEXPR_H_ 36 #define _BLAZE_MATH_EXPRESSIONS_DMATDMATEQUALEXPR_H_ 71 template<
typename MT1
73 struct DMatDMatEqualExprHelper
77 using CT1 = RemoveReference_t< CompositeType_t<MT1> >;
80 using CT2 = RemoveReference_t< CompositeType_t<MT2> >;
84 static constexpr
bool value =
85 ( useOptimizedKernels &&
88 HasSIMDEqual_v< ElementType_t<CT1>, ElementType_t<CT2> > );
119 inline auto equal(
const DenseMatrix<MT1,false>& lhs,
const DenseMatrix<MT2,false>& rhs )
120 -> DisableIf_t< DMatDMatEqualExprHelper<MT1,MT2>::value,
bool >
122 using CT1 = CompositeType_t<MT1>;
123 using CT2 = CompositeType_t<MT2>;
135 for(
size_t i=0UL; i<A.rows(); ++i ) {
136 for(
size_t j=0UL; j<A.columns(); ++j ) {
137 if( !equal<RF>( A(i,j), B(i,j) ) )
return false;
163 inline auto equal(
const DenseMatrix<MT1,false>& lhs,
const DenseMatrix<MT2,false>& rhs )
164 -> EnableIf_t< DMatDMatEqualExprHelper<MT1,MT2>::value,
bool >
166 using CT1 = CompositeType_t<MT1>;
167 using CT2 = CompositeType_t<MT2>;
168 using XT1 = RemoveReference_t<CT1>;
169 using XT2 = RemoveReference_t<CT2>;
179 constexpr
size_t SIMDSIZE = SIMDTrait< ElementType_t<MT1> >
::size;
180 constexpr
bool remainder( !usePadding || !IsPadded_v<XT1> || !IsPadded_v<XT2> );
182 const size_t M( A.rows() );
183 const size_t N( A.columns() );
185 const size_t jpos( ( remainder )?( N &
size_t(-SIMDSIZE) ):( N ) );
188 for(
size_t i=0UL; i<M; ++i )
192 for( ; (j+SIMDSIZE*3UL) < jpos; j+=SIMDSIZE*4UL ) {
193 if( !equal<RF>( A.load(i,j ), B.load(i,j ) ) )
return false;
194 if( !equal<RF>( A.load(i,j+SIMDSIZE ), B.load(i,j+SIMDSIZE ) ) )
return false;
195 if( !equal<RF>( A.load(i,j+SIMDSIZE*2UL), B.load(i,j+SIMDSIZE*2UL) ) )
return false;
196 if( !equal<RF>( A.load(i,j+SIMDSIZE*3UL), B.load(i,j+SIMDSIZE*3UL) ) )
return false;
198 for( ; (j+SIMDSIZE) < jpos; j+=SIMDSIZE*2UL ) {
199 if( !equal<RF>( A.load(i,j ), B.load(i,j ) ) )
return false;
200 if( !equal<RF>( A.load(i,j+SIMDSIZE), B.load(i,j+SIMDSIZE) ) )
return false;
202 for( ; j<jpos; j+=SIMDSIZE ) {
203 if( !equal<RF>( A.load(i,j), B.load(i,j) ) )
return false;
205 for( ; remainder && j<A.columns(); ++j ) {
206 if( !equal<RF>( A(i,j), B(i,j) ) )
return false;
232 inline auto equal(
const DenseMatrix<MT1,true>& lhs,
const DenseMatrix<MT2,true>& rhs )
233 -> DisableIf_t< DMatDMatEqualExprHelper<MT1,MT2>::value,
bool >
235 using CT1 = CompositeType_t<MT1>;
236 using CT2 = CompositeType_t<MT2>;
248 for(
size_t j=0UL; j<A.columns(); ++j ) {
249 for(
size_t i=0UL; i<A.rows(); ++i ) {
250 if( !equal<RF>( A(i,j), B(i,j) ) )
return false;
276 inline auto equal(
const DenseMatrix<MT1,true>& lhs,
const DenseMatrix<MT2,true>& rhs )
277 -> EnableIf_t< DMatDMatEqualExprHelper<MT1,MT2>::value,
bool >
279 using CT1 = CompositeType_t<MT1>;
280 using CT2 = CompositeType_t<MT2>;
281 using XT1 = RemoveReference_t<CT1>;
282 using XT2 = RemoveReference_t<CT2>;
292 constexpr
size_t SIMDSIZE = SIMDTrait< ElementType_t<MT1> >
::size;
293 constexpr
bool remainder( !usePadding || !IsPadded_v<XT1> || !IsPadded_v<XT2> );
295 const size_t M( A.rows() );
296 const size_t N( A.columns() );
298 const size_t ipos( ( remainder )?( M &
size_t(-SIMDSIZE) ):( M ) );
301 for(
size_t j=0UL; j<N; ++j )
305 for( ; (i+SIMDSIZE*3UL) < ipos; i+=SIMDSIZE*4UL ) {
306 if( !equal<RF>( A.load(i ,j), B.load(i ,j) ) )
return false;
307 if( !equal<RF>( A.load(i+SIMDSIZE ,j), B.load(i+SIMDSIZE ,j) ) )
return false;
308 if( !equal<RF>( A.load(i+SIMDSIZE*2UL,j), B.load(i+SIMDSIZE*2UL,j) ) )
return false;
309 if( !equal<RF>( A.load(i+SIMDSIZE*3UL,j), B.load(i+SIMDSIZE*3UL,j) ) )
return false;
311 for( ; (i+SIMDSIZE) < ipos; i+=SIMDSIZE*2UL ) {
312 if( !equal<RF>( A.load(i ,j), B.load(i ,j) ) )
return false;
313 if( !equal<RF>( A.load(i+SIMDSIZE,j), B.load(i+SIMDSIZE,j) ) )
return false;
315 for( ; i<ipos; i+=SIMDSIZE ) {
316 if( !equal<RF>( A.load(i,j), B.load(i,j) ) )
return false;
318 for( ; remainder && i<M; ++i ) {
319 if( !equal<RF>( A(i,j), B(i,j) ) )
return false;
346 inline bool equal(
const DenseMatrix<MT1,SO>& lhs,
const DenseMatrix<MT2,!SO>& rhs )
348 using CT1 = CompositeType_t<MT1>;
349 using CT2 = CompositeType_t<MT2>;
361 const size_t rows ( A.rows() );
362 const size_t columns( A.columns() );
363 const size_t block ( BLOCK_SIZE );
365 for(
size_t ii=0UL; ii<
rows; ii+=block ) {
366 const size_t iend( (
rows < ii+block )?(
rows ):( ii+block ) );
367 for(
size_t jj=0UL; jj<
columns; jj+=block ) {
368 const size_t jend( (
columns < jj+block )?(
columns ):( jj+block ) );
369 for(
size_t i=ii; i<iend; ++i ) {
370 for(
size_t j=jj; j<jend; ++j ) {
371 if( !equal<RF>( A(i,j), B(i,j) ) )
return false;
391 template<
typename MT1
397 return equal<relaxed>( lhs, rhs );
410 template<
typename MT1
416 return !equal<relaxed>( lhs, rhs );
Header file for auxiliary alias declarations.
Header file for kernel specific block sizes.
Header file for basic type definitions.
System settings for performance optimizations.
constexpr size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:514
Base class for dense matrices.The DenseMatrix class is a base class for all dense matrix classes....
Definition: DenseMatrix.h:81
Header file for the DisableIf class template.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
Header file for the DenseMatrix base class.
constexpr bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:253
Header file for all SIMD functionality.
Header file for the equal shim.
constexpr bool operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:293
Header file for the EnableIf class template.
Header file for the IsPadded type trait.
Header file for the relaxation flag types.
constexpr size_t size(const Matrix< MT, SO > &matrix) noexcept
Returns the total number of elements of the matrix.
Definition: Matrix.h:530
constexpr size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:498
Header file for the RemoveReference type trait.
Header file for the HasSIMDEqual type trait.
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression,...
Definition: Assert.h:101
bool equal(const SharedValue< T1 > &lhs, const SharedValue< T2 > &rhs)
Equality check for a two shared values.
Definition: SharedValue.h:342