From 38584f29d232f01606a68d665ad70c4ca3d8612f Mon Sep 17 00:00:00 2001 From: Lukas Cejka <lukas.ostatek@gmail.com> Date: Sun, 29 Sep 2019 22:22:26 +0200 Subject: [PATCH] Added comparison and assignment operators. --- src/TNL/Matrices/AdEllpack.h | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/TNL/Matrices/AdEllpack.h b/src/TNL/Matrices/AdEllpack.h index 0a68102824..90faa91ee1 100644 --- a/src/TNL/Matrices/AdEllpack.h +++ b/src/TNL/Matrices/AdEllpack.h @@ -107,6 +107,15 @@ private: template< typename Real, typename Device, typename Index > class AdEllpack : public Sparse< Real, Device, Index > { +private: + // convenient template alias for controlling the selection of copy-assignment operator + template< typename Device2 > + using Enabler = std::enable_if< ! std::is_same< Device2, Device >::value >; + + // friend class will be needed for templated assignment operators + template< typename Real2, typename Device2, typename Index2 > + friend class ChunkedEllpack; + public: typedef Real RealType; @@ -135,6 +144,12 @@ public: void setLike( const AdEllpack< Real2, Device2, Index2 >& matrix ); void reset(); + + template< typename Real2, typename Device2, typename Index2 > + bool operator == ( const AdEllpack< Real2, Device2, Index2 >& matrix ) const; + + template< typename Real2, typename Device2, typename Index2 > + bool operator != ( const AdEllpack< Real2, Device2, Index2 >& matrix ) const; bool setElement( const IndexType row, const IndexType column, @@ -172,8 +187,16 @@ public: typename OutVector > void vectorProduct( const InVector& inVector, OutVector& outVector ) const; + + // copy assignment + AdEllpack& operator=( const AdEllpack& matrix ); - void save( File& file ) const; + // cross-device copy assignment + template< typename Real2, typename Device2, typename Index2, + typename = typename Enabler< Device2 >::type > + AdEllpack& operator=( const AdEllpack< Real2, Device2, Index2 >& matrix ); + + bool save( File& file ) const; void load( File& file ); -- GitLab