From 9a3c18f9929aba388453bd3a326af7a7559f9c36 Mon Sep 17 00:00:00 2001 From: Raphael Boucherie <raphael.boucherie@inria.fr> Date: Wed, 12 Apr 2017 15:08:12 +0200 Subject: [PATCH] Removed the structure for just a simple table stocking the step for each tiles --- include/libhqr.h | 18 +++++++++--------- src/treewalk.c | 10 ++++++++-- testings/testing_treedraw.c | 16 +++++++++------- testings/testing_treewalk.c | 17 +++++++++++------ 4 files changed, 37 insertions(+), 24 deletions(-) diff --git a/include/libhqr.h b/include/libhqr.h index eacd7a4..d075339 100644 --- a/include/libhqr.h +++ b/include/libhqr.h @@ -78,14 +78,14 @@ typedef enum libhqr_typefacto_ { LIBHQR_LQ = 1, } libhqr_typefacto_e; -/** - * @brief Structure for stocking informations in order to draw the tree - */ -typedef struct libhqr_treedraw_s{ - int k; /**< The factorization step for the color */ - int *tiles; /**< Table for tiles */ - int tiles_size; /**< Size of the table */ -} libhqr_treedraw_t; +/* /\** */ +/* * @brief Structure for stocking informations in order to draw the tree */ +/* *\/ */ +/* typedef struct libhqr_treedraw_s{ */ +/* int k; /\**< The factorization step for the color *\/ */ +/* int *tiles; /\**< Table for tiles *\/ */ +/* int tiles_size; /\**< Size of the table *\/ */ +/* } libhqr_treedraw_t; */ /** * @brief Minimal structure to define the shape of the matrix to factorize. @@ -202,7 +202,7 @@ void libhqr_hqr_finalize( libhqr_tree_t *qrtree ); * function for treewalk */ -void libhqr_treewalk(const libhqr_tree_t *qrtree,int k); +void libhqr_treewalk(const libhqr_tree_t *qrtree,int k, int *tiles); /* * Debugging functions diff --git a/src/treewalk.c b/src/treewalk.c index d5f11c2..7d2a2dc 100644 --- a/src/treewalk.c +++ b/src/treewalk.c @@ -31,15 +31,18 @@ * @param[in] k * Factorization step * + * @param[in] tiles + * Table stocking the tiles and their step + * */ -void libhqr_treewalk(const libhqr_tree_t *qrtree, int k) +void libhqr_treewalk(const libhqr_tree_t *qrtree, int k, int *tiles) { int tsid = -1, ttid = -1; int p = k; int pivot = k; libhqr_queue_tile_t *tt = libhqr_queue_tile_new(); libhqr_queue_tile_t *ts = libhqr_queue_tile_new(); - + int y; libhqr_queue_tile_push(&tt, k); while( tt ) @@ -71,6 +74,9 @@ void libhqr_treewalk(const libhqr_tree_t *qrtree, int k) printf("POP TS: %d\n", tsid); printf("Call function on (%d, %d)\n", qrtree->currpiv(qrtree, k, tsid), tsid ); + y = libhqr_imax(tiles[tsid], tiles[qrtree->currpiv(qrtree, k, tsid)]) + 1; + tiles[tsid] = tiles[qrtree->currpiv(qrtree, k, tsid)] = y; + printf("Step %d\n", y ); tsid = libhqr_queue_tile_head(&ts); } pivot = p = ttid; diff --git a/testings/testing_treedraw.c b/testings/testing_treedraw.c index c935ebe..a9e0c33 100644 --- a/testings/testing_treedraw.c +++ b/testings/testing_treedraw.c @@ -29,20 +29,22 @@ main(int argc, char ** argv) { libhqr_tree_t qrtree; libhqr_tiledesc_t matrix; - int minMN; - libhqr_treedraw_t drawing; + int maxMN; + int *tiles; matrix.nodes = 1; matrix.p = 1; matrix.mt = 8; matrix.nt = 4; libhqr_hqr_init( &qrtree, LIBHQR_QR, &matrix, LIBHQR_BINARY_TREE, LIBHQR_FLAT_TREE, 1, 1, 0, 0); - minMN = libhqr_imin(matrix.mt, matrix.nt ); - drawing.tiles = (int*)malloc(minMN*sizeof(int)); - drawing.tiles_size = minMN; + maxMN = libhqr_imax(matrix.mt, matrix.nt ); + tiles = (int*)malloc(maxMN*sizeof(int)); + for ( int i = 0; i < maxMN; i++){ + tiles[i] = 0; + } FILE *tree = fopen("tree.svg","w+"); libhqr_writeheader(tree); - libhqr_treewalk(&qrtree, 0); + libhqr_treewalk(&qrtree, 0, tiles); libhqr_writeend(tree); - free(drawing.tiles); + free(tree); return 1; } diff --git a/testings/testing_treewalk.c b/testings/testing_treewalk.c index c57056e..1c6f22e 100644 --- a/testings/testing_treewalk.c +++ b/testings/testing_treewalk.c @@ -16,13 +16,15 @@ #include "libhqr.h" #include "queue.h" #include <stdio.h> +#include <stdlib.h> int main(int argc, char ** argv) { libhqr_tree_t qrtree; libhqr_tiledesc_t matrix; - int minMN, k, rc ; + int *tiles; + int maxMN, rc ; /* * Test treewalk for HQR trees */ @@ -30,12 +32,15 @@ main(int argc, char ** argv) matrix.p = 1; matrix.mt = 8; matrix.nt = 4; - libhqr_hqr_init( &qrtree, LIBHQR_QR, &matrix, LIBHQR_FIBONACCI_TREE, LIBHQR_FLAT_TREE, 1, 1, 0, 0); - minMN = libhqr_imin(matrix.mt, matrix.nt ); + libhqr_hqr_init( &qrtree, LIBHQR_QR, &matrix, LIBHQR_BINARY_TREE, LIBHQR_FLAT_TREE, 1, 1, 0, 0); + maxMN = libhqr_imax(matrix.mt, matrix.nt ); + tiles = (int*)malloc(maxMN*sizeof(int)); + for ( int i = 0; i < maxMN; i++){ + tiles[i] = 0; + } rc = libhqr_tree_check( &matrix, &qrtree ); printf("%d\n", rc); - for (k=0; k<minMN; k++) { - libhqr_treewalk( &qrtree, k ); - } + libhqr_treewalk( &qrtree, 0, tiles); libhqr_hqr_finalize( &qrtree ); + free(tiles); } -- GitLab