Created
January 8, 2014 17:56
-
-
Save charlieda/8321218 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef __SPARSE_H | |
#define __SPARSE_H | |
#include "util.h" | |
typedef struct C | |
{ | |
int col; | |
int val; | |
struct C* next; | |
} sparse_cell; | |
typedef struct { | |
int rows; | |
int cols; | |
sparse_cell** row; | |
} sparse_matrix; | |
// Core Functions | |
sparse_matrix* sparse_new(int rows, int cols); | |
void sparse_destroy(sparse_matrix* self); | |
sparse_matrix* sparse_read(char* filename, bool transpose); | |
bool sparse_write(sparse_matrix* self, char* filename); | |
void sparse_set_cell(sparse_matrix* self, int row, int col, int val); | |
int sparse_value_at(sparse_matrix* self, int row, int col); | |
sparse_cell* sparse_cell_at(sparse_matrix* self, int row, int col); | |
// Niave Implementations | |
sparse_matrix* sparse_transposed(sparse_matrix* self); | |
sparse_matrix* sparse_sum(sparse_matrix* a, sparse_matrix* b); | |
sparse_matrix* sparse_mul(sparse_matrix* a, sparse_matrix* b); | |
bool sparse_is_equal(sparse_matrix* a, sparse_matrix* b); | |
// Optimised Implementations | |
sparse_matrix* sparse_add(sparse_matrix* a, sparse_matrix* b); | |
sparse_matrix* sparse_mul_optimised(sparse_matrix* a, sparse_matrix* b); | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment