35#ifndef _BLAZE_MATH_EXPRESSIONS_DMATDMATEQUALEXPR_H_
36#define _BLAZE_MATH_EXPRESSIONS_DMATDMATEQUALEXPR_H_
73struct 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> > );
119inline 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>;
126 if( (*lhs).rows() != (*rhs).rows() || (*lhs).columns() != (*rhs).columns() )
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;
163inline 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>;
172 if( (*lhs).rows() != (*rhs).rows() || (*lhs).columns() != (*rhs).columns() )
179 constexpr size_t SIMDSIZE = SIMDTrait< ElementType_t<MT1> >
::size;
180 constexpr bool remainder( !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 ?
prevMultiple( N, 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;
232inline 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>;
239 if( (*lhs).rows() != (*rhs).rows() || (*lhs).columns() != (*rhs).columns() )
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;
276inline 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>;
285 if( (*lhs).rows() != (*rhs).rows() || (*lhs).columns() != (*rhs).columns() )
292 constexpr size_t SIMDSIZE = SIMDTrait< ElementType_t<MT1> >
::size;
293 constexpr bool remainder( !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 ?
prevMultiple( M, 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;
346inline bool equal(
const DenseMatrix<MT1,SO>& lhs,
const DenseMatrix<MT2,!SO>& rhs )
348 using CT1 = CompositeType_t<MT1>;
349 using CT2 = CompositeType_t<MT2>;
352 if( (*lhs).rows() != (*rhs).rows() || (*lhs).columns() != (*rhs).columns() )
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;
391template<
typename MT1
397 return equal<relaxed>( lhs, rhs );
410template<
typename MT1
416 return !equal<relaxed>( lhs, rhs );
Header file for auxiliary alias declarations.
Header file for kernel specific block sizes.
Header file for the EnableIf class template.
Header file for the HasSIMDEqual type trait.
Header file for the IsPadded type trait.
Header file for the prevMultiple shim.
Header file for the relaxation flag enumeration.
Header file for the RemoveReference type trait.
Header file for all SIMD functionality.
Base class for dense matrices.
Definition: DenseMatrix.h:82
Header file for the DenseMatrix base class.
bool operator!=(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Inequality operator for the comparison of two dense matrices.
Definition: DMatDMatEqualExpr.h:414
bool operator==(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Equality operator for the comparison of two dense matrices.
Definition: DMatDMatEqualExpr.h:395
RelaxationFlag
Relaxation flag for strict or relaxed semantics.
Definition: RelaxationFlag.h:66
BLAZE_ALWAYS_INLINE constexpr auto prevMultiple(T1 value, T2 factor) noexcept
Rounds down an integral value to the previous multiple of a given factor.
Definition: PrevMultiple.h:68
constexpr size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:644
constexpr size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:660
constexpr size_t size(const Matrix< MT, SO > &matrix) noexcept
Returns the total number of elements of the matrix.
Definition: Matrix.h:676
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.
Definition: Assert.h:101
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.
System settings for performance optimizations.
Header file for basic type definitions.