Commit 4f2d9832 authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

Cosmetic changes in Array

parent b0cd8f73
Loading
Loading
Loading
Loading
+21 −22
Original line number Diff line number Diff line
@@ -35,7 +35,6 @@ class Array : public virtual Object
      typedef Index IndexType;
      typedef Containers::Array< Element, Devices::Host, Index > HostType;
      typedef Containers::Array< Element, Devices::Cuda, Index > CudaType;
      typedef Containers::Array< Element, Device, Index > ThisType;

      Array();

@@ -44,7 +43,7 @@ class Array : public virtual Object
      Array( Element* data,
             const IndexType& size );

      Array( Array< Element, Device, Index >& array,
      Array( Array& array,
             const IndexType& begin = 0,
             const IndexType& size = 0 );

@@ -63,26 +62,26 @@ class Array : public virtual Object
       */
      void setSize( Index size );

      template< typename Array >
      void setLike( const Array& array );
      __cuda_callable__ Index getSize() const;

      template< typename ArrayT >
      void setLike( const ArrayT& array );

      void bind( Element* _data,
                 const Index _size );

      template< typename Array >      
      void bind( const Array& array,
      template< typename ArrayT >
      void bind( const ArrayT& array,
                 const IndexType& begin = 0,
                 const IndexType& size = 0 );

      template< int Size >
      void bind( StaticArray< Size, Element >& array );

      void swap( Array< Element, Device, Index >& array );
      void swap( Array& array );

      void reset();

      __cuda_callable__ Index getSize() const;

      void setElement( const Index& i, const Element& x );

      Element getElement( const Index& i ) const;
@@ -91,10 +90,10 @@ class Array : public virtual Object

      __cuda_callable__ inline const Element& operator[] ( const Index& i ) const;

      Array< Element, Device, Index >& operator = ( const Array< Element, Device, Index >& array );
      Array& operator = ( const Array& array );

      template< typename ArrayT >
      Array< Element, Device, Index >& operator = ( const ArrayT& array );
      Array& operator = ( const ArrayT& array );

      template< typename ArrayT >
      bool operator == ( const ArrayT& array ) const;
+24 −26
Original line number Diff line number Diff line
@@ -22,8 +22,6 @@
namespace TNL {
namespace Containers {

using namespace std;

template< typename Element,
          typename Device,
          typename Index >
@@ -34,7 +32,7 @@ Array()
  allocationPointer( 0 ),
  referenceCounter( 0 )
{
};
}

template< typename Element,
          typename Device,
@@ -185,6 +183,17 @@ setSize( const Index size )
   }
}

template< typename Element,
          typename Device,
          typename Index >
__cuda_callable__
Index
Array< Element, Device, Index >::
getSize() const
{
   return this -> size;
}

template< typename Element,
          typename Device,
          typename Index >
@@ -285,17 +294,6 @@ reset()
   this->releaseData();
}

template< typename Element,
          typename Device,
          typename Index >
__cuda_callable__
Index
Array< Element, Device, Index >::
getSize() const
{
   return this -> size;
}

template< typename Element,
          typename Device,
          typename Index >
@@ -472,8 +470,8 @@ bool Array< Element, Device, Index > :: save( File& file ) const
      return false;
   if( this->size != 0 && ! ArrayIO< Element, Device, Index >::save( file, this->data, this->size ) )
   {
      cerr << "I was not able to save " << this->getType()
           << " with size " << this -> getSize() << endl;
      std::cerr << "I was not able to save " << this->getType()
           << " with size " << this -> getSize() << std::endl;
      return false;
   }
   return true;
@@ -493,7 +491,7 @@ load( File& file )
      return false;
   if( _size < 0 )
   {
      cerr << "Error: The size " << _size << " of the file is not a positive number or zero." << endl;
      std::cerr << "Error: The size " << _size << " of the file is not a positive number or zero." << std::endl;
      return false;
   }
   setSize( _size );
@@ -501,8 +499,8 @@ load( File& file )
   {
      if( ! ArrayIO< Element, Device, Index >::load( file, this->data, this->size ) )
      {
         cerr << "I was not able to load " << this->getType()
                    << " with size " << this -> getSize() << endl;
         std::cerr << "I was not able to load " << this->getType()
                    << " with size " << this -> getSize() << std::endl;
         return false;
      }
   }
@@ -523,7 +521,7 @@ boundLoad( File& file )
      return false;
   if( _size < 0 )
   {
      cerr << "Error: The size " << _size << " of the file is not a positive number or zero." << endl;
      std::cerr << "Error: The size " << _size << " of the file is not a positive number or zero." << std::endl;
      return false;
   }
   if( this->getSize() != 0 )
@@ -540,8 +538,8 @@ boundLoad( File& file )
   {
      if( ! ArrayIO< Element, Device, Index >::load( file, this->data, this->size ) )
      {
         cerr << "I was not able to load " << this->getType()
                    << " with size " << this -> getSize() << endl;
         std::cerr << "I was not able to load " << this->getType()
                    << " with size " << this -> getSize() << std::endl;
         return false;
      }
   }
@@ -558,14 +556,14 @@ boundLoad( const String& fileName )
   File file;
   if( ! file. open( fileName, IOMode::read ) )
   {
      cerr << "I am not bale to open the file " << fileName << " for reading." << endl;
      std::cerr << "I am not bale to open the file " << fileName << " for reading." << std::endl;
      return false;
   }
   if( ! this->boundLoad( file ) )
      return false;
   if( ! file. close() )
   {
      cerr << "An error occurred when I was closing the file " << fileName << "." << endl;
      std::cerr << "An error occurred when I was closing the file " << fileName << "." << std::endl;
      return false;
   }
   return true;