| 543 | } |
| 544 | |
| 545 | void CSRMatrix::commitChange( unsigned row, unsigned column, double newValue ) |
| 546 | { |
| 547 | ASSERT( FloatUtils::wellFormed( newValue ) ); |
| 548 | |
| 549 | // First check whether the entry already exists |
| 550 | unsigned index = findArrayIndexForEntry( row, column ); |
| 551 | bool found = ( index < _nnz ); |
| 552 | |
| 553 | if ( !found ) |
| 554 | { |
| 555 | // Entry doesn't exist currently |
| 556 | if ( !FloatUtils::isZero( newValue ) ) |
| 557 | { |
| 558 | CommittedChange change; |
| 559 | change._column = column; |
| 560 | change._value = newValue; |
| 561 | _committedInsertions[row].insert( change ); |
| 562 | } |
| 563 | } |
| 564 | else |
| 565 | { |
| 566 | // Entry currently exists |
| 567 | if ( FloatUtils::isZero( newValue ) ) |
| 568 | { |
| 569 | _committedDeletions.insert( index ); |
| 570 | } |
| 571 | else if ( FloatUtils::areDisequal( newValue, _A[index] ) ) |
| 572 | { |
| 573 | CommittedChange change; |
| 574 | change._column = column; |
| 575 | change._value = newValue; |
| 576 | _committedChanges[row].append( change ); |
| 577 | } |
| 578 | } |
| 579 | } |
| 580 | |
| 581 | unsigned CSRMatrix::findArrayIndexForEntry( unsigned row, unsigned column ) const |
| 582 | { |