Commit 090a8f29 authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

Added operator() to StaticArray, Array, ArrayView and ExpressionTemplates

Hence, all StaticArray, Array, ArrayView and even expression templates are
directly usable in reduction without the need to create a wrapping fetch
functor. Also NDArray has this interface in 1D.
parent 045241d7
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -498,6 +498,20 @@ class Array
       */
      __cuda_callable__ const Value& operator[]( IndexType i ) const;

      /**
       * \brief Accesses the \e i-th element of the array.
       *
       * Equivalent to \ref operator[], with the same notes and caveats.
       */
      __cuda_callable__ Value& operator()( IndexType i );

      /**
       * \brief Accesses the \e i-th element of the array.
       *
       * Equivalent to \ref operator[], with the same notes and caveats.
       */
      __cuda_callable__ const Value& operator()( IndexType i ) const;

      /**
       * \brief Copy-assignment operator for copying data from another array.
       *
+25 −1
Original line number Diff line number Diff line
/***************************************************************************
                          Array_impl.h  -  description
                          Array.hpp  -  description
                             -------------------
    begin                : Nov 8, 2012
    copyright            : (C) 2012 by Tomas Oberhuber
@@ -555,6 +555,30 @@ operator[]( IndexType i ) const
   return this->data[ i ];
}

template< typename Value,
          typename Device,
          typename Index,
          typename Allocator >
__cuda_callable__
Value&
Array< Value, Device, Index, Allocator >::
operator()( IndexType i )
{
   return operator[]( i );
}

template< typename Value,
          typename Device,
          typename Index,
          typename Allocator >
__cuda_callable__
const Value&
Array< Value, Device, Index, Allocator >::
operator()( IndexType i ) const
{
   return operator[]( i );
}

template< typename Value,
          typename Device,
          typename Index,
+14 −0
Original line number Diff line number Diff line
@@ -370,6 +370,20 @@ public:
   __cuda_callable__
   const Value& operator[]( IndexType i ) const;

   /**
    * \brief Accesses the \e i-th element of the array.
    *
    * Equivalent to \ref operator[], with the same notes and caveats.
    */
   __cuda_callable__ Value& operator()( IndexType i );

   /**
    * \brief Accesses the \e i-th element of the array.
    *
    * Equivalent to \ref operator[], with the same notes and caveats.
    */
   __cuda_callable__ const Value& operator()( IndexType i ) const;

   /**
    * \brief Compares the array view with another array-like container.
    *
+23 −1
Original line number Diff line number Diff line
/***************************************************************************
                          ArrayView_impl.h  -  description
                          ArrayView.hpp  -  description
                             -------------------
    begin                : Sep 1, 2018
    copyright            : (C) 2018 by Tomas Oberhuber et al.
@@ -273,6 +273,28 @@ operator[]( IndexType i ) const
   return data[ i ];
}

template< typename Value,
          typename Device,
          typename Index >
__cuda_callable__
Value&
ArrayView< Value, Device, Index >::
operator()( IndexType i )
{
   return operator[]( i );
}

template< typename Value,
          typename Device,
          typename Index >
__cuda_callable__
const Value&
ArrayView< Value, Device, Index >::
operator()( IndexType i ) const
{
   return operator[]( i );
}

template< typename Value,
          typename Device,
          typename Index >
+24 −0
Original line number Diff line number Diff line
@@ -88,6 +88,12 @@ struct BinaryExpressionTemplate< T1, T2, Operation, VectorExpressionVariable, Ve
      return Operation::evaluate( op1[ i ], op2[ i ] );
   }

   __cuda_callable__
   RealType operator()( const IndexType i ) const
   {
      return operator[]( i );
   }

   __cuda_callable__
   IndexType getSize() const
   {
@@ -131,6 +137,12 @@ struct BinaryExpressionTemplate< T1, T2, Operation, VectorExpressionVariable, Ar
      return Operation::evaluate( op1[ i ], op2 );
   }

   __cuda_callable__
   RealType operator()( const IndexType i ) const
   {
      return operator[]( i );
   }

   __cuda_callable__
   IndexType getSize() const
   {
@@ -174,6 +186,12 @@ struct BinaryExpressionTemplate< T1, T2, Operation, ArithmeticVariable, VectorEx
      return Operation::evaluate( op1, op2[ i ] );
   }

   __cuda_callable__
   RealType operator()( const IndexType i ) const
   {
      return operator[]( i );
   }

   __cuda_callable__
   IndexType getSize() const
   {
@@ -218,6 +236,12 @@ struct UnaryExpressionTemplate
      return Operation::evaluate( operand[ i ] );
   }

   __cuda_callable__
   RealType operator()( const IndexType i ) const
   {
      return operator[]( i );
   }

   __cuda_callable__
   IndexType getSize() const
   {
Loading