From 95a4787a40d657305ceecf9c6df01e34e9922856 Mon Sep 17 00:00:00 2001 From: Daniel Grund Date: Tue, 19 Jul 2005 15:26:11 +0000 Subject: [PATCH] Changed type of entries form int to matrix_type. matrix_type is doulbe by default. --- ir/be/sp_matrix.c | 7 +++---- ir/be/sp_matrix.h | 10 ++++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/ir/be/sp_matrix.c b/ir/be/sp_matrix.c index 665dd605d..d62e216df 100644 --- a/ir/be/sp_matrix.c +++ b/ir/be/sp_matrix.c @@ -5,7 +5,6 @@ * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE. * Sparse matrix storage with linked lists for rows and cols. - * I did not need floats, so this is all integer. */ #ifdef HAVE_CONFIG_H @@ -172,7 +171,7 @@ void del_matrix(sp_matrix_t *m) { free(m); } -void matrix_set(sp_matrix_t *m, int row, int col, int val) { +void matrix_set(sp_matrix_t *m, int row, int col, matrix_type val) { matrix_elem_t *me = NULL; entry_t *entr; struct list_head *leftof, *above; @@ -230,7 +229,7 @@ void matrix_set(sp_matrix_t *m, int row, int col, int val) { m->entries++; } -int matrix_get(const sp_matrix_t *m, int row, int col) { +matrix_type matrix_get(const sp_matrix_t *m, int row, int col) { struct list_head *dummy; matrix_elem_t *me; @@ -395,7 +394,7 @@ void matrix_dump(sp_matrix_t *m, FILE *out, int factor) { matrix_foreach_in_row(m, i, e) { for (o=last_idx+1; ocol; ++o) fprintf(out, "0"); - fprintf(out, "%d", factor*e->val); + fprintf(out, "%f", factor*e->val); last_idx = e->col; } for (o=last_idx+1; o<=m->maxcol; ++o) diff --git a/ir/be/sp_matrix.h b/ir/be/sp_matrix.h index b30e18974..d04056d19 100644 --- a/ir/be/sp_matrix.h +++ b/ir/be/sp_matrix.h @@ -5,7 +5,6 @@ * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE. * Sparse matrix storage with linked lists for rows and cols. - * I did not need floats, so this is all integer. */ #ifndef _SP_MATRIX_H @@ -13,8 +12,11 @@ #include +typedef double matrix_type; + typedef struct _matrix_elem_t { - int row, col, val; + int row, col; + matrix_type val; } matrix_elem_t; typedef struct _sp_matrix_t sp_matrix_t; @@ -34,12 +36,12 @@ void del_matrix(sp_matrix_t *m); /** * Sets m[row, col] to val */ -void matrix_set(sp_matrix_t *m, int row, int col, int val); +void matrix_set(sp_matrix_t *m, int row, int col, matrix_type val); /** * Returns the value stored in m[row, col]. */ -int matrix_get(const sp_matrix_t *m, int row, int col); +matrix_type matrix_get(const sp_matrix_t *m, int row, int col); /** * Returns the number of (not-0-)entries. -- 2.20.1