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

Fixed Size definition in StaticArray.

parent d7424e5b
Loading
Loading
Loading
Loading
+18 −19
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@ class StaticArray
   public:
   using ValueType = Value;
   using IndexType = int;
   enum { size = Size };

   /**
    * \brief Gets size of this array.
@@ -187,9 +186,9 @@ template< typename Value >
class StaticArray< 1, Value >
{
   public:
   typedef Value ValueType;
   typedef int     IndexType;
   enum { size = 1 };
   using ValueType = Value;
   using IndexType = int;
   enum { Size = 1 };

   /**
    * \brief Gets size of this array.
@@ -206,7 +205,7 @@ class StaticArray< 1, Value >
   // reference: https://stackoverflow.com/q/4610503
   template< typename _unused = void >
   __cuda_callable__
   inline StaticArray( const Value v[ size ] );
   inline StaticArray( const Value v[ Size ] );

   /** \brief See StaticArray::StaticArray(const Value& v).*/
   __cuda_callable__
@@ -214,7 +213,7 @@ class StaticArray< 1, Value >

   /** \brief See StaticArray::StaticArray( const StaticArray< Size, Value >& v ).*/
   __cuda_callable__
   inline StaticArray( const StaticArray< size, Value >& v );
   inline StaticArray( const StaticArray< Size, Value >& v );

   inline StaticArray( const std::initializer_list< Value > &elems );

@@ -286,7 +285,7 @@ class StaticArray< 1, Value >
   std::ostream& write( std::ostream& str, const char* separator = " " ) const;

   protected:
   Value data[ size ];
   Value data[ Size ];
};

/**
@@ -296,9 +295,9 @@ template< typename Value >
class StaticArray< 2, Value >
{
   public:
   typedef Value ValueType;
   typedef int     IndexType;
   enum { size = 2 };
   using ValueType = Value;
   using IndexType = int;
   enum { Size = 2 };

   /**
    * \brief Gets size of this array.
@@ -315,7 +314,7 @@ class StaticArray< 2, Value >
   // reference: https://stackoverflow.com/q/4610503
   template< typename _unused = void >
   __cuda_callable__
   inline StaticArray( const Value v[ size ] );
   inline StaticArray( const Value v[ Size ] );

   /** \brief See StaticArray::StaticArray(const Value& v).*/
   __cuda_callable__
@@ -332,7 +331,7 @@ class StaticArray< 2, Value >

   /** \brief See StaticArray::StaticArray( const StaticArray< Size, Value >& v ).*/
   __cuda_callable__
   inline StaticArray( const StaticArray< size, Value >& v );
   inline StaticArray( const StaticArray< Size, Value >& v );

   inline StaticArray( const std::initializer_list< Value > &elems );

@@ -411,7 +410,7 @@ class StaticArray< 2, Value >
   std::ostream& write( std::ostream& str, const char* separator = " " ) const;

   protected:
   Value data[ size ];
   Value data[ Size ];
};

/**
@@ -421,9 +420,9 @@ template< typename Value >
class StaticArray< 3, Value >
{
   public:
   typedef Value ValueType;
   typedef int     IndexType;
   enum { size = 3 };
   using ValueType = Value;
   using IndexType = int;
   enum { Size = 3 };

   /**
    * \brief Gets size of this array.
@@ -440,7 +439,7 @@ class StaticArray< 3, Value >
   // reference: https://stackoverflow.com/q/4610503
   template< typename _unused = void >
   __cuda_callable__
   inline StaticArray( const Value v[ size ] );
   inline StaticArray( const Value v[ Size ] );

   /** \brief See StaticArray::StaticArray(const Value& v).*/
   __cuda_callable__
@@ -458,7 +457,7 @@ class StaticArray< 3, Value >

   /** \brief See StaticArray::StaticArray( const StaticArray< Size, Value >& v ).*/
   __cuda_callable__
   inline StaticArray( const StaticArray< size, Value >& v );
   inline StaticArray( const StaticArray< Size, Value >& v );

   StaticArray( const std::initializer_list< Value > &elems );

@@ -545,7 +544,7 @@ class StaticArray< 3, Value >
   std::ostream& write( std::ostream& str, const char* separator = " " ) const;

   protected:
   Value data[ size ];
   Value data[ Size ];
};

template< int Size, typename Value >
+9 −9
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@ template< typename Value >
__cuda_callable__
constexpr int StaticArray< 1, Value >::getSize()
{
   return size;
   return Size;
}

template< typename Value >
@@ -32,7 +32,7 @@ inline StaticArray< 1, Value >::StaticArray()
template< typename Value >
   template< typename _unused >
__cuda_callable__
inline StaticArray< 1, Value >::StaticArray( const Value v[ size ] )
inline StaticArray< 1, Value >::StaticArray( const Value v[ Size ] )
{
   data[ 0 ] = v[ 0 ];
}
@@ -46,7 +46,7 @@ inline StaticArray< 1, Value >::StaticArray( const Value& v )

template< typename Value >
__cuda_callable__
inline StaticArray< 1, Value >::StaticArray( const StaticArray< size, Value >& v )
inline StaticArray< 1, Value >::StaticArray( const StaticArray< Size, Value >& v )
{
   data[ 0 ] = v[ 0 ];
}
@@ -63,7 +63,7 @@ template< typename Value >
String StaticArray< 1, Value >::getType()
{
   return String( "Containers::StaticArray< " ) +
          convertToString( size ) +
          convertToString( Size ) +
          String( ", " ) +
          TNL::getType< Value >() +
          String( " >" );
@@ -88,7 +88,7 @@ __cuda_callable__
inline const Value& StaticArray< 1, Value >::operator[]( int i ) const
{
   TNL_ASSERT_GE( i, 0, "Element index must be non-negative." );
   TNL_ASSERT_LT( i, size, "Element index is out of bounds." );
   TNL_ASSERT_LT( i, Size, "Element index is out of bounds." );
   return data[ i ];
}

@@ -97,7 +97,7 @@ __cuda_callable__
inline Value& StaticArray< 1, Value >::operator[]( int i )
{
   TNL_ASSERT_GE( i, 0, "Element index must be non-negative." );
   TNL_ASSERT_LT( i, size, "Element index is out of bounds." );
   TNL_ASSERT_LT( i, Size, "Element index is out of bounds." );
   return data[ i ];
}

@@ -137,7 +137,7 @@ template< typename Value >
__cuda_callable__
inline bool StaticArray< 1, Value >::operator == ( const Array& array ) const
{
   return( ( int ) size == ( int ) Array::size && data[ 0 ] == array[ 0 ] );
   return( ( int ) Size == ( int ) Array::getSize() && data[ 0 ] == array[ 0 ] );
}

template< typename Value >
@@ -170,14 +170,14 @@ inline void StaticArray< 1, Value >::setValue( const ValueType& val )
template< typename Value >
bool StaticArray< 1, Value >::save( File& file ) const
{
   file.save< Value, Value, Devices::Host >( data, size );
   file.save< Value, Value, Devices::Host >( data, Size );
   return true;
}

template< typename Value >
bool StaticArray< 1, Value >::load( File& file)
{
   file.load< Value, Value, Devices::Host >( data, size );
   file.load< Value, Value, Devices::Host >( data, Size );
   return true;
}

+9 −9
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ template< typename Value >
__cuda_callable__
constexpr int StaticArray< 2, Value >::getSize()
{
   return size;
   return Size;
}

template< typename Value >
@@ -33,7 +33,7 @@ inline StaticArray< 2, Value >::StaticArray()
template< typename Value >
   template< typename _unused >
__cuda_callable__
inline StaticArray< 2, Value >::StaticArray( const Value v[ size ] )
inline StaticArray< 2, Value >::StaticArray( const Value v[ Size ] )
{
   data[ 0 ] = v[ 0 ];
   data[ 1 ] = v[ 1 ];
@@ -57,7 +57,7 @@ inline StaticArray< 2, Value >::StaticArray( const Value& v1, const Value& v2 )

template< typename Value >
__cuda_callable__
inline StaticArray< 2, Value >::StaticArray( const StaticArray< size, Value >& v )
inline StaticArray< 2, Value >::StaticArray( const StaticArray< Size, Value >& v )
{
   data[ 0 ] = v[ 0 ];
   data[ 1 ] = v[ 1 ];
@@ -75,7 +75,7 @@ template< typename Value >
String StaticArray< 2, Value >::getType()
{
   return String( "Containers::StaticArray< " ) +
          convertToString( size ) +
          convertToString( Size ) +
          String( ", " ) +
          TNL::getType< Value >() +
          String( " >" );
@@ -100,7 +100,7 @@ __cuda_callable__
inline const Value& StaticArray< 2, Value >::operator[]( int i ) const
{
   TNL_ASSERT_GE( i, 0, "Element index must be non-negative." );
   TNL_ASSERT_LT( i, size, "Element index is out of bounds." );
   TNL_ASSERT_LT( i, Size, "Element index is out of bounds." );
   return data[ i ];
}

@@ -109,7 +109,7 @@ __cuda_callable__
inline Value& StaticArray< 2, Value >::operator[]( int i )
{
   TNL_ASSERT_GE( i, 0, "Element index must be non-negative." );
   TNL_ASSERT_LT( i, size, "Element index is out of bounds." );
   TNL_ASSERT_LT( i, Size, "Element index is out of bounds." );
   return data[ i ];
}

@@ -165,7 +165,7 @@ template< typename Value >
__cuda_callable__
inline bool StaticArray< 2, Value >::operator == ( const Array& array ) const
{
   return( ( int ) size == ( int ) Array::size &&
   return( ( int ) Size == ( int ) Array::getSize() &&
           data[ 0 ] == array[ 0 ] &&
           data[ 1 ] == array[ 1 ] );
}
@@ -200,14 +200,14 @@ inline void StaticArray< 2, Value >::setValue( const ValueType& val )
template< typename Value >
bool StaticArray< 2, Value >::save( File& file ) const
{
   file.save< Value, Value, Devices::Host >( data, size );
   file.save< Value, Value, Devices::Host >( data, Size );
   return true;
}

template< typename Value >
bool StaticArray< 2, Value >::load( File& file)
{
   file.load< Value, Value, Devices::Host >( data, size );
   file.load< Value, Value, Devices::Host >( data, Size );
   return true;
}

+9 −9
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ template< typename Value >
__cuda_callable__
constexpr int StaticArray< 3, Value >::getSize()
{
   return size;
   return Size;
}

template< typename Value >
@@ -33,7 +33,7 @@ inline StaticArray< 3, Value >::StaticArray()
template< typename Value >
   template< typename _unused >
__cuda_callable__
inline StaticArray< 3, Value >::StaticArray( const Value v[ size ] )
inline StaticArray< 3, Value >::StaticArray( const Value v[ Size ] )
{
   data[ 0 ] = v[ 0 ];
   data[ 1 ] = v[ 1 ];
@@ -60,7 +60,7 @@ inline StaticArray< 3, Value >::StaticArray( const Value& v1, const Value& v2, c

template< typename Value >
__cuda_callable__
inline StaticArray< 3, Value >::StaticArray( const StaticArray< size, Value >& v )
inline StaticArray< 3, Value >::StaticArray( const StaticArray< Size, Value >& v )
{
   data[ 0 ] = v[ 0 ];
   data[ 1 ] = v[ 1 ];
@@ -79,7 +79,7 @@ template< typename Value >
String StaticArray< 3, Value >::getType()
{
   return String( "Containers::StaticArray< " ) +
          convertToString( size ) +
          convertToString( Size ) +
          String( ", " ) +
          TNL::getType< Value >() +
          String( " >" );
@@ -104,7 +104,7 @@ __cuda_callable__
inline const Value& StaticArray< 3, Value >::operator[]( int i ) const
{
   TNL_ASSERT_GE( i, 0, "Element index must be non-negative." );
   TNL_ASSERT_LT( i, size, "Element index is out of bounds." );
   TNL_ASSERT_LT( i, Size, "Element index is out of bounds." );
   return data[ i ];
}

@@ -113,7 +113,7 @@ __cuda_callable__
inline Value& StaticArray< 3, Value >::operator[]( int i )
{
   TNL_ASSERT_GE( i, 0, "Element index must be non-negative." );
   TNL_ASSERT_LT( i, size, "Element index is out of bounds." );
   TNL_ASSERT_LT( i, Size, "Element index is out of bounds." );
   return data[ i ];
}

@@ -184,7 +184,7 @@ template< typename Value >
__cuda_callable__
bool StaticArray< 3, Value >::operator == ( const Array& array ) const
{
   return( ( int ) size == ( int ) Array::size &&
   return( ( int ) Size == ( int ) Array::getSize() &&
           data[ 0 ] == array[ 0 ] &&
           data[ 1 ] == array[ 1 ] &&
           data[ 2 ] == array[ 2 ] );
@@ -221,14 +221,14 @@ void StaticArray< 3, Value >::setValue( const ValueType& val )
template< typename Value >
bool StaticArray< 3, Value >::save( File& file ) const
{
   file.save< Value, Value, Devices::Host >( data, size );
   file.save< Value, Value, Devices::Host >( data, Size );
   return true;
}

template< typename Value >
bool StaticArray< 3, Value >::load( File& file)
{
   file.load< Value, Value, Devices::Host >( data, size );
   file.load< Value, Value, Devices::Host >( data, Size );
   return true;
}

+9 −9
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ template< int Size, typename Value >
__cuda_callable__
constexpr int StaticArray< Size, Value >::getSize()
{
   return size;
   return Size;
}

template< int Size, typename Value >
@@ -92,7 +92,7 @@ __cuda_callable__
inline const Value& StaticArray< Size, Value >::operator[]( int i ) const
{
   TNL_ASSERT_GE( i, 0, "Element index must be non-negative." );
   TNL_ASSERT_LT( i, size, "Element index is out of bounds." );
   TNL_ASSERT_LT( i, Size, "Element index is out of bounds." );
   return data[ i ];
}

@@ -101,7 +101,7 @@ __cuda_callable__
inline Value& StaticArray< Size, Value >::operator[]( int i )
{
   TNL_ASSERT_GE( i, 0, "Element index must be non-negative." );
   TNL_ASSERT_LT( i, size, "Element index is out of bounds." );
   TNL_ASSERT_LT( i, Size, "Element index is out of bounds." );
   return data[ i ];
}

@@ -109,7 +109,7 @@ template< int Size, typename Value >
__cuda_callable__
inline StaticArray< Size, Value >& StaticArray< Size, Value >::operator = ( const StaticArray< Size, Value >& array )
{
   for( int i = 0; i < size; i++ )
   for( int i = 0; i < Size; i++ )
      data[ i ] = array[ i ];
   return *this;
}
@@ -119,7 +119,7 @@ template< int Size, typename Value >
__cuda_callable__
inline StaticArray< Size, Value >& StaticArray< Size, Value >::operator = ( const Array& array )
{
   for( int i = 0; i < size; i++ )
   for( int i = 0; i < Size; i++ )
      data[ i ] = array[ i ];
   return *this;
}
@@ -129,9 +129,9 @@ template< int Size, typename Value >
__cuda_callable__
inline bool StaticArray< Size, Value >::operator == ( const Array& array ) const
{
   if( ( int ) size != ( int ) Array::size )
   if( ( int ) Size != ( int ) Array::getSize() )
      return false;
   for( int i = 0; i < size; i++ )
   for( int i = 0; i < Size; i++ )
      if( data[ i ] != array[ i ] )
         return false;
   return true;
@@ -168,14 +168,14 @@ inline void StaticArray< Size, Value >::setValue( const ValueType& val )
template< int Size, typename Value >
bool StaticArray< Size, Value >::save( File& file ) const
{
   file.save< Value, Value, Devices::Host >( data, size );
   file.save< Value, Value, Devices::Host >( data, Size );
   return true;
}

template< int Size, typename Value >
bool StaticArray< Size, Value >::load( File& file)
{
   file.load< Value, Value, Devices::Host >( data, size );
   file.load< Value, Value, Devices::Host >( data, Size );
   return true;
}

Loading