From a3d54cb08431dcd349b44f4e319d7b681807ac59 Mon Sep 17 00:00:00 2001 From: mtzikara Date: Sun, 30 Sep 2018 23:38:32 +0200 Subject: [PATCH] Delete lil_sparse_matrix.c --- serial_csr/lil_sparse_matrix.c | 76 ---------------------------------- 1 file changed, 76 deletions(-) delete mode 100644 serial_csr/lil_sparse_matrix.c diff --git a/serial_csr/lil_sparse_matrix.c b/serial_csr/lil_sparse_matrix.c deleted file mode 100644 index 61777ea..0000000 --- a/serial_csr/lil_sparse_matrix.c +++ /dev/null @@ -1,76 +0,0 @@ -#include "lil_sparse_matrix.h" - -LilSparseMatrix createLilSparseMatrix() { - LilSparseMatrix sparseMatrix; - sparseMatrix.elements = 0; - sparseMatrix.firstElement = NULL; - sparseMatrix.lastElement = NULL; - return sparseMatrix; -} - -void apendElement(LilSparseMatrix *sparseMatrix, double value, int row, int column) { - // Creates the new element - LilSparseMatrixElement *newElement = (LilSparseMatrixElement *) malloc(sizeof(LilSparseMatrixElement)); - newElement->value = value; - newElement->rowIndex = row; - newElement->columnIndex = column; - newElement->nextElement = NULL; - - if (sparseMatrix->firstElement == NULL) { - // Sparse matrix is empty, this is the first element - sparseMatrix->firstElement = newElement; - sparseMatrix->lastElement = newElement; - } else { - //Gets last element of the matrix - LilSparseMatrixElement *lastElement = sparseMatrix->lastElement; - - lastElement->nextElement = newElement; - sparseMatrix->lastElement = newElement; - } - - sparseMatrix->elements = sparseMatrix->elements + 1; -} - -void lilSparseMatrixVectorMultiplication(LilSparseMatrix sparseMatrix, - double *vector, double **product, int vectorSize) { - // Initializes the elements of the product vector to zero - for (int i=0; irowIndex, column = element->columnIndex; - - if (row >= vectorSize) { - printf("Error at sparseMatrixVectorMultiplication. Matrix has more rows than vector!\n"); - printf("row = %d\n", row); - exit(EXIT_FAILURE); - } - - (*product)[row] = (*product)[row] + element->value * vector[column]; - element = element->nextElement; - } -} - -void destroyLilSparseMatrix(LilSparseMatrix *sparseMatrix) { - LilSparseMatrixElement *currentElement = sparseMatrix->firstElement; - while (currentElement != NULL) { - LilSparseMatrixElement *toDelete = currentElement; - currentElement = currentElement->nextElement; - free(toDelete); - } -} - -void printLilSparseMatrix(LilSparseMatrix sparseMatrix) { - if (sparseMatrix.elements == 0) { - return; - } - - LilSparseMatrixElement *currentElement = sparseMatrix.firstElement; - for (int i=0; irowIndex, - currentElement->columnIndex, currentElement->value); - currentElement = currentElement->nextElement; - } -} \ No newline at end of file