Commit 574c7901 authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

Removed broken copyFrom and operator= methods from Matrix

The problem was the getRow() method, there is only getRowFast() which
does not work cross-device.
parent a212f974
Loading
Loading
Loading
Loading
+4 −13
Original line number Diff line number Diff line
@@ -23,7 +23,6 @@ template< typename Real = double,
class Matrix : public virtual Object
{
public:

   typedef Real RealType;
   typedef Device DeviceType;
   typedef Index IndexType;
@@ -85,18 +84,12 @@ class Matrix : public virtual Object
   virtual Real getElement( const IndexType row,
                            const IndexType column ) const = 0;

   Matrix< RealType, DeviceType, IndexType >& operator = ( const Matrix< RealType, DeviceType, IndexType >& );

   template< typename Matrix >
   bool operator == ( const Matrix& matrix ) const;

   template< typename Matrix >
   bool operator != ( const Matrix& matrix ) const;

   template< typename Matrix >
   bool copyFrom( const Matrix& matrix,
                  const CompressedRowLengthsVector& rowLengths );

   virtual bool save( File& file ) const;

   virtual bool load( File& file );
@@ -107,8 +100,6 @@ class Matrix : public virtual Object

   IndexType rows, columns;

   public: // TODO: remove this

   ValuesVector values;
};

+0 −55
Original line number Diff line number Diff line
@@ -85,61 +85,6 @@ void Matrix< Real, Device, Index >::reset()
   this->columns = 0;
}

template< typename Real,
          typename Device,
          typename Index >
   template< typename MatrixT >
bool Matrix< Real, Device, Index >::copyFrom( const MatrixT& matrix,
                                              const CompressedRowLengthsVector& rowLengths )
{
   /*tnlStaticTNL_ASSERT( DeviceType::DeviceType == Devices::HostDevice, );
   tnlStaticTNL_ASSERT( DeviceType::DeviceType == Matrix:DeviceType::DeviceType, );*/

   this->setLike( matrix );
   this->setCompressedRowLengths( rowLengths );
   Containers::Vector< RealType, Devices::Host, IndexType > values;
   Containers::Vector< IndexType, Devices::Host, IndexType > columns;
   values.setSize( this->getColumns() );
   columns.setSize( this->getColumns() );
   for( IndexType row = 0; row < this->getRows(); row++ )
   {
      TNL_ASSERT( false, );
      // TODO: fix this
      //matrix.getRow( row, columns.getData(), values.getData() );
      this->setRow( row, columns.getData(), values.getData(), rowLengths.getElement( row ) );
   }
   return true;
}

template< typename Real,
          typename Device,
          typename Index >
Matrix< Real, Device, Index >& Matrix< Real, Device, Index >::operator = ( const Matrix< RealType, DeviceType, IndexType >& m )
{
   this->setLike( m );

   Containers::Vector< IndexType, DeviceType, IndexType > rowLengths;
   m.getCompressedRowLengths( rowLengths );
   this->setCompressedRowLengths( rowLengths );

   Containers::Vector< RealType, DeviceType, IndexType > rowValues;
   Containers::Vector< IndexType, DeviceType, IndexType > rowColumns;
   const IndexType maxRowLength = rowLengths.max();
   rowValues.setSize( maxRowLength );
   rowColumns.setSize( maxRowLength );
   for( IndexType row = 0; row < this->getRows(); row++ )
   {
      m.getRow( row,
                rowColumns.getData(),
                rowValues.getData() );
      this->setRow( row,
                    rowColumns.getData(),
                    rowValues.getData(),
                    m.getRowLength( row ) );
   }
   return *this;
}

template< typename Real,
          typename Device,
          typename Index >