From 2a75802dd7977ab5847b062d283ad83f4b95fad2 Mon Sep 17 00:00:00 2001
From: Mathieu Faverge <mathieu.faverge@inria.fr>
Date: Fri, 28 Jul 2017 13:03:59 +0200
Subject: [PATCH] automaticaly set p to the right value when -1 is given

---
 src/hqr.c | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/src/hqr.c b/src/hqr.c
index 1522aaf..d1b856d 100644
--- a/src/hqr.c
+++ b/src/hqr.c
@@ -806,8 +806,24 @@ libhqr_initfct_hqr( libhqr_tree_t *qrtree,
     }
 
     /* Compute parameters */
-    a = (a == -1) ? 4 : libhqr_imax( a, 1 );
-    p = libhqr_imax( p, 1 );
+    if ( a == -1) {
+        a = 4; /* TODO: add automatic computation */
+    }
+    else {
+        a = libhqr_imax( a, 1 );
+    }
+
+    if ( p == -1 ) {
+        if ( trans == LIBHQR_QR ) {
+            p = A->p;
+        }
+        else {
+            p = A->nodes / A->p;
+        }
+    }
+    else {
+        p = libhqr_imax( p, 1 );
+    }
 
     /* Domino */
     if ( domino >= 0 ) {
-- 
GitLab