| 600 | } |
| 601 | |
| 602 | void CSRMatrix::executeChanges() |
| 603 | { |
| 604 | // Get the changes out of the way |
| 605 | for ( const auto &changedRow : _committedChanges ) |
| 606 | { |
| 607 | unsigned row = changedRow.first; |
| 608 | for ( const auto &changedColumn : changedRow.second ) |
| 609 | { |
| 610 | unsigned column = changedColumn._column; |
| 611 | unsigned index = findArrayIndexForEntry( row, column ); |
| 612 | |
| 613 | ASSERT( index < _nnz ); |
| 614 | |
| 615 | _A[index] = changedColumn._value; |
| 616 | } |
| 617 | } |
| 618 | _committedChanges.clear(); |
| 619 | |
| 620 | // Next, handle the deletions. Do a pass on the data structures, and shrink |
| 621 | // them as needed. |
| 622 | if ( !_committedDeletions.empty() ) |
| 623 | { |
| 624 | List<unsigned> deletions; |
| 625 | for ( const auto &deletedEntry : _committedDeletions ) |
| 626 | deletions.append( deletedEntry ); |
| 627 | deleteElements( deletions ); |
| 628 | |
| 629 | _committedDeletions.clear(); |
| 630 | } |
| 631 | |
| 632 | // Finally, handle the insertions |
| 633 | if ( !_committedInsertions.empty() ) |
| 634 | { |
| 635 | insertElements( _committedInsertions ); |
| 636 | _committedInsertions.clear(); |
| 637 | } |
| 638 | } |
| 639 | |
| 640 | void CSRMatrix::countElements( unsigned *numRowElements, unsigned *numColumnElements ) |
| 641 | { |