Loading src/implementation/matrices/tnlChunkedEllpackMatrix_impl.h +3 −2 Original line number Diff line number Diff line Loading @@ -376,7 +376,8 @@ bool tnlChunkedEllpackMatrix< Real, Device, Index > :: setRow( const IndexType r const IndexType& chunkSize = slices.getElement( sliceIndex ).chunkSize; IndexType elementPointer = rowPointers[ row ]; const IndexType rowEnd = rowPointers[ row + 1 ]; if( elements > rowEnd - elementPointer ) const IndexType rowLength = rowEnd - elementPointer; if( elements > rowLength ) return false; for( IndexType i = 0; i < elements; i++ ) Loading @@ -385,7 +386,7 @@ bool tnlChunkedEllpackMatrix< Real, Device, Index > :: setRow( const IndexType r this->values[ elementPointer ] = values[ i ]; elementPointer++; } for( IndexType i = elements; i < this->rowLengths; i++ ) for( IndexType i = elements; i < rowLength; i++ ) this->columnIndexes[ elementPointer++ ] = this->getColumns(); return true; } Loading src/implementation/matrices/tnlDenseMatrix_impl.h +16 −3 Original line number Diff line number Diff line Loading @@ -95,6 +95,19 @@ Index tnlDenseMatrix< Real, Device, Index >::getNumberOfMatrixElements() const return this->getRows() * this->getColumns(); } template< typename Real, typename Device, typename Index > Index tnlDenseMatrix< Real, Device, Index >::getNumberOfNonzeroMatrixElements() const { IndexType nonzeroElements( 0 ); for( IndexType row = 0; row < this->getRows(); row++ ) for( IndexType column = 0; column < this->getColumns(); column++ ) if( this->getElement( row, column ) != 0 ) nonzeroElements++; return nonzeroElements; } template< typename Real, typename Device, typename Index > Loading Loading @@ -154,15 +167,15 @@ bool tnlDenseMatrix< Real, Device, Index >::addRow( const IndexType row, const IndexType* columns, const RealType* values, const IndexType elements, const RealType thisRowMultiplicator ) const RealType& thisRowMultiplicator ) { tnlAssert( elements <= this->columns, cerr << " elements = " << elements << " this->columns = " << this->columns << " this->getName() = " << this->getName() ); for( IndexType i = 0; i < elements; i++ ) this->operator[]( row, columns[ i ] ) = thisRowMultiplicator * this->operator[]( row, columns[ i ] ) + values[ i ]; this->setElement( row, columns[ i ], thisRowMultiplicator * this->getElement( row, columns[ i ] ) + values[ i ] ); return true; } Loading src/implementation/matrices/tnlMatrix_impl.h +30 −2 Original line number Diff line number Diff line Loading @@ -45,11 +45,11 @@ template< typename Real, template< typename Real, typename Device, typename Index > void tnlMatrix< Real, Device, Index >::getRowLentghs( tnlVector< IndexType, DeviceType, IndexType >& rowLengths ) const void tnlMatrix< Real, Device, Index >::getRowLengths( tnlVector< IndexType, DeviceType, IndexType >& rowLengths ) const { rowLengths.setSize( this->getRows() ); for( IndexType row = 0; row < this->getRows(); row++ ) rowLengths.setElement( row, this->getRowLengths( row ) ); rowLengths.setElement( row, this->getRowLength( row ) ); } template< typename Real, Loading Loading @@ -88,6 +88,34 @@ void tnlMatrix< Real, Device, Index >::reset() this->columns = 0; } template< typename Real, typename Device, typename Index > tnlMatrix< Real, Device, Index >& tnlMatrix< Real, Device, Index >::operator = ( const tnlMatrix< RealType, DeviceType, IndexType >& m ) { this->setLike( m ); tnlVector< IndexType, DeviceType, IndexType > rowLengths; m.getRowLengths( rowLengths ); this->setRowLengths( rowLengths ); tnlVector< RealType, DeviceType, IndexType > rowValues; tnlVector< 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(), rowLengths.getElement( row ) ); } } template< typename Real, typename Device, typename Index > Loading src/implementation/matrices/tnlMultidiagonalMatrix_impl.h +12 −0 Original line number Diff line number Diff line Loading @@ -146,6 +146,18 @@ Index tnlMultidiagonalMatrix< Real, Device, Index > :: getNumberOfMatrixElements return this->values.getSize(); } template< typename Real, typename Device, typename Index > Index tnlMultidiagonalMatrix< Real, Device, Index > :: getNumberOfNonzeroMatrixElements() const { IndexType nonzeroElements; for( IndexType i = 0; i < this->values.getSize(); i++ ) if( this->values.getElement( i ) != 0 ) nonzeroElements++; return nonzeroElements; } template< typename Real, typename Device, typename Index > Loading src/implementation/matrices/tnlSlicedEllpackMatrix_impl.h +2 −2 Original line number Diff line number Diff line Loading @@ -111,7 +111,7 @@ template< typename Real, int SliceSize > Index tnlSlicedEllpackMatrix< Real, Device, Index, SliceSize >::getRowLength( const IndexType row ) const { const IndexType slice = roundUpDivision( this->row, SliceSize ); const IndexType slice = roundUpDivision( row, SliceSize ); return this->sliceRowLengths[ slice ]; } Loading Loading @@ -259,7 +259,7 @@ bool tnlSlicedEllpackMatrix< Real, Device, Index, SliceSize > :: setRow( const I this->values[ elementPointer ] = values[ i ]; elementPointer++; } for( IndexType i = elements; i < this->rowLengths; i++ ) for( IndexType i = elements; i < rowLength; i++ ) this->columnIndexes[ elementPointer++ ] = this->getColumns(); return true; } Loading Loading
src/implementation/matrices/tnlChunkedEllpackMatrix_impl.h +3 −2 Original line number Diff line number Diff line Loading @@ -376,7 +376,8 @@ bool tnlChunkedEllpackMatrix< Real, Device, Index > :: setRow( const IndexType r const IndexType& chunkSize = slices.getElement( sliceIndex ).chunkSize; IndexType elementPointer = rowPointers[ row ]; const IndexType rowEnd = rowPointers[ row + 1 ]; if( elements > rowEnd - elementPointer ) const IndexType rowLength = rowEnd - elementPointer; if( elements > rowLength ) return false; for( IndexType i = 0; i < elements; i++ ) Loading @@ -385,7 +386,7 @@ bool tnlChunkedEllpackMatrix< Real, Device, Index > :: setRow( const IndexType r this->values[ elementPointer ] = values[ i ]; elementPointer++; } for( IndexType i = elements; i < this->rowLengths; i++ ) for( IndexType i = elements; i < rowLength; i++ ) this->columnIndexes[ elementPointer++ ] = this->getColumns(); return true; } Loading
src/implementation/matrices/tnlDenseMatrix_impl.h +16 −3 Original line number Diff line number Diff line Loading @@ -95,6 +95,19 @@ Index tnlDenseMatrix< Real, Device, Index >::getNumberOfMatrixElements() const return this->getRows() * this->getColumns(); } template< typename Real, typename Device, typename Index > Index tnlDenseMatrix< Real, Device, Index >::getNumberOfNonzeroMatrixElements() const { IndexType nonzeroElements( 0 ); for( IndexType row = 0; row < this->getRows(); row++ ) for( IndexType column = 0; column < this->getColumns(); column++ ) if( this->getElement( row, column ) != 0 ) nonzeroElements++; return nonzeroElements; } template< typename Real, typename Device, typename Index > Loading Loading @@ -154,15 +167,15 @@ bool tnlDenseMatrix< Real, Device, Index >::addRow( const IndexType row, const IndexType* columns, const RealType* values, const IndexType elements, const RealType thisRowMultiplicator ) const RealType& thisRowMultiplicator ) { tnlAssert( elements <= this->columns, cerr << " elements = " << elements << " this->columns = " << this->columns << " this->getName() = " << this->getName() ); for( IndexType i = 0; i < elements; i++ ) this->operator[]( row, columns[ i ] ) = thisRowMultiplicator * this->operator[]( row, columns[ i ] ) + values[ i ]; this->setElement( row, columns[ i ], thisRowMultiplicator * this->getElement( row, columns[ i ] ) + values[ i ] ); return true; } Loading
src/implementation/matrices/tnlMatrix_impl.h +30 −2 Original line number Diff line number Diff line Loading @@ -45,11 +45,11 @@ template< typename Real, template< typename Real, typename Device, typename Index > void tnlMatrix< Real, Device, Index >::getRowLentghs( tnlVector< IndexType, DeviceType, IndexType >& rowLengths ) const void tnlMatrix< Real, Device, Index >::getRowLengths( tnlVector< IndexType, DeviceType, IndexType >& rowLengths ) const { rowLengths.setSize( this->getRows() ); for( IndexType row = 0; row < this->getRows(); row++ ) rowLengths.setElement( row, this->getRowLengths( row ) ); rowLengths.setElement( row, this->getRowLength( row ) ); } template< typename Real, Loading Loading @@ -88,6 +88,34 @@ void tnlMatrix< Real, Device, Index >::reset() this->columns = 0; } template< typename Real, typename Device, typename Index > tnlMatrix< Real, Device, Index >& tnlMatrix< Real, Device, Index >::operator = ( const tnlMatrix< RealType, DeviceType, IndexType >& m ) { this->setLike( m ); tnlVector< IndexType, DeviceType, IndexType > rowLengths; m.getRowLengths( rowLengths ); this->setRowLengths( rowLengths ); tnlVector< RealType, DeviceType, IndexType > rowValues; tnlVector< 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(), rowLengths.getElement( row ) ); } } template< typename Real, typename Device, typename Index > Loading
src/implementation/matrices/tnlMultidiagonalMatrix_impl.h +12 −0 Original line number Diff line number Diff line Loading @@ -146,6 +146,18 @@ Index tnlMultidiagonalMatrix< Real, Device, Index > :: getNumberOfMatrixElements return this->values.getSize(); } template< typename Real, typename Device, typename Index > Index tnlMultidiagonalMatrix< Real, Device, Index > :: getNumberOfNonzeroMatrixElements() const { IndexType nonzeroElements; for( IndexType i = 0; i < this->values.getSize(); i++ ) if( this->values.getElement( i ) != 0 ) nonzeroElements++; return nonzeroElements; } template< typename Real, typename Device, typename Index > Loading
src/implementation/matrices/tnlSlicedEllpackMatrix_impl.h +2 −2 Original line number Diff line number Diff line Loading @@ -111,7 +111,7 @@ template< typename Real, int SliceSize > Index tnlSlicedEllpackMatrix< Real, Device, Index, SliceSize >::getRowLength( const IndexType row ) const { const IndexType slice = roundUpDivision( this->row, SliceSize ); const IndexType slice = roundUpDivision( row, SliceSize ); return this->sliceRowLengths[ slice ]; } Loading Loading @@ -259,7 +259,7 @@ bool tnlSlicedEllpackMatrix< Real, Device, Index, SliceSize > :: setRow( const I this->values[ elementPointer ] = values[ i ]; elementPointer++; } for( IndexType i = elements; i < this->rowLengths; i++ ) for( IndexType i = elements; i < rowLength; i++ ) this->columnIndexes[ elementPointer++ ] = this->getColumns(); return true; } Loading