diff --git a/librerie/exercise5/build.sh b/librerie/exercise5/build.sh index 17349be..5ccdfe1 100755 --- a/librerie/exercise5/build.sh +++ b/librerie/exercise5/build.sh @@ -1,7 +1,7 @@ #! /bin/bash -g++-10 -o main \ +g++-10 -g -o main \ zlasdtest/exercise1/simpletest.cpp zlasdtest/exercise1/fulltest.cpp \ zlasdtest/exercise2/simpletest.cpp zlasdtest/exercise2/fulltest.cpp \ zlasdtest/exercise3/simpletest.cpp zlasdtest/exercise3/fulltest.cpp \ diff --git a/librerie/exercise5/matrix/csr/matrixcsr.cpp b/librerie/exercise5/matrix/csr/matrixcsr.cpp index 13c0f0a..8f2a2b2 100755 --- a/librerie/exercise5/matrix/csr/matrixcsr.cpp +++ b/librerie/exercise5/matrix/csr/matrixcsr.cpp @@ -218,6 +218,7 @@ Data& MatrixCSR::operator()(const ulong& r, const ulong& c){ struct List>::Node* nextNode = *ptr; *ptr = newNode; newNode->next = nextNode; + (newNode->value).second = c; if(last == ptr){ // the newely inserted element is the last one in its row for(ulong i=r+1 ; i::operator!=(const MatrixVec& toCompare) const noexcept{ template void MatrixVec::RowResize(const ulong& newdim){ - Vector::Resize(newdim); + if(newdim == 0){ + Clear(); + }else{ + Vector::Resize(newdim * columns); + rows = newdim; + size = newdim * columns; + } } template diff --git a/librerie/exercise5/zlasdtest/exercise5/simpletest.cpp b/librerie/exercise5/zlasdtest/exercise5/simpletest.cpp index 6a94395..dcb0ee9 100755 --- a/librerie/exercise5/zlasdtest/exercise5/simpletest.cpp +++ b/librerie/exercise5/zlasdtest/exercise5/simpletest.cpp @@ -36,6 +36,7 @@ void stestMatrixInt(Mat& mat, uint& testnum, uint& testerr) { SetRowNumber(loctestnum, loctesterr, mat, true, 1); SetColumnNumber(loctestnum, loctesterr, mat, true, 1); + std::cout<<"\nClearing the matrix\n"; mat.Clear(); ExistsCell(loctestnum, loctesterr, mat, false, 0, 0); @@ -45,10 +46,10 @@ void stestMatrixInt(Mat& mat, uint& testnum, uint& testerr) { SetColumnNumber(loctestnum, loctesterr, mat, true, 4); GetColumnNumber(loctestnum, loctesterr, mat, true, 4); - SetCell(loctestnum, loctesterr, mat, true, 0, 1, 1); - SetCell(loctestnum, loctesterr, mat, true, 1, 0, 2); + SetCell(loctestnum, loctesterr, mat, true, 0, 1, 1); //15 + SetCell(loctestnum, loctesterr, mat, true, 1, 0, 2);//16 - SetCell(loctestnum, loctesterr, mat, true, 2, 1, 3); + SetCell(loctestnum, loctesterr, mat, true, 2, 1, 3);//17 SetCell(loctestnum, loctesterr, mat, true, 0, 3, 4); SetCell(loctestnum, loctesterr, mat, true, 2, 3, 5); @@ -58,8 +59,8 @@ void stestMatrixInt(Mat& mat, uint& testnum, uint& testerr) { Mat copmat(mat); - MapPreOrder(loctestnum, loctesterr, mat, true, &MapPrint, 0); - MapPreOrder(loctestnum, loctesterr, copmat, true, &MapPrint, 0); + MapPreOrder(loctestnum, loctesterr, mat, true, &MapPrint, 0); //22 + MapPreOrder(loctestnum, loctesterr, copmat, true, &MapPrint, 0); //23 MapPostOrder(loctestnum, loctesterr, mat, true, &MapPrint, 0); MapPostOrder(loctestnum, loctesterr, copmat, true, &MapPrint, 0); @@ -73,7 +74,7 @@ void stestMatrixInt(Mat& mat, uint& testnum, uint& testerr) { MapPreOrder(loctestnum, loctesterr, mat, true, &MapDecrement, 0); - SetColumnNumber(loctestnum, loctesterr, mat, true, 5); + SetColumnNumber(loctestnum, loctesterr, mat, true, 5); //31 SetCell(loctestnum, loctesterr, mat, true, 1, 4, 8); SetCell(loctestnum, loctesterr, mat, true, 3, 4, 9); @@ -88,7 +89,7 @@ void stestMatrixInt(Mat& mat, uint& testnum, uint& testerr) { MapPreOrder(loctestnum, loctesterr, mat, true, &MapIncrement, 0); - MapPreOrder(loctestnum, loctesterr, mat, true, &MapPrint, 0); + MapPreOrder(loctestnum, loctesterr, mat, true, &MapPrint, 0); //40 FoldPreOrder(loctestnum, loctesterr, mat, true, &FoldMultiply, 0, 1, 168); @@ -100,7 +101,7 @@ void stestMatrixInt(Mat& mat, uint& testnum, uint& testerr) { MapPreOrder(loctestnum, loctesterr, mat, true, &MapPrint, 0); MapPostOrder(loctestnum, loctesterr, mat, true, &MapPrint, 0); - FoldPreOrder(loctestnum, loctesterr, mat, true, &FoldAdd, 0, 0, 6); + FoldPreOrder(loctestnum, loctesterr, mat, true, &FoldAdd, 0, 0, 6); //47 MapPostOrder(loctestnum, loctesterr, mat, true, &MapIncrement, 0); diff --git a/librerie/exercise5/zlasdtest/test.cpp b/librerie/exercise5/zlasdtest/test.cpp index 443ad27..9d6a50c 100755 --- a/librerie/exercise5/zlasdtest/test.cpp +++ b/librerie/exercise5/zlasdtest/test.cpp @@ -19,14 +19,14 @@ using namespace std; void lasdtest() { cout << endl << "~*~#~*~ Welcome to the LASD Test Suite ~*~#~*~ " << endl; - testSimpleExercise1(); - testFullExercise1(); - testSimpleExercise2(); - testFullExercise2(); - testSimpleExercise3(); - testFullExercise3(); - testSimpleExercise4(); - testFullExercise4(); + // testSimpleExercise1(); + // testFullExercise1(); + // testSimpleExercise2(); + // testFullExercise2(); + // testSimpleExercise3(); + // testFullExercise3(); + // testSimpleExercise4(); + // testFullExercise4(); testSimpleExercise5(); testFullExercise5(); cout << endl << "Goodbye!" << endl; diff --git a/librerie/exercise5_alessandro.zip b/librerie/exercise5_alessandro.zip new file mode 100644 index 0000000..5cbda9e Binary files /dev/null and b/librerie/exercise5_alessandro.zip differ