mirror of https://github.com/xfarrow/lasd.git
parent
e9091bd403
commit
8f7716bc2d
|
@ -27,7 +27,7 @@ MatrixCSR<Data>::MatrixCSR(const MatrixCSR& toCopy) : MatrixCSR(toCopy.rows, toC
|
||||||
in this way:
|
in this way:
|
||||||
The row index is represented by "i" (the variable that iterates over the R array),
|
The row index is represented by "i" (the variable that iterates over the R array),
|
||||||
meanwhile the column index is represented by the second element in the pair of the node.
|
meanwhile the column index is represented by the second element in the pair of the node.
|
||||||
The actual element is stored in the first element in the pair of the node.
|
The current element is stored in the first element in the pair of the node.
|
||||||
The update of the newely created R array is left to operator()().
|
The update of the newely created R array is left to operator()().
|
||||||
*/
|
*/
|
||||||
for(ulong i=0 ; i < (toCopy.R.Size()-1) ; ++i){
|
for(ulong i=0 ; i < (toCopy.R.Size()-1) ; ++i){
|
||||||
|
@ -150,15 +150,15 @@ void MatrixCSR<Data>::RowResize(const ulong& new_row_size){
|
||||||
template <typename Data>
|
template <typename Data>
|
||||||
void MatrixCSR<Data>::ColumnResize(const ulong& new_column_size){
|
void MatrixCSR<Data>::ColumnResize(const ulong& new_column_size){
|
||||||
if(new_column_size < columns){
|
if(new_column_size < columns){
|
||||||
Node** prev;
|
Node** prev; // in case an element must be deleted, this is its previous element.
|
||||||
Node* toDelete;
|
Node* toDelete;
|
||||||
Node** toModify;
|
Node** toModify;
|
||||||
for(ulong i=0 ; i<R.Size()-1 ; ++i){ // iterate over the R array
|
for(ulong i=0 ; i<R.Size()-1 ; ++i){ // iterate over the R array
|
||||||
prev = R[i]; // in case an element must be deleted, this is its previous element.
|
prev = R[i];
|
||||||
|
|
||||||
for(Node** ptr = R[i] ; ptr!=R[i+1] ; ){
|
for(Node** ptr = R[i] ; ptr!=R[i+1] ; ){
|
||||||
if(((*ptr)->value).second < new_column_size){
|
if(((*ptr)->value).second < new_column_size){
|
||||||
prev = &( (*(*ptr)).next );
|
prev = &( (*(*ptr)).next ); // This, alongside line 157 is redundant, but maybe it gives more clarity
|
||||||
ptr = &( (*(*ptr)).next);
|
ptr = &( (*(*ptr)).next);
|
||||||
}else{
|
}else{
|
||||||
toDelete = *ptr;
|
toDelete = *ptr;
|
||||||
|
|
|
@ -13,6 +13,12 @@
|
||||||
|
|
||||||
namespace lasd {
|
namespace lasd {
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Although MatrixCSR inherits from List, it's not safe to use List methods here.
|
||||||
|
** For example, insertAtBack() is both a logical (why would you need to create
|
||||||
|
** a separate case for inserting at back in a matrix?) and a functional problem
|
||||||
|
** (the tail gets never updated).
|
||||||
|
*/
|
||||||
template <typename Data>
|
template <typename Data>
|
||||||
class MatrixCSR : virtual public List<std::pair<Data,ulong>>,
|
class MatrixCSR : virtual public List<std::pair<Data,ulong>>,
|
||||||
virtual public Matrix<Data>{ // Must extend Matrix<Data>
|
virtual public Matrix<Data>{ // Must extend Matrix<Data>
|
||||||
|
|
Loading…
Reference in New Issue