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

Implementing CSR sparse matrix format.

parent ef71a3d6
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -83,7 +83,7 @@ template< typename Vertex, typename Device >
   if( XDiffOrder == 0 )
      return this->amplitude * sin( this->phase + 2.0 * M_PI * x / this->waveLength );
   if( XDiffOrder == 1 )
      return 2.0 * M_PI / this->waveLength * this->amplitude * cos( 2.0 * M_PI * x / this->waveLength );
      return 2.0 * M_PI / this->waveLength * this->amplitude * cos( this->phase + 2.0 * M_PI * x / this->waveLength );
   return 0.0;
}

@@ -110,7 +110,7 @@ template< typename Vertex, typename Device >
   const RealType& z = v.z();
   if( XDiffOrder == 0 && YDiffOrder == 0 && ZDiffOrder == 0 )
   {
      return this->amplitude * sin( this->phase + sqrt( x * x + y * y + z * z ) / ( M_PI * this->waveLength) );
      return this->amplitude * sin( this->phase + 2.0 * M_PI * sqrt( x * x + y * y + z * z ) / this->waveLength );
   }
   return 0.0;
}
+0 −25
Original line number Diff line number Diff line
@@ -71,36 +71,11 @@ template< typename Real,
   template< typename Vector >
bool tnlCSRMatrix< Real, Device, Index >::setRowLengths( const Vector& rowLengths )
{
   const IndexType slices = roundUpDivision( this->rows, SliceSize );
   if( ! this->sliceRowLengths.setSize( slices ) ||
       ! this->slicePointers.setSize( slices + 1 ) )
      return false;
   IndexType row( 0 ), slice( 0 ), sliceRowLength( 0 );

   /****
    * Compute maximal row length in each slice
    */
   while( row < this->rows )
   {
      sliceRowLength = Max( rowLengths.getElement( row++ ), sliceRowLength );
      if( row % SliceSize == 0 )
      {
         this->sliceRowLengths.setElement( slice, sliceRowLength );
         this->slicePointers.setElement( slice++, sliceRowLength*SliceSize );
         sliceRowLength = 0;
      }
   }
   if( row % SliceSize != 0 )
   {
      this->sliceRowLengths.setElement( slice, sliceRowLength );
      this->slicePointers.setElement( slice++, sliceRowLength*SliceSize );
   }

   /****
    * Compute the slice pointers using the exclusive prefix sum
    */
   this->slicePointers.setElement( slices, 0 );
   this->slicePointers.computeExclusivePrefixSum();

   /****
    * Allocate values and column indexes
+0 −1
Original line number Diff line number Diff line
@@ -87,7 +87,6 @@ Real tnlFiniteDifferences< tnlGrid< 1, Real, Device, Index, tnlIdenticalGridGeom
               2.0 * function[ grid.getElementIndex( c.x() ) ] +
               function[ grid.getElementIndex( c.x() - 1 ) ] ) / (  hx * hx );
   }

}

/****