LOG4CPLUS_INFO(logger,"Attempting to create matrix of size "<<firstPass.choices<<" x "<<(firstPass.highestStateIndex+1)<<" with "<<firstPass.numberOfNonzeroEntries<<" entries.");
// Depending on whether the internal data storage was preallocated or not, adding the value is done somewhat
// differently.
if(storagePreallocated){
// Check whether the given row and column positions are valid and throw error otherwise.
if(row>=rowCount||column>=columnCount){
throwstorm::exceptions::OutOfRangeException()<<"Illegal call to SparseMatrixBuilder::addNextValue: adding entry at out-of-bounds position ("<<row<<", "<<column<<") in matrix of size ("<<rowCount<<", "<<columnCount<<").";
}
}else{
if(rowCountSet){
if(row>=rowCount){
throwstorm::exceptions::OutOfRangeException()<<"Illegal call to SparseMatrixBuilder::addNextValue: adding entry at out-of-bounds row "<<row<<" in matrix with "<<rowCount<<" rows.";
}
}
if(columnCountSet){
if(column>=columnCount){
throwstorm::exceptions::OutOfRangeException()<<"Illegal call to SparseMatrixBuilder::addNextValue: adding entry at out-of-bounds column "<<column<<" in matrix with "<<columnCount<<" columns.";
}
}
}
// Check that we did not move backwards wrt. the row.
if(row<lastRow){
throwstorm::exceptions::InvalidArgumentException()<<"Illegal call to SparseMatrixBuilder::addNextValue: adding an element in row "<<row<<", but an element in row "<<lastRow<<" has already been added.";
}
// Check that we did not move backwards wrt. to column.
if(row==lastRow&&column<lastColumn){
throwstorm::exceptions::InvalidArgumentException()<<"Illegal call to SparseMatrixBuilder::addNextValue: adding an element in column "<<column<<" in row "<<row<<", but an element in column "<<lastColumn<<" has already been added in that row.";
@ -91,24 +82,9 @@ namespace storm {
// If we switched to another row, we have to adjust the missing entries in the row indices vector.
if(row!=lastRow){
if(storagePreallocated){
// If the storage was preallocated, we can access the elements in the vectors with the subscript
// operator.
for(index_typei=lastRow+1;i<=row;++i){
rowIndications[i]=currentEntryCount;
}
}else{
// Otherwise, we need to push the correct values to the vectors, which might trigger reallocations.
for(index_typei=lastRow+1;i<=row;++i){
rowIndications.push_back(currentEntryCount);
}
}
if(!hasCustomRowGrouping){
for(index_typei=lastRow+1;i<=row;++i){
rowGroupIndices.push_back(i);
++currentRowGroup;
}
// Otherwise, we need to push the correct values to the vectors, which might trigger reallocations.
for(index_typei=lastRow+1;i<=row;++i){
rowIndications.push_back(currentEntryCount);
}
lastRow=row;
@ -117,109 +93,76 @@ namespace storm {
lastColumn=column;
// Finally, set the element and increase the current size.
// In case we did not expect this value, we throw an exception.
if(forceInitialDimensions){
LOG_THROW(!initialRowCountSet||lastRow<initialRowCount,storm::exceptions::OutOfRangeException,"Cannot insert value at illegal row "<<lastRow<<".");
LOG_THROW(!initialColumnCountSet||lastColumn<initialColumnCount,storm::exceptions::OutOfRangeException,"Cannot insert value at illegal column "<<lastColumn<<".");
LOG_THROW(!initialEntryCountSet||currentEntryCount<=initialEntryCount,storm::exceptions::OutOfRangeException,"Too many entries in matrix, expected only "<<initialEntryCount<<".");
throwstorm::exceptions::InvalidStateException()<<"Illegal call to SparseMatrix::newRowGroup: illegal row group with negative size.";
}
if(rowGroupCountSet){
rowGroupIndices[currentRowGroup]=startingRow;
++currentRowGroup;
}else{
rowGroupIndices.push_back(startingRow);
}
LOG_THROW(hasCustomRowGrouping,storm::exceptions::InvalidStateException,"Matrix was not created to have a custom row grouping.");
LOG_THROW(rowGroupIndices.empty()||startingRow>=rowGroupIndices.back(),storm::exceptions::InvalidStateException,"Illegal row group with negative size.");
LOG_THROW(rowCount<=initialRowCount,storm::exceptions::InvalidStateException,"Expected not more than "<<initialRowCount<<" rows, but got "<<rowCount<<".");
LOG_THROW(columnCount<=initialColumnCount,storm::exceptions::InvalidStateException,"Expected not more than "<<initialColumnCount<<" columns, but got "<<columnCount<<".");
LOG_THROW(rowGroupCount<=initialRowGroupCount,storm::exceptions::InvalidStateException,"Expected not more than "<<initialRowGroupCount<<" row groups, but got "<<rowGroupCount<<".");