From 18f459c8cc82c2a7ba59e82e70e96d5d5a42671c Mon Sep 17 00:00:00 2001
From: Raphael Boucherie <raphael.boucherie@inria.fr>
Date: Thu, 13 Apr 2017 16:45:23 +0200
Subject: [PATCH] Removed useless testings, added size parameter

---
 Makefile                    |  7 ++----
 include/libhqr.h            |  2 +-
 src/treewalk.c              | 14 +++++------
 testings/testing_treedraw.c | 17 +++++++-------
 testings/testing_treewalk.c | 47 -------------------------------------
 5 files changed, 19 insertions(+), 68 deletions(-)
 delete mode 100644 testings/testing_treewalk.c

diff --git a/Makefile b/Makefile
index f4135c0..803ab99 100644
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,7 @@ CFLAGS = -Iinclude -Wall -g3
 LDFLAGS = -lm
 LIBHQR=src/libhqr.a
 
-default: testing_pivgen testing_treewalk testing_treedraw
+default: testing_pivgen testing_treedraw
 
 src/queue.o:           include/queue.h include/common.h
 src/libhqr.o:          include/common.h include/libhqr.h
@@ -21,9 +21,6 @@ $(LIBHQR): src/libhqr.o src/libhqr_dbg.o src/libhqr_systolic.o src/treewalk.o sr
 testing_pivgen : testings/testing_pivgen.o ${LIBHQR}
 	$(CC) -o $@ $^ $(CFLAGS) $(LDFLAGS)
 
-testing_treewalk : testings/testing_treewalk.c ${LIBHQR}
-	$(CC) -o $@ $^ $(CFLAGS) $(LDFLAGS)
-
 testing_treedraw : testings/testing_treedraw.o ${LIBHQR}
 	$(CC) -o $@ $^ $(CFLAGS) $(LDFLAGS)
 
@@ -34,4 +31,4 @@ clean :
 
 cleanall: clean
 	rm -f ${LIBHQR}
-	rm -f testing_pivgen testing_treewalk testing_treedraw tree.svg
+	rm -f testing_pivgen testing_treedraw tree.svg
diff --git a/include/libhqr.h b/include/libhqr.h
index 4f86864..9f516dc 100644
--- a/include/libhqr.h
+++ b/include/libhqr.h
@@ -194,7 +194,7 @@ void libhqr_hqr_finalize( libhqr_tree_t *qrtree );
  * function for treewalk
  */
 
-void libhqr_treewalk(const libhqr_tree_t *qrtree,int k, int *tiles, FILE *tree);
+void libhqr_treewalk(const libhqr_tree_t *qrtree,int k, int *tiles, FILE *tree, int size);
 
 /*
  * Debugging functions
diff --git a/src/treewalk.c b/src/treewalk.c
index 09bf974..7631973 100644
--- a/src/treewalk.c
+++ b/src/treewalk.c
@@ -36,7 +36,7 @@
  *         Table stocking the tiles and their step
  *
  */
-void libhqr_treewalk(const libhqr_tree_t *qrtree, int k, int *tiles, FILE *tree)
+void libhqr_treewalk(const libhqr_tree_t *qrtree, int k, int *tiles, FILE *tree, int size)
 {
     int tsid = -1, ttid = -1;
     int p = k;
@@ -76,15 +76,15 @@ void libhqr_treewalk(const libhqr_tree_t *qrtree, int k, int *tiles, FILE *tree)
             printf("Call function on (%d, %d)\n",
                    qrtree->currpiv(qrtree, k, tsid), tsid );
             /* Drawing the horizontal lines */
-            ordinate1 = ordinate2 = 100 + 100 * tsid;
-            ordinate3 = ordinate4 = 100 + 100 * qrtree->currpiv(qrtree, k, tsid);
-            absciss1 = 100 + 100 * tiles[tsid];
-            absciss3 = 100 + 100 * tiles[qrtree->currpiv(qrtree, k, tsid)];
+            ordinate1 = ordinate2 = size + size * tsid;
+            ordinate3 = ordinate4 = size + size * qrtree->currpiv(qrtree, k, tsid);
+            absciss1 = (size + (size / 4)) + size * tiles[tsid];
+            absciss3 = (size + (size / 4)) + size * tiles[qrtree->currpiv(qrtree, k, tsid)];
             /* Increasing the step */
             y = libhqr_imax(tiles[tsid],  tiles[qrtree->currpiv(qrtree, k, tsid)]) + 1;
             tiles[tsid] = tiles[qrtree->currpiv(qrtree, k, tsid)] = y;
-            absciss2 = 100 +100 * tiles[tsid];
-            absciss4 = 100 + 100 * tiles[qrtree->currpiv(qrtree, k, tsid)];
+            absciss2 = (size + (size / 4)) + size * tiles[tsid];
+            absciss4 = (size + (size / 4)) + size * tiles[qrtree->currpiv(qrtree, k, tsid)];
             libhqr_drawline( absciss1, ordinate1, absciss2, ordinate2, k, tree);
             libhqr_drawline( absciss3, ordinate3, absciss4, ordinate4, k, tree);
             tsid = libhqr_queue_tile_head(&ts);
diff --git a/testings/testing_treedraw.c b/testings/testing_treedraw.c
index 0a0d3bc..d0e562e 100644
--- a/testings/testing_treedraw.c
+++ b/testings/testing_treedraw.c
@@ -23,6 +23,7 @@
 
 #define WIDTH  50
 #define HEIGHT 50
+#define SIZE 100
 
 int
 main(int argc, char ** argv)
@@ -45,25 +46,25 @@ main(int argc, char ** argv)
     libhqr_writeheader(tree);
     for (k = 0; k < 3; k++){
         /* Drawing the horizontal lines */
-        libhqr_treewalk(&qrtree, k, tiles, tree);
+        libhqr_treewalk(&qrtree, k, tiles, tree, SIZE);
         /* Drawing the vertical lines */
         for (i = k; i < maxMN; i++){
             if (i > 0){
-                absciss1 = absciss2 = 100 + 100 * tiles[i];
-                ordinate1 = 100 + 100 * i;
-                ordinate2 = 100 + 100 * (qrtree.currpiv(&qrtree, k, i));
+                absciss1 = absciss2 = SIZE + SIZE * tiles[i];
+                ordinate1 = SIZE + SIZE * i;
+                ordinate2 = SIZE + SIZE * (qrtree.currpiv(&qrtree, k, i));
                 libhqr_drawline(absciss1, ordinate1, absciss2, ordinate2, k, tree);
             }
         }
 
         /* Drawing the rectangles */
         for (i = k + 1; i < maxMN; i++){
-            absciss1 = 75 + 100 * tiles[i];
-            ordinate1 = 75 + 100 * i;
+            absciss1 = ((SIZE * 3) /4) + SIZE * tiles[i];
+            ordinate1 = ((SIZE * 3) /4) + SIZE * i;
             libhqr_drawTS(absciss1, ordinate1, WIDTH, HEIGHT, k, tree);
             j = qrtree.currpiv(&qrtree, k, i);
-            absciss1 = 75 + 100 * tiles[i];
-            ordinate1 = 75 + 100 * j;
+            absciss1 = ((SIZE * 3) /4) + SIZE * tiles[i];
+            ordinate1 = ((SIZE * 3) /4) + SIZE * j;
             libhqr_drawTT(absciss1, ordinate1, WIDTH, HEIGHT, k, tree);
         }
     }
diff --git a/testings/testing_treewalk.c b/testings/testing_treewalk.c
deleted file mode 100644
index ca656de..0000000
--- a/testings/testing_treewalk.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- *
- * @file testing_treewalk.c
- *
- * Testing the treewalk algorithm using different kind of matrix
- *
- * @copyright 2012-2017 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
- *                      Univ. Bordeaux. All rights reserved.
- *
- * @version 1.0.0
- * @author Raphael Boucherie
- * @author Mathieu Faverge
- * @date 2017-03-21
- *
- */
-#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 *tiles;
-    int maxMN, rc ;
-    FILE *tree = fopen("tree.svg","w+");
-    /*
-     * Test treewalk for HQR trees
-     */
-    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);
-    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);
-    libhqr_treewalk( &qrtree, 0, tiles, tree);
-    libhqr_hqr_finalize( &qrtree );
-    free(tiles);
-}
-- 
GitLab