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

Fixing and adding new assignment operators for dense matrix (and dense matrix view).

parent 584ce91e
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
@@ -851,6 +851,24 @@ class DenseMatrix : public Matrix< Real, Device, Index, RealAllocator >
       */
      DenseMatrix& operator=( const DenseMatrix& matrix );

      /**
       * \brief Assignment operator with the same organization.
       *
       * \param matrix is the right-hand side matrix.
       * \return reference to this matrix.
       */
      template< typename RHSReal, typename RHSDevice, typename RHSIndex, typename RHSRealAllocator >
      DenseMatrix& operator=( const DenseMatrix< RHSReal, RHSDevice, RHSIndex, Organization, RHSRealAllocator >& matrix );

      /**
       * \brief Assignment operator with matrix view having the same elements organization.
       *
       * \param matrix is the right-hand side matrix.
       * \return reference to this matrix.
       */
      template< typename RHSReal, typename RHSDevice, typename RHSIndex >
      DenseMatrix& operator=( const DenseMatrixView< RHSReal, RHSDevice, RHSIndex, Organization >& matrix );

      /**
       * \brief Assignment operator with other dense matrices.
       *
@@ -861,6 +879,16 @@ class DenseMatrix : public Matrix< Real, Device, Index, RealAllocator >
                 ElementsOrganization RHSOrganization, typename RHSRealAllocator >
      DenseMatrix& operator=( const DenseMatrix< RHSReal, RHSDevice, RHSIndex, RHSOrganization, RHSRealAllocator >& matrix );

      /**
       * \brief Assignment operator with other dense matrices.
       *
       * \param matrix is the right-hand side matrix.
       * \return reference to this matrix.
       */
      template< typename RHSReal, typename RHSDevice, typename RHSIndex,
                 ElementsOrganization RHSOrganization >
      DenseMatrix& operator=( const DenseMatrixView< RHSReal, RHSDevice, RHSIndex, RHSOrganization >& matrix );

      /**
       * \brief Assignment operator with other (sparse) types of matrices.
       *
+44 −4
Original line number Diff line number Diff line
@@ -1068,8 +1068,34 @@ DenseMatrix< Real, Device, Index, Organization, RealAllocator >&
DenseMatrix< Real, Device, Index, Organization, RealAllocator >::
operator=( const DenseMatrix< Real, Device, Index, Organization, RealAllocator >& matrix )
{
   setLike( matrix );
   this->values = matrix.values;
   return this->operator=( matrix.getConstView() );
}

template< typename Real,
          typename Device,
          typename Index,
          ElementsOrganization Organization,
          typename RealAllocator >
   template< typename RHSReal, typename RHSDevice, typename RHSIndex, typename RHSRealAllocator >
DenseMatrix< Real, Device, Index, Organization, RealAllocator >&
DenseMatrix< Real, Device, Index, Organization, RealAllocator >::
operator=( const DenseMatrix< RHSReal, RHSDevice, RHSIndex, Organization, RHSRealAllocator >& matrix )
{
   return this->operator=( matrix.getConstView() );
}

template< typename Real,
          typename Device,
          typename Index,
          ElementsOrganization Organization,
          typename RealAllocator >
   template< typename RHSReal, typename RHSDevice, typename RHSIndex >
DenseMatrix< Real, Device, Index, Organization, RealAllocator >&
DenseMatrix< Real, Device, Index, Organization, RealAllocator >::
operator=( const DenseMatrixView< RHSReal, RHSDevice, RHSIndex, Organization >& matrix )
{
   this->setLike( matrix );
   this->values = matrix.getValues();
   return *this;
}

@@ -1084,9 +1110,23 @@ DenseMatrix< Real, Device, Index, Organization, RealAllocator >&
DenseMatrix< Real, Device, Index, Organization, RealAllocator >::
operator=( const DenseMatrix< RHSReal, RHSDevice, RHSIndex, RHSOrganization, RHSRealAllocator >& matrix )
{
   using RHSMatrix = DenseMatrix< RHSReal, RHSDevice, RHSIndex, RHSOrganization, RHSRealAllocator >;
   return this->operator=( matrix.getConstView() );
}

template< typename Real,
          typename Device,
          typename Index,
          ElementsOrganization Organization,
          typename RealAllocator >
   template< typename RHSReal, typename RHSDevice, typename RHSIndex,
             ElementsOrganization RHSOrganization >
DenseMatrix< Real, Device, Index, Organization, RealAllocator >&
DenseMatrix< Real, Device, Index, Organization, RealAllocator >::
operator=( const DenseMatrixView< RHSReal, RHSDevice, RHSIndex, RHSOrganization >& matrix )
{
   using RHSMatrix = DenseMatrixView< RHSReal, RHSDevice, RHSIndex, RHSOrganization >;
   using RHSIndexType = typename RHSMatrix::IndexType;
   using RHSRealType = typename RHSMatrix::RealType;
   using RHSRealType = std::remove_const_t< typename RHSMatrix::RealType >;
   using RHSDeviceType = typename RHSMatrix::DeviceType;

   this->setLike( matrix );