@ -87,7 +87,7 @@ namespace storm {
}
}
template < typename ValueType >
template < typename ValueType >
SparseMatrixBuilder < ValueType > : : SparseMatrixBuilder ( index_type rows , index_type columns , index_type entries , bool forceDimensions , bool hasCustomRowGrouping , index_type rowGroups ) : initialRowCountSet ( rows ! = 0 ) , initialRowCount ( rows ) , initialColumnCountSet ( columns ! = 0 ) , initialColumnCount ( columns ) , initialEntryCountSet ( entries ! = 0 ) , initialEntryCount ( entries ) , forceInitialDimensions ( forceDimensions ) , hasCustomRowGrouping ( hasCustomRowGrouping ) , initialRowGroupCountSet ( rowGroups ! = 0 ) , initialRowGroupCount ( rowGroups ) , rowGroupIndices ( ) , columnsAndValues ( ) , rowIndications ( ) , currentEntryCount ( 0 ) , lastRow ( 0 ) , lastColumn ( 0 ) , highestColumn ( 0 ) , currentRowGroup ( 0 ) {
SparseMatrixBuilder < ValueType > : : SparseMatrixBuilder ( index_type rows , index_type columns , index_type entries , bool forceDimensions , bool hasCustomRowGrouping , index_type rowGroups ) : initialRowCountSet ( rows ! = 0 ) , initialRowCount ( rows ) , initialColumnCountSet ( columns ! = 0 ) , initialColumnCount ( columns ) , initialEntryCountSet ( entries ! = 0 ) , initialEntryCount ( entries ) , forceInitialDimensions ( forceDimensions ) , hasCustomRowGrouping ( hasCustomRowGrouping ) , initialRowGroupCountSet ( rowGroups ! = 0 ) , initialRowGroupCount ( rowGroups ) , rowGroupIndices ( ) , columnsAndValues ( ) , rowIndications ( ) , currentEntryCount ( 0 ) , lastRow ( 0 ) , lastColumn ( 0 ) , highestColumn ( 0 ) , currentRowGroupCount ( 0 ) {
// Prepare the internal storage.
// Prepare the internal storage.
if ( initialRowCountSet ) {
if ( initialRowCountSet ) {
rowIndications . reserve ( initialRowCount + 1 ) ;
rowIndications . reserve ( initialRowCount + 1 ) ;
@ -105,7 +105,7 @@ namespace storm {
}
}
template < typename ValueType >
template < typename ValueType >
SparseMatrixBuilder < ValueType > : : SparseMatrixBuilder ( SparseMatrix < ValueType > & & matrix ) : initialRowCountSet ( false ) , initialRowCount ( 0 ) , initialColumnCountSet ( false ) , initialColumnCount ( 0 ) , initialEntryCountSet ( false ) , initialEntryCount ( 0 ) , forceInitialDimensions ( false ) , hasCustomRowGrouping ( ! matrix . trivialRowGrouping ) , initialRowGroupCountSet ( false ) , initialRowGroupCount ( 0 ) , rowGroupIndices ( ) , columnsAndValues ( std : : move ( matrix . columnsAndValues ) ) , rowIndications ( std : : move ( matrix . rowIndications ) ) , currentEntryCount ( matrix . entryCount ) , currentRowGroup ( ) {
SparseMatrixBuilder < ValueType > : : SparseMatrixBuilder ( SparseMatrix < ValueType > & & matrix ) : initialRowCountSet ( false ) , initialRowCount ( 0 ) , initialColumnCountSet ( false ) , initialColumnCount ( 0 ) , initialEntryCountSet ( false ) , initialEntryCount ( 0 ) , forceInitialDimensions ( false ) , hasCustomRowGrouping ( ! matrix . trivialRowGrouping ) , initialRowGroupCountSet ( false ) , initialRowGroupCount ( 0 ) , rowGroupIndices ( ) , columnsAndValues ( std : : move ( matrix . columnsAndValues ) ) , rowIndications ( std : : move ( matrix . rowIndications ) ) , currentEntryCount ( matrix . entryCount ) , currentRowGroupCount ( ) {
lastRow = matrix . rowCount = = 0 ? 0 : matrix . rowCount - 1 ;
lastRow = matrix . rowCount = = 0 ? 0 : matrix . rowCount - 1 ;
lastColumn = columnsAndValues . empty ( ) ? 0 : columnsAndValues . back ( ) . getColumn ( ) ;
lastColumn = columnsAndValues . empty ( ) ? 0 : columnsAndValues . back ( ) . getColumn ( ) ;
@ -117,7 +117,7 @@ namespace storm {
if ( ! rowGroupIndices - > empty ( ) ) {
if ( ! rowGroupIndices - > empty ( ) ) {
rowGroupIndices . get ( ) . pop_back ( ) ;
rowGroupIndices . get ( ) . pop_back ( ) ;
}
}
currentRowGroup = rowGroupIndices - > empty ( ) ? 0 : rowGroupIndices . get ( ) . size ( ) - 1 ;
currentRowGroupCount = rowGroupIndices - > empty ( ) ? 0 : rowGroupIndices . get ( ) . size ( ) - 1 ;
}
}
// Likewise, we need to 'open' the row indications again.
// Likewise, we need to 'open' the row indications again.
@ -191,7 +191,7 @@ namespace storm {
STORM_LOG_THROW ( hasCustomRowGrouping , storm : : exceptions : : InvalidStateException , " Matrix was not created to have a custom row grouping. " ) ;
STORM_LOG_THROW ( hasCustomRowGrouping , storm : : exceptions : : InvalidStateException , " Matrix was not created to have a custom row grouping. " ) ;
STORM_LOG_THROW ( startingRow > = lastRow , storm : : exceptions : : InvalidStateException , " Illegal row group with negative size. " ) ;
STORM_LOG_THROW ( startingRow > = lastRow , storm : : exceptions : : InvalidStateException , " Illegal row group with negative size. " ) ;
rowGroupIndices . get ( ) . push_back ( startingRow ) ;
rowGroupIndices . get ( ) . push_back ( startingRow ) ;
+ + currentRowGroup ;
+ + currentRowGroupCount ;
// Close all rows from the most recent one to the starting row.
// Close all rows from the most recent one to the starting row.
for ( index_type i = lastRow + 1 ; i < startingRow ; + + i ) {
for ( index_type i = lastRow + 1 ; i < startingRow ; + + i ) {
@ -252,14 +252,14 @@ namespace storm {
// Check whether row groups are missing some entries.
// Check whether row groups are missing some entries.
if ( hasCustomRowGrouping ) {
if ( hasCustomRowGrouping ) {
uint_fast64_t rowGroupCount = currentRowGroup ;
uint_fast64_t rowGroupCount = currentRowGroupCount ;
if ( initialRowGroupCountSet & & forceInitialDimensions ) {
if ( initialRowGroupCountSet & & forceInitialDimensions ) {
STORM_LOG_THROW ( rowGroupCount < = initialRowGroupCount , storm : : exceptions : : InvalidStateException , " Expected not more than " < < initialRowGroupCount < < " row groups, but got " < < rowGroupCount < < " . " ) ;
STORM_LOG_THROW ( rowGroupCount < = initialRowGroupCount , storm : : exceptions : : InvalidStateException , " Expected not more than " < < initialRowGroupCount < < " row groups, but got " < < rowGroupCount < < " . " ) ;
rowGroupCount = std : : max ( rowGroupCount , initialRowGroupCount ) ;
rowGroupCount = std : : max ( rowGroupCount , initialRowGroupCount ) ;
}
}
rowGroupCount = std : : max ( rowGroupCount , overriddenRowGroupCount ) ;
rowGroupCount = std : : max ( rowGroupCount , overriddenRowGroupCount ) ;
for ( index_type i = currentRowGroup ; i < = rowGroupCount ; + + i ) {
for ( index_type i = currentRowGroupCount ; i < = rowGroupCount ; + + i ) {
rowGroupIndices . get ( ) . push_back ( rowCount ) ;
rowGroupIndices . get ( ) . push_back ( rowCount ) ;
}
}
}
}
@ -273,11 +273,11 @@ namespace storm {
}
}
template < typename ValueType >
template < typename ValueType >
typename SparseMatrixBuilder < ValueType > : : index_type SparseMatrixBuilder < ValueType > : : getLastRowGroup ( ) const {
typename SparseMatrixBuilder < ValueType > : : index_type SparseMatrixBuilder < ValueType > : : getCurrentRowGroupCount ( ) const {
if ( this - > hasCustomRowGrouping ) {
if ( this - > hasCustomRowGrouping ) {
return currentRowGroup ;
return currentRowGroupCount ;
} else {
} else {
return getLastRow ( ) ;
return getLastRow ( ) + 1 ;
}
}
}
}