Commit 86bf24dd authored by Tomáš Oberhuber's avatar Tomáš Oberhuber Committed by Jakub Klinkovský
Browse files

Small fixes of sparse sandbox matrix.

parent 11c8a4b0
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -21,6 +21,9 @@

namespace TNL {
   namespace Matrices {
      /**
       * \brief Namespace for sandbox matrices.
       */
      namespace Sandbox {

/**
+1 −1
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ SparseSandboxMatrixRowView( IndexType rowIdx,
                            IndexType size,
                            const ValuesViewType& values,
                            const ColumnsIndexesViewType& columnIndexes )
 : rowIdx( rowIdx ), offset( offset ), size( size ), values( values ), columnIndexes( columnIndexes )
 : rowIdx( rowIdx ), size( size ), offset( offset ), values( values ), columnIndexes( columnIndexes )
{
}

+6 −2
Original line number Diff line number Diff line
@@ -426,7 +426,11 @@ vectorProduct( const InVector& inVector,
         const auto end = rowPointers[ rowIdx + 1 ];
         RealType sum( 0.0 );
         for( IndexType globalIdx = begin; globalIdx < end; globalIdx++ )
               sum += this->values[ globalIdx ] * inVector[ this->columnIndexes[ globalIdx ] ];
         {
            const auto columnIdx = this->columnIndexes[ globalIdx ];
            if( columnIdx != paddingIndex )
               sum += this->values[ globalIdx ] * inVector[ columnIdx ];
         }
         // SANDBOX_TODO:The following is quite inefficient, its better to specialized the code for cases when
         // `outVectorMultiplicator` is zero or `matrixMultiplicator` is one - see. the full implementation bellow.
         outVector[ rowIdx ] = outVector[ rowIdx ] * outVectorMultiplicator + matrixMultiplicator * sum;
@@ -440,7 +444,7 @@ vectorProduct( const InVector& inVector,
         const auto end = rowPointersView[ rowIdx + 1 ];
         RealType sum( 0.0 );
         for( IndexType globalIdx = begin; globalIdx < end; globalIdx++ )
            sum + valuesView[ globalIdx ] * inVectorView[ columnIndexesView[ globalIdx ] ];
            sum += valuesView[ globalIdx ] * inVectorView[ columnIndexesView[ globalIdx ] ];
         outVectorView[ rowIdx ] = outVectorView[ rowIdx ] * outVectorMultiplicator + matrixMultiplicator * sum;
      };
      TNL::Algorithms::ParallelFor< DeviceType >::exec( firstRow, lastRow, f );