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

Implementing the tridiagonal matrix.

parent cd7e53cf
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -53,6 +53,7 @@ bool tnlDenseMatrix< Real, Device, Index >::setDimensions( const IndexType rows,
                                                           const IndexType columns )
{
   return tnlMultiArray< 2, Real, Device, Index >::setDimensions( columns, rows );
   tnlMultiArray< 2, Real, Device, Index >::setValue( 0.0 );
}

template< typename Real,
@@ -195,7 +196,7 @@ template< typename Real,
          typename Index >
   template< typename Matrix, int tileDim >
void tnlDenseMatrix< Real, Device, Index >::getTransposition( const Matrix& matrix,
                                                              const RealType matrixMultiplicator )
                                                              const RealType& matrixMultiplicator )
{
   tnlAssert( this->getColumns() == matrix.getRows() &&
              this->getRows() == matrix.getColumns(),
+69 −17
Original line number Diff line number Diff line
@@ -55,6 +55,16 @@ bool tnlTridiagonalMatrix< Real, Device, Index >::setDimensions( const IndexType
   if( ! values.setSize( 3*rows - 2 ) )
      return false;
   this->rows = rows;
   this->values.setValue( 0.0 );
}

template< typename Real,
          typename Device,
          typename Index >
   template< typename Real2, typename Device2, typename Index2 >
bool tnlTridiagonalMatrix< Real, Device, Index >::setLike( const tnlTridiagonalMatrix< Real2, Device2, Index2 >& m )
{

}

template< typename Real,
@@ -91,6 +101,14 @@ bool tnlTridiagonalMatrix< Real, Device, Index >::operator != ( const tnlTridiag
   return this->values != matrix.values;
}

template< typename Real,
          typename Device,
          typename Index >
void tnlTridiagonalMatrix< Real, Device, Index >::setValue( const RealType& v )
{

}

template< typename Real,
          typename Device,
          typename Index >
@@ -104,7 +122,7 @@ void tnlTridiagonalMatrix< Real, Device, Index >::setElement( const IndexType ro
template< typename Real,
          typename Device,
          typename Index >
RealType tnlTridiagonalMatrix< Real, Device, Index >::getElement( const IndexType row,
Real tnlTridiagonalMatrix< Real, Device, Index >::getElement( const IndexType row,
                                                              const IndexType column ) const
{
   return this->values.getElement( this->getElementIndex( row, column ) );
@@ -113,19 +131,19 @@ RealType tnlTridiagonalMatrix< Real, Device, Index >::getElement( const IndexTyp
template< typename Real,
          typename Device,
          typename Index >
RealType& tnlTridiagonalMatrix< Real, Device, Index >::operator()( const IndexType row,
Real& tnlTridiagonalMatrix< Real, Device, Index >::operator()( const IndexType row,
                                                               const IndexType column )
{
   return this->values( this->getElementIndex( row, column ) );
   return this->values[ this->getElementIndex( row, column ) ];
}

template< typename Real,
          typename Device,
          typename Index >
const RealType& tnlTridiagonalMatrix< Real, Device, Index >::operator()( const IndexType row,
const Real& tnlTridiagonalMatrix< Real, Device, Index >::operator()( const IndexType row,
                                                                     const IndexType column ) const
{
   return this->values( this->getElementIndex( row, column ) );
   return this->values[ this->getElementIndex( row, column ) ];
}

template< typename Real,
@@ -134,14 +152,14 @@ template< typename Real,
bool tnlTridiagonalMatrix< Real, Device, Index >::addToElement( const IndexType row,
                                                                const IndexType column,
                                                                const RealType& value,
                                                                const RealType thisElementMultiplicator )
                                                                const RealType& thisElementMultiplicator )
{
   const IndexType elementIndex = this->getElementIndex( row, column );
   if( thisElementMultiplicator == 1.0 )
      this->values( elementIndex ) += value;
      this->values[ elementIndex ] += value;
   else
      this->operator()( elementIndex ) =
         thisElementMultiplicator * this->operator()( elementIndex ) + value;
      this->values[ elementIndex ] =
         thisElementMultiplicator * this->values[ elementIndex ] + value;
}

template< typename Real,
@@ -207,9 +225,9 @@ void tnlTridiagonalMatrix< Real, Device, Index >::addMatrix( const tnlTridiagona
template< typename Real,
          typename Device,
          typename Index >
   template< typename Matrix, int tileDim >
void tnlTridiagonalMatrix< Real, Device, Index >::getTransposition( const Matrix& matrix,
                                                              const RealType matrixMultiplicator )
   template< typename Real2, typename Index2, int tileDim >
void tnlTridiagonalMatrix< Real, Device, Index >::getTransposition( const tnlTridiagonalMatrix< Real2, Device, Index2 >& matrix,
                                                                    const RealType& matrixMultiplicator )
{
   tnlAssert( this->getColumns() == matrix.getRows() &&
              this->getRows() == matrix.getColumns(),
@@ -245,6 +263,38 @@ void tnlTridiagonalMatrix< Real, Device, Index >::performSORIteration( const Vec
   x[ row ] += omega / this->operator()( row, row )( b[ row ] - sum );
}

template< typename Real,
          typename Device,
          typename Index >
bool tnlTridiagonalMatrix< Real, Device, Index >::save( tnlFile& file ) const
{

}

template< typename Real,
          typename Device,
          typename Index >
bool tnlTridiagonalMatrix< Real, Device, Index >::load( tnlFile& file )
{

}

template< typename Real,
          typename Device,
          typename Index >
bool tnlTridiagonalMatrix< Real, Device, Index >::save( const tnlString& fileName ) const
{

}

template< typename Real,
          typename Device,
          typename Index >
bool tnlTridiagonalMatrix< Real, Device, Index >::load( const tnlString& fileName )
{

}

template< typename Real,
          typename Device,
          typename Index >
@@ -262,7 +312,7 @@ void tnlTridiagonalMatrix< Real, Device, Index >::printMatrix( ostream& str ) co
template< typename Real,
          typename Device,
          typename Index >
IndexType tnlTridiagonalMatrix< Real, Device, Index >::getElementIndex( const IndexType row,
Index tnlTridiagonalMatrix< Real, Device, Index >::getElementIndex( const IndexType row,
                                                                    const IndexType column ) const
{
   tnlAssert( row >= 0 && column >= 0 && row < this->rows && column < this->rows,
@@ -274,4 +324,6 @@ IndexType tnlTridiagonalMatrix< Real, Device, Index >::getElementIndex( const In
}




#endif /* TNLTRIDIAGONALMATRIX_IMPL_H_ */
+0 −1
Original line number Diff line number Diff line
@@ -8,7 +8,6 @@ SET( headers tnlDenseMatrix.h
	         tnlEllpackMatrixCUDA.h 	        
	         tnlFastCSRMatrix.h 
	         tnlFastRgCSRMatrix.h
	         tnlFullMatrix.h
	         tnlMatrix.h
	         tnlMultiDiagonalMatrix.h
	         tnlPETSCMatrix.h
+6 −6
Original line number Diff line number Diff line
@@ -48,7 +48,7 @@ class tnlDenseMatrix : public tnlMultiArray< 2, Real, Device, Index >
   bool addToElement( const IndexType row,
                      const IndexType column,
                      const RealType& value,
                      const RealType thisElementMultiplicator = 1.0 );
                      const RealType& thisElementMultiplicator = 1.0 );

   template< typename Vector >
   void vectorProduct( const Vector& inVector,
@@ -56,18 +56,18 @@ class tnlDenseMatrix : public tnlMultiArray< 2, Real, Device, Index >

   template< typename Matrix >
   void addMatrix( const Matrix& matrix,
                   const RealType matrixMultiplicator = 1.0,
                   const RealType thisMatrixMultiplicator = 1.0 );
                   const RealType& matrixMultiplicator = 1.0,
                   const RealType& thisMatrixMultiplicator = 1.0 );

   template< typename Matrix1, typename Matrix2, int tileDim = 32 >
   void getMatrixProduct( const Matrix1& matrix1,
                       const Matrix2& matrix2,
                       const RealType matrix1Multiplicator = 1.0,
                       const RealType matrix2Multiplicator = 1.0 );
                       const RealType& matrix1Multiplicator = 1.0,
                       const RealType& matrix2Multiplicator = 1.0 );

   template< typename Matrix, int tileDim = 32 >
   void getTransposition( const Matrix& matrix,
                             const RealType matrixMultiplicator = 1.0 );
                          const RealType& matrixMultiplicator = 1.0 );

   template< typename Vector >
   void performSORIteration( const Vector& b,
+11 −7
Original line number Diff line number Diff line
@@ -39,8 +39,10 @@ class tnlTridiagonalMatrix : public tnlObject

   tnlString getTypeVirtual() const;

   bool setDimensions( const IndexType rows,
                       const IndexType columns );
   bool setDimensions( const IndexType rows );

   template< typename Real2, typename Device2, typename Index2 >
   bool setLike( const tnlTridiagonalMatrix< Real2, Device2, Index2 >& m );

   IndexType getRows() const;

@@ -52,6 +54,8 @@ class tnlTridiagonalMatrix : public tnlObject
   template< typename Real2, typename Index2 >
   bool operator != ( const tnlTridiagonalMatrix< Real2, Device, Index2 >& matrix ) const;

   void setValue( const RealType& v );

   void setElement( const IndexType row,
                    const IndexType column,
                    const RealType& value );
@@ -74,13 +78,13 @@ class tnlTridiagonalMatrix : public tnlObject
   void vectorProduct( const Vector& inVector,
                       Vector& outVector ) const;

   template< typename Matrix >
   void addMatrix( const Matrix& matrix,
   template< typename Real2, typename Index2 >
   void addMatrix( const tnlTridiagonalMatrix< Real2, Device, Index2 >& matrix,
                   const RealType& matrixMultiplicator = 1.0,
                   const RealType& thisMatrixMultiplicator = 1.0 );

   template< typename Matrix, int tileDim = 32 >
   void getTransposition( const Matrix& matrix,
   template< typename Real2, typename Index2, int tileDim = 32 >
   void getTransposition( const tnlTridiagonalMatrix< Real2, Device, Index2 >& matrix,
                          const RealType& matrixMultiplicator = 1.0 );

   template< typename Vector >
Loading