Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 9a3c18f9 authored by BOUCHERIE Raphael's avatar BOUCHERIE Raphael
Browse files

Removed the structure for just a simple table stocking the step for each tiles

parent b4dc986b
No related branches found
No related tags found
1 merge request!5Print tree
......@@ -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
......
......@@ -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;
......
......@@ -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;
}
......@@ -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);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment