From d4579bd42ef73f6572904e2a8fd396a346a8b62e Mon Sep 17 00:00:00 2001
From: Raphael Boucherie <raphael.boucherie@inria.fr>
Date: Tue, 18 Apr 2017 17:43:13 +0200
Subject: [PATCH] added testing file, success on stocking basic info for 1 step

---
 Makefile                    |  7 +++++--
 include/libhqr.h            |  8 +++++++-
 src/libhqr.c                | 12 ++++++++++++
 testings/testing_tileinit.c | 39 +++++++++++++++++++++++++++++++++++++
 4 files changed, 63 insertions(+), 3 deletions(-)
 create mode 100644 testings/testing_tileinit.c

diff --git a/Makefile b/Makefile
index 803ab99..3a7f943 100644
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,7 @@ CFLAGS = -Iinclude -Wall -g3
 LDFLAGS = -lm
 LIBHQR=src/libhqr.a
 
-default: testing_pivgen testing_treedraw
+default: testing_pivgen testing_treedraw testing_tileinit
 
 src/queue.o:           include/queue.h include/common.h
 src/libhqr.o:          include/common.h include/libhqr.h
@@ -24,6 +24,9 @@ testing_pivgen : testings/testing_pivgen.o ${LIBHQR}
 testing_treedraw : testings/testing_treedraw.o ${LIBHQR}
 	$(CC) -o $@ $^ $(CFLAGS) $(LDFLAGS)
 
+testing_tileinit : testings/testing_tileinit.o ${LIBHQR}
+	$(CC) -o $@ $^ $(CFLAGS) $(LDFLAGS)
+
 clean :
 	rm -f include/*~
 	rm -f src/*.o src/*~
@@ -31,4 +34,4 @@ clean :
 
 cleanall: clean
 	rm -f ${LIBHQR}
-	rm -f testing_pivgen testing_treedraw tree.svg
+	rm -f testing_pivgen testing_treedraw testing_tileinit tree.svg
diff --git a/include/libhqr.h b/include/libhqr.h
index f5d10bd..657f61c 100644
--- a/include/libhqr.h
+++ b/include/libhqr.h
@@ -95,7 +95,7 @@ typedef struct libhqr_tiledesc_s{
 
 typedef struct libhqr_tileinfo_s{
     int type;
-    int *currpiv;
+    int currpiv;
     int *nextpiv;
     int *prevpiv;
     int first_nextpiv;
@@ -213,6 +213,12 @@ void draw_horizontal_line(int k, int p, int m, int *tiles, FILE *file);
 void draw_vertical_line(int k, int p, int m, int *tiles, FILE *file);
 void libhqr_print_tree(const libhqr_tree_t *qrtree, libhqr_tiledesc_t *matrix);
 
+/*
+ * functions for stocking the information of each tile
+ */
+
+void libhqr_tile_init(const libhqr_tree_t *qrtree, int k, libhqr_tileinfo_t *tiles);
+
 /*
  * Debugging functions
  */
diff --git a/src/libhqr.c b/src/libhqr.c
index 434bf2f..74775c6 100644
--- a/src/libhqr.c
+++ b/src/libhqr.c
@@ -2740,3 +2740,15 @@ libhqr_svd_init( libhqr_tree_t *qrtree,
     return 0;
 }
 
+void libhqr_tile_init(const libhqr_tree_t *qrtree, int k, libhqr_tileinfo_t *tiles){
+    int i, maxMN;
+    maxMN = libhqr_imax(qrtree->nt, qrtree->mt);
+    for (i = 0; i < maxMN; i++){
+        tiles[i].first_nextpiv = qrtree->nextpiv(qrtree, k, i, qrtree->mt);
+        tiles[i].first_prevpiv = qrtree->prevpiv(qrtree, k, i, i);
+        tiles[i].type = qrtree->gettype(qrtree, k, i);
+        tiles[i].currpiv = qrtree->currpiv(qrtree, k, i);
+        printf("Info on tiles %d on step %d :\n first_nextpiv = %d\n first_prevpiv = %d\n currpiv = %d\n",
+               i, k, tiles[i].first_nextpiv, tiles[i].first_prevpiv, tiles[i].currpiv);
+    }
+}
diff --git a/testings/testing_tileinit.c b/testings/testing_tileinit.c
new file mode 100644
index 0000000..7938c86
--- /dev/null
+++ b/testings/testing_tileinit.c
@@ -0,0 +1,39 @@
+/**
+ *
+ * @file testting_tileinit.c
+ *
+ * Testing file for the functions stocking the informations of the tiles
+ *
+ * @copyright 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-04-18
+ *
+ */
+
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include "libhqr.h"
+
+int
+main(int argc, char ** argv)
+{
+    libhqr_tree_t qrtree;
+    libhqr_tiledesc_t matrix;
+    libhqr_tileinfo_t *tiles;
+    matrix.nodes = 1;
+    matrix.p     = 1;
+    matrix.mt    = 16;
+    matrix.nt    = 4;
+    tiles = (libhqr_tileinfo_t*)malloc(matrix.mt*sizeof(libhqr_tileinfo_t));
+    libhqr_hqr_init( &qrtree, LIBHQR_QR, &matrix, LIBHQR_BINARY_TREE, LIBHQR_FLAT_TREE, 1, 2, 0, 0);
+    libhqr_tile_init(&qrtree, 0, tiles);
+    libhqr_hqr_finalize( &qrtree );
+    free(tiles);
+    return 1;
+}
-- 
GitLab