Commit 7ffd1698 authored by Tomáš Oberhuber's avatar Tomáš Oberhuber
Browse files

Fixed VectorView comparison.

parent 8de56429
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -142,9 +142,6 @@ public:
   template< typename VectorExpression >
   VectorView& operator/=( const VectorExpression& expression );

   template< typename Real_, typename Device_, typename Index_ >
   bool operator!=( const VectorView< Real_, Device_, Index_ >& v );

   /**
    * \brief Scalar product
    * @param v
+13 −2
Original line number Diff line number Diff line
@@ -179,16 +179,27 @@ operator/=( const VectorExpression& expression )
   return *this;
}

/*template< typename Real,
          typename Device,
          typename Index >
   template< typename Real_, typename Device_, typename Index_ >
bool
VectorView< Real, Device, Index >::
operator==( const VectorView< Real_, Device_, Index_ >& v ) const
{
   return ArrayView< Real, Device, Index >::operator ==( v );
}

template< typename Real,
          typename Device,
          typename Index >
   template< typename Real_, typename Device_, typename Index_ >
bool
VectorView< Real, Device, Index >::
operator!=( const VectorView< Real_, Device_, Index_ >& v )
operator!=( const VectorView< Real_, Device_, Index_ >& v ) const
{
   return !ArrayView< Real, Device, Index >::operator ==( v );
}
}*/

template< typename Real,
          typename Device,
+21 −6
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@

#pragma once

#include <TNL/Containers/Algorithms/ArrayOperations.h>
#include <TNL/Containers/Expressions/ExpressionTemplates.h>
#include <TNL/Containers/Expressions/ExpressionTemplatesOperations.h>
#include <TNL/Containers/Expressions/Comparison.h>
@@ -173,10 +174,17 @@ bool operator==( const ET& a, const Containers::VectorView< Real, Device, Index
   return Containers::Expressions::ComparisonEQ( a, b );
}

template< typename Real1, typename Real2, typename Device, typename Index >
bool operator==( const Containers::VectorView< Real1, Device, Index >& a, const Containers::VectorView< Real2, Device, Index >& b )
template< typename Real1, typename Real2, typename Device1, typename Device2, typename Index >
bool operator==( const Containers::VectorView< Real1, Device1, Index >& a, const Containers::VectorView< Real2, Device2, Index >& b )
{
   return Containers::Expressions::ComparisonEQ( a, b );
   if( a.getSize() != b.getSize() )
      return false;
   if( a.getSize() == 0 )
      return true;
   return Containers::Algorithms::ArrayOperations< Device1, Device2 >::
            compareMemory( a.getData(),
                           b.getData(),
                           a.getSize() );
}

////
@@ -193,10 +201,17 @@ bool operator!=( const ET& a, const Containers::VectorView< Real, Device, Index
   return Containers::Expressions::ComparisonNE( a, b );
}

template< typename Real1, typename Real2, typename Device, typename Index >
bool operator!=( const Containers::VectorView< Real1, Device, Index >& a, const Containers::VectorView< Real2, Device, Index >& b )
template< typename Real1, typename Real2, typename Device1, typename Device2, typename Index >
bool operator!=( const Containers::VectorView< Real1, Device1, Index >& a, const Containers::VectorView< Real2, Device2, Index >& b )
{
   return Containers::Expressions::ComparisonNE( a, b );
   if( a.getSize() != b.getSize() )
      return false;
   if( a.getSize() == 0 )
      return true;
   return !Containers::Algorithms::ArrayOperations< Device1, Device2 >::
            compareMemory( a.getData(),
                           b.getData(),
                           a.getSize() );
}

////
+2 −2
Original line number Diff line number Diff line
@@ -375,8 +375,8 @@ TYPED_TEST( ArrayViewTest, containsOnlyValue )

TYPED_TEST( ArrayViewTest, comparisonOperator )
{
   using ArrayType = typename TestFixture::ArrayType;
   using ViewType = typename TestFixture::ViewType;
   using ArrayType = Array< double >;//typename TestFixture::ArrayType;
   using ViewType = ArrayView< double >;//typename TestFixture::ViewType;

   ArrayType a( 10 ), b( 10 );
   typename ArrayType::HostType a_host( 10 );