@ -55,68 +55,68 @@ uint_fast64_t DeterministicSparseTransitionParser::firstPass(char* buf, uint_fas
buf = strchr ( buf , ' \n ' ) + 1 ; // skip format hint
buf = strchr ( buf , ' \n ' ) + 1 ; // skip format hint
}
}
/*
/*
* Check all transitions for non - zero diagonal entries and deadlock states .
* Check all transitions for non - zero diagonal entries and deadlock states .
*/
*/
int_fast64_t lastRow = - 1 ;
int_fast64_t lastRow = - 1 ;
u int_fast64_t row , col ;
int_fast64_t row , col ;
uint_fast64_t readTransitionCount = 0 ;
uint_fast64_t readTransitionCount = 0 ;
bool rowHadDiagonalEntry = false ;
bool rowHadDiagonalEntry = false ;
double val ;
double val ;
maxnode = 0 ;
maxnode = 0 ;
while ( buf [ 0 ] ! = ' \0 ' ) {
while ( buf [ 0 ] ! = ' \0 ' ) {
/*
/*
* Read row and column .
* Read row and column .
*/
*/
row = checked_strtol ( buf , & buf ) ;
row = checked_strtol ( buf , & buf ) ;
col = checked_strtol ( buf , & buf ) ;
col = checked_strtol ( buf , & buf ) ;
if ( ! isRewardMatrix ) {
if ( lastRow ! = ( int_fast64_t ) row ) {
if ( ( lastRow ! = - 1 ) & & ( ! rowHadDiagonalEntry ) ) {
+ + nonZeroEntryCount ;
rowHadDiagonalEntry = true ;
}
for ( uint_fast64_t skippedRow = ( uint_fast64_t ) ( lastRow + 1 ) ; skippedRow < row ; + + skippedRow ) {
+ + nonZeroEntryCount ;
}
lastRow = row ;
rowHadDiagonalEntry = false ;
}
if ( col = = row ) {
if ( ! isRewardMatrix ) {
rowHadDiagonalEntry = true ;
if ( lastRow ! = ( int_fast64_t ) row ) {
} else if ( col > row & & ! rowHadDiagonalEntry ) {
if ( ( lastRow ! = - 1 ) & & ( ! rowHadDiagonalEntry ) ) {
+ + nonZeroEntryCount ;
rowHadDiagonalEntry = true ;
rowHadDiagonalEntry = true ;
}
for ( uint_fast64_t skippedRow = ( uint_fast64_t ) ( lastRow + 1 ) ; skippedRow < row ; + + skippedRow ) {
+ + nonZeroEntryCount ;
+ + nonZeroEntryCount ;
}
}
}
lastRow = row ;
rowHadDiagonalEntry = false ;
/*
}
* Check if one is larger than the current maximum id .
if ( col = = row ) {
*/
rowHadDiagonalEntry = true ;
if ( row > maxnode ) maxnode = row ;
} else if ( col > row & & ! rowHadDiagonalEntry ) {
if ( col > maxnode ) maxnode = col ;
rowHadDiagonalEntry = true ;
+ + nonZeroEntryCount ;
/*
}
* Read probability of this transition .
}
* Check , if the value is a probability , i . e . if it is between 0 and 1.
/*
*/
* Check if one is larger than the current maximum id .
val = checked_strtod ( buf , & buf ) ;
*/
if ( ( val < 0.0 ) | | ( val > 1.0 ) ) {
if ( row > maxnode ) maxnode = row ;
LOG4CPLUS_ERROR ( logger , " Expected a positive probability but got \" " < < val < < " \" . " ) ;
if ( col > maxnode ) maxnode = col ;
return 0 ;
/*
}
* Read probability of this transition .
+ + nonZeroEntryCount ;
* Check , if the value is a probability , i . e . if it is between 0 and 1.
+ + readTransitionCount ;
*/
buf = trimWhitespaces ( buf ) ;
val = checked_strtod ( buf , & buf ) ;
}
if ( ( val < 0.0 ) | | ( val > 1.0 ) ) {
LOG4CPLUS_ERROR ( logger , " Expected a positive probability but got \" " < < val < < " \" . " ) ;
if ( ! rowHadDiagonalEntry & & ! isRewardMatrix ) {
return 0 ;
+ + nonZeroEntryCount ;
}
}
+ + nonZeroEntryCount ;
+ + readTransitionCount ;
return nonZeroEntryCount ;
buf = trimWhitespaces ( buf ) ;
}
if ( ! rowHadDiagonalEntry & & ! isRewardMatrix ) {
+ + nonZeroEntryCount ;
}
return nonZeroEntryCount ;
}
}
xxxxxxxxxx