From 401a7513a23d97d791936230678ba2696b8c8692 Mon Sep 17 00:00:00 2001
From: Mathieu Faverge <mathieu.faverge@inria.fr>
Date: Mon, 5 Feb 2018 18:56:59 +0100
Subject: [PATCH] Remove COMPLEX/REAL from coreblas

---
 coreblas/compute/core_zgessq.c |  5 +----
 coreblas/compute/core_zhemm.c  |  6 ------
 coreblas/compute/core_zher2k.c |  6 ------
 coreblas/compute/core_zherk.c  |  6 ------
 coreblas/compute/core_zhessq.c | 10 ++++------
 coreblas/compute/core_zplghe.c | 13 +++++--------
 coreblas/compute/core_zplgsy.c | 11 ++++-------
 coreblas/compute/core_zplrnt.c |  7 ++-----
 coreblas/compute/core_zsyssq.c | 10 ++++------
 coreblas/compute/core_ztrssq.c |  6 ++----
 coreblas/compute/core_ztslqt.c |  6 ++----
 coreblas/compute/core_ztsqrt.c |  8 +++-----
 coreblas/compute/core_zttlqt.c |  8 +++-----
 coreblas/compute/core_zttqrt.c |  8 +++-----
 14 files changed, 33 insertions(+), 77 deletions(-)

diff --git a/coreblas/compute/core_zgessq.c b/coreblas/compute/core_zgessq.c
index ac4547a37..9a8723dbd 100644
--- a/coreblas/compute/core_zgessq.c
+++ b/coreblas/compute/core_zgessq.c
@@ -23,8 +23,6 @@
 #include "coreblas/lapacke.h"
 #include "coreblas.h"
 
-#define COMPLEX
-
 #define UPDATE( __nb, __value )                                         \
     if (__value != 0. ){                                                \
         if ( *scale < __value ) {                                       \
@@ -89,7 +87,6 @@
  *          \retval -k, the k-th argument had an illegal value
  *
  */
-
 int CORE_zgessq(int M, int N,
                 const MORSE_Complex64_t *A, int LDA,
                 double *scale, double *sumsq)
@@ -104,7 +101,7 @@ int CORE_zgessq(int M, int N,
             tmp = fabs(*ptr);
             UPDATE( 1., tmp );
 
-#ifdef COMPLEX
+#if defined(PRECISION_z) || defined(PRECISION_c)
             ptr++;
             tmp = fabs(*ptr);
             UPDATE( 1., tmp );
diff --git a/coreblas/compute/core_zhemm.c b/coreblas/compute/core_zhemm.c
index ba7255f9c..c908bd7e8 100644
--- a/coreblas/compute/core_zhemm.c
+++ b/coreblas/compute/core_zhemm.c
@@ -25,9 +25,6 @@
  */
 #include "coreblas.h"
 
-#undef REAL
-#define COMPLEX
-#ifdef COMPLEX
 /**
  *
  * @ingroup CORE_MORSE_Complex64_t
@@ -47,6 +44,3 @@ void CORE_zhemm(MORSE_enum side, MORSE_enum uplo,
         B, LDB,
         CBLAS_SADDR(beta), C, LDC);
 }
-
-
-#endif
diff --git a/coreblas/compute/core_zher2k.c b/coreblas/compute/core_zher2k.c
index 8b894f50b..f7af24a7d 100644
--- a/coreblas/compute/core_zher2k.c
+++ b/coreblas/compute/core_zher2k.c
@@ -25,9 +25,6 @@
  */
 #include "coreblas.h"
 
-#undef REAL
-#define COMPLEX
-#ifdef COMPLEX
 /**
  *
  * @ingroup CORE_MORSE_Complex64_t
@@ -46,6 +43,3 @@ void CORE_zher2k(MORSE_enum uplo, MORSE_enum trans,
         CBLAS_SADDR(alpha), A, LDA, B, LDB,
         beta, C, LDC);
 }
-
-
-#endif
diff --git a/coreblas/compute/core_zherk.c b/coreblas/compute/core_zherk.c
index bff780e94..ec57c9e35 100644
--- a/coreblas/compute/core_zherk.c
+++ b/coreblas/compute/core_zherk.c
@@ -25,9 +25,6 @@
  */
 #include "coreblas.h"
 
-#undef REAL
-#define COMPLEX
-#ifdef COMPLEX
 /**
  *
  * @ingroup CORE_MORSE_Complex64_t
@@ -45,6 +42,3 @@ void CORE_zherk(MORSE_enum uplo, MORSE_enum trans,
         alpha, A, LDA,
         beta, C, LDC);
 }
-
-
-#endif
diff --git a/coreblas/compute/core_zhessq.c b/coreblas/compute/core_zhessq.c
index 427c62cc2..23915b59a 100644
--- a/coreblas/compute/core_zhessq.c
+++ b/coreblas/compute/core_zhessq.c
@@ -23,8 +23,6 @@
 #include "coreblas/lapacke.h"
 #include "coreblas.h"
 
-#define COMPLEX
-
 #define UPDATE( __nb, __value )                                         \
     if (__value != 0. ){                                                \
         if ( *scale < __value ) {                                       \
@@ -113,7 +111,7 @@ int CORE_zhessq(MORSE_enum uplo, int N,
                 tmp = fabs(*ptr);
                 UPDATE( 2., tmp );
 
-#ifdef COMPLEX
+#if defined(PRECISION_z) || defined(PRECISION_c)
                 ptr++;
                 tmp = fabs(*ptr);
                 UPDATE( 2., tmp );
@@ -124,7 +122,7 @@ int CORE_zhessq(MORSE_enum uplo, int N,
             tmp = fabs(*ptr);
             UPDATE( 1., tmp );
 
-#ifdef COMPLEX
+#if defined(PRECISION_z) || defined(PRECISION_c)
             ptr++;
 #endif
         }
@@ -138,7 +136,7 @@ int CORE_zhessq(MORSE_enum uplo, int N,
             UPDATE( 1., tmp );
             ptr++;
 
-#ifdef COMPLEX
+#if defined(PRECISION_z) || defined(PRECISION_c)
             ptr++;
 #endif
 
@@ -147,7 +145,7 @@ int CORE_zhessq(MORSE_enum uplo, int N,
                 tmp = fabs(*ptr);
                 UPDATE( 2., tmp );
 
-#ifdef COMPLEX
+#if defined(PRECISION_z) || defined(PRECISION_c)
                 ptr++;
                 tmp = fabs(*ptr);
                 UPDATE( 2., tmp );
diff --git a/coreblas/compute/core_zplghe.c b/coreblas/compute/core_zplghe.c
index ff9f984a8..6c5d16f42 100644
--- a/coreblas/compute/core_zplghe.c
+++ b/coreblas/compute/core_zplghe.c
@@ -25,9 +25,6 @@
  */
 #include "coreblas.h"
 
-#define COMPLEX
-#undef REAL
-
 /*
  Rnd64seed is a global variable but it doesn't spoil thread safety. All matrix
  generating threads only read Rnd64seed. It is safe to set Rnd64seed before
@@ -41,7 +38,7 @@
 #define RndF_Mul 5.4210108624275222e-20f
 #define RndD_Mul 5.4210108624275222e-20
 
-#ifdef COMPLEX
+#if defined(PRECISION_z) || defined(PRECISION_c)
 #define NBELEM   2
 #else
 #define NBELEM   1
@@ -87,7 +84,7 @@ void CORE_zplghe( double bump, int m, int n, MORSE_Complex64_t *A, int lda,
             for (i = j; i < m; i++) {
                 *tmp = 0.5f - ran * RndF_Mul;
                 ran  = Rnd64_A * ran + Rnd64_C;
-#ifdef COMPLEX
+#if defined(PRECISION_z) || defined(PRECISION_c)
                 *tmp += I*(0.5f - ran * RndF_Mul);
                 ran   = Rnd64_A * ran + Rnd64_C;
 #endif
@@ -98,7 +95,7 @@ void CORE_zplghe( double bump, int m, int n, MORSE_Complex64_t *A, int lda,
         }
 
         for (j = 0; j < n; j++) {
-#ifdef COMPLEX
+#if defined(PRECISION_z) || defined(PRECISION_c)
             A[j+j*lda] += bump - I*cimag( A[j+j*lda] );
 #else
             A[j+j*lda] += bump;
@@ -119,7 +116,7 @@ void CORE_zplghe( double bump, int m, int n, MORSE_Complex64_t *A, int lda,
             for (i = 0; i < m; i++) {
                 *tmp = 0.5f - ran * RndF_Mul;
                 ran  = Rnd64_A * ran + Rnd64_C;
-#ifdef COMPLEX
+#if defined(PRECISION_z) || defined(PRECISION_c)
                 *tmp += I*(0.5f - ran * RndF_Mul);
                 ran   = Rnd64_A * ran + Rnd64_C;
 #endif
@@ -142,7 +139,7 @@ void CORE_zplghe( double bump, int m, int n, MORSE_Complex64_t *A, int lda,
             for (j = 0; j < n; j++) {
                 A[j*lda+i] = 0.5f - ran * RndF_Mul;
                 ran = Rnd64_A * ran + Rnd64_C;
-#ifdef COMPLEX
+#if defined(PRECISION_z) || defined(PRECISION_c)
                 A[j*lda+i] -= I*(0.5f - ran * RndF_Mul);
                 ran = Rnd64_A * ran + Rnd64_C;
 #endif
diff --git a/coreblas/compute/core_zplgsy.c b/coreblas/compute/core_zplgsy.c
index 4f61012ae..e2af54bdb 100644
--- a/coreblas/compute/core_zplgsy.c
+++ b/coreblas/compute/core_zplgsy.c
@@ -25,9 +25,6 @@
  */
 #include "coreblas.h"
 
-#define COMPLEX
-#undef REAL
-
 /*
  Rnd64seed is a global variable but it doesn't spoil thread safety. All matrix
  generating threads only read Rnd64seed. It is safe to set Rnd64seed before
@@ -41,7 +38,7 @@
 #define RndF_Mul 5.4210108624275222e-20f
 #define RndD_Mul 5.4210108624275222e-20
 
-#ifdef COMPLEX
+#if defined(PRECISION_z) || defined(PRECISION_c)
 #define NBELEM   2
 #else
 #define NBELEM   1
@@ -88,7 +85,7 @@ void CORE_zplgsy( MORSE_Complex64_t bump, int m, int n, MORSE_Complex64_t *A, in
             for (i = j; i < m; i++) {
                 *tmp = 0.5f - ran * RndF_Mul;
                 ran  = Rnd64_A * ran + Rnd64_C;
-#ifdef COMPLEX
+#if defined(PRECISION_z) || defined(PRECISION_c)
                 *tmp += I*(0.5f - ran * RndF_Mul);
                 ran   = Rnd64_A * ran + Rnd64_C;
 #endif
@@ -116,7 +113,7 @@ void CORE_zplgsy( MORSE_Complex64_t bump, int m, int n, MORSE_Complex64_t *A, in
             for (i = 0; i < m; i++) {
                 *tmp = 0.5f - ran * RndF_Mul;
                 ran  = Rnd64_A * ran + Rnd64_C;
-#ifdef COMPLEX
+#if defined(PRECISION_z) || defined(PRECISION_c)
                 *tmp += I*(0.5f - ran * RndF_Mul);
                 ran   = Rnd64_A * ran + Rnd64_C;
 #endif
@@ -139,7 +136,7 @@ void CORE_zplgsy( MORSE_Complex64_t bump, int m, int n, MORSE_Complex64_t *A, in
             for (j = 0; j < n; j++) {
                 A[j*lda+i] = 0.5f - ran * RndF_Mul;
                 ran = Rnd64_A * ran + Rnd64_C;
-#ifdef COMPLEX
+#if defined(PRECISION_z) || defined(PRECISION_c)
                 A[j*lda+i] += I*(0.5f - ran * RndF_Mul);
                 ran = Rnd64_A * ran + Rnd64_C;
 #endif
diff --git a/coreblas/compute/core_zplrnt.c b/coreblas/compute/core_zplrnt.c
index f272dd3f9..8f4971dab 100644
--- a/coreblas/compute/core_zplrnt.c
+++ b/coreblas/compute/core_zplrnt.c
@@ -25,9 +25,6 @@
  */
 #include "coreblas.h"
 
-#define COMPLEX
-#undef REAL
-
 /*
  Rnd64seed is a global variable but it doesn't spoil thread safety. All matrix
  generating threads only read Rnd64seed. It is safe to set Rnd64seed before
@@ -41,7 +38,7 @@
 #define RndF_Mul 5.4210108624275222e-20f
 #define RndD_Mul 5.4210108624275222e-20
 
-#ifdef COMPLEX
+#if defined(PRECISION_z) || defined(PRECISION_c)
 #define NBELEM   2
 #else
 #define NBELEM   1
@@ -82,7 +79,7 @@ void CORE_zplrnt( int m, int n, MORSE_Complex64_t *A, int lda,
         for (i = 0; i < m; ++i) {
             *tmp = 0.5f - ran * RndF_Mul;
             ran  = Rnd64_A * ran + Rnd64_C;
-#ifdef COMPLEX
+#if defined(PRECISION_z) || defined(PRECISION_c)
             *tmp += I*(0.5f - ran * RndF_Mul);
             ran   = Rnd64_A * ran + Rnd64_C;
 #endif
diff --git a/coreblas/compute/core_zsyssq.c b/coreblas/compute/core_zsyssq.c
index 80b16a4cc..b1c16e6f3 100644
--- a/coreblas/compute/core_zsyssq.c
+++ b/coreblas/compute/core_zsyssq.c
@@ -23,8 +23,6 @@
 #include "coreblas/lapacke.h"
 #include "coreblas.h"
 
-#define COMPLEX
-
 #define UPDATE( __nb, __value )                                         \
     if (__value != 0. ){                                                \
         if ( *scale < __value ) {                                       \
@@ -113,7 +111,7 @@ int CORE_zsyssq(MORSE_enum uplo, int N,
                 tmp = fabs(*ptr);
                 UPDATE( 2., tmp );
 
-#ifdef COMPLEX
+#if defined(PRECISION_z) || defined(PRECISION_c)
                 ptr++;
                 tmp = fabs(*ptr);
                 UPDATE( 2., tmp );
@@ -124,7 +122,7 @@ int CORE_zsyssq(MORSE_enum uplo, int N,
             tmp = fabs(*ptr);
             UPDATE( 1., tmp );
 
-#ifdef COMPLEX
+#if defined(PRECISION_z) || defined(PRECISION_c)
             ptr++;
             tmp = fabs(*ptr);
             UPDATE( 1., tmp );
@@ -140,7 +138,7 @@ int CORE_zsyssq(MORSE_enum uplo, int N,
             UPDATE( 1., tmp );
             ptr++;
 
-#ifdef COMPLEX
+#if defined(PRECISION_z) || defined(PRECISION_c)
             tmp = fabs(*ptr);
             UPDATE( 1., tmp );
             ptr++;
@@ -151,7 +149,7 @@ int CORE_zsyssq(MORSE_enum uplo, int N,
                 tmp = fabs(*ptr);
                 UPDATE( 2., tmp );
 
-#ifdef COMPLEX
+#if defined(PRECISION_z) || defined(PRECISION_c)
                 ptr++;
                 tmp = fabs(*ptr);
                 UPDATE( 2., tmp );
diff --git a/coreblas/compute/core_ztrssq.c b/coreblas/compute/core_ztrssq.c
index 53eb52f0f..207768b32 100644
--- a/coreblas/compute/core_ztrssq.c
+++ b/coreblas/compute/core_ztrssq.c
@@ -23,8 +23,6 @@
 #include "coreblas/lapacke.h"
 #include "coreblas.h"
 
-#define COMPLEX
-
 #define UPDATE( __nb, __value )                                         \
     if (__value != 0. ){                                                \
         if ( *scale < __value ) {                                       \
@@ -115,7 +113,7 @@ int CORE_ztrssq(MORSE_enum uplo, MORSE_enum diag, int M, int N,
                 tmp = fabs(*ptr);
                 UPDATE( 1., tmp );
 
-#ifdef COMPLEX
+#if defined(PRECISION_z) || defined(PRECISION_c)
                 ptr++;
                 tmp = fabs(*ptr);
                 UPDATE( 1., tmp );
@@ -133,7 +131,7 @@ int CORE_ztrssq(MORSE_enum uplo, MORSE_enum diag, int M, int N,
                 tmp = fabs(*ptr);
                 UPDATE( 1., tmp );
 
-#ifdef COMPLEX
+#if defined(PRECISION_z) || defined(PRECISION_c)
                 ptr++;
                 tmp = fabs(*ptr);
                 UPDATE( 1., tmp );
diff --git a/coreblas/compute/core_ztslqt.c b/coreblas/compute/core_ztslqt.c
index 67817bc41..ce9e955df 100644
--- a/coreblas/compute/core_ztslqt.c
+++ b/coreblas/compute/core_ztslqt.c
@@ -25,8 +25,6 @@
  */
 #include "coreblas/lapacke.h"
 #include "coreblas.h"
-#undef REAL
-#define COMPLEX
 
 /**
  *
@@ -142,7 +140,7 @@ int CORE_ztslqt(int M, int N, int IB,
             /*
              * Generate elementary reflector H( II*IB+I ) to annihilate A( II*IB+I, II*IB+I:N ).
              */
-#ifdef COMPLEX
+#if defined(PRECISION_z) || defined(PRECISION_c)
             LAPACKE_zlacgv_work(N, &A2[ii+i], LDA2);
             LAPACKE_zlacgv_work(1, &A1[LDA1*(ii+i)+ii+i], LDA1);
 #endif
@@ -184,7 +182,7 @@ int CORE_ztslqt(int M, int N, int IB,
                 CBLAS_SADDR(alpha), &A2[ii], LDA2,
                 &A2[ii+i], LDA2,
                 CBLAS_SADDR(zzero), &T[LDT*(ii+i)], 1);
-#ifdef COMPLEX
+#if defined(PRECISION_z) || defined(PRECISION_c)
             LAPACKE_zlacgv_work(N, &A2[ii+i], LDA2 );
             LAPACKE_zlacgv_work(1, &A1[LDA1*(ii+i)+ii+i], LDA1 );
 #endif
diff --git a/coreblas/compute/core_ztsqrt.c b/coreblas/compute/core_ztsqrt.c
index 2a811493e..928414431 100644
--- a/coreblas/compute/core_ztsqrt.c
+++ b/coreblas/compute/core_ztsqrt.c
@@ -25,8 +25,6 @@
  */
 #include "coreblas/lapacke.h"
 #include "coreblas.h"
-#undef REAL
-#define COMPLEX
 
 /**
  *
@@ -144,7 +142,7 @@ int CORE_ztsqrt(int M, int N, int IB,
                     sb-i-1,
                     &A1[LDA1*(ii+i+1)+(ii+i)], LDA1,
                     WORK, 1);
-#ifdef COMPLEX
+#if defined(PRECISION_z) || defined(PRECISION_c)
                 LAPACKE_zlacgv_work(sb-i-1, WORK, 1);
 #endif
                 cblas_zgemv(
@@ -153,14 +151,14 @@ int CORE_ztsqrt(int M, int N, int IB,
                     CBLAS_SADDR(zone), &A2[LDA2*(ii+i+1)], LDA2,
                     &A2[LDA2*(ii+i)], 1,
                     CBLAS_SADDR(zone), WORK, 1);
-#ifdef COMPLEX
+#if defined(PRECISION_z) || defined(PRECISION_c)
                 LAPACKE_zlacgv_work(sb-i-1, WORK, 1 );
 #endif
                 cblas_zaxpy(
                     sb-i-1, CBLAS_SADDR(alpha),
                     WORK, 1,
                     &A1[LDA1*(ii+i+1)+ii+i], LDA1);
-#ifdef COMPLEX
+#if defined(PRECISION_z) || defined(PRECISION_c)
                 LAPACKE_zlacgv_work(sb-i-1, WORK, 1 );
 #endif
                 cblas_zgerc(
diff --git a/coreblas/compute/core_zttlqt.c b/coreblas/compute/core_zttlqt.c
index 4930772b9..3c0aa09b8 100644
--- a/coreblas/compute/core_zttlqt.c
+++ b/coreblas/compute/core_zttlqt.c
@@ -25,8 +25,6 @@
  */
 #include "coreblas/lapacke.h"
 #include "coreblas.h"
-#undef REAL
-#define COMPLEX
 
 /**
  *
@@ -111,7 +109,7 @@ int CORE_zttlqt(int M, int N, int IB,
 {
     static MORSE_Complex64_t zone  = 1.0;
     static MORSE_Complex64_t zzero = 0.0;
-#ifdef COMPLEX
+#if defined(PRECISION_z) || defined(PRECISION_c)
     static int                ione  = 1;
 #endif
 
@@ -154,7 +152,7 @@ int CORE_zttlqt(int M, int N, int IB,
             /*
              * Generate elementary reflector H( II*IB+I ) to annihilate A( II*IB+I, II*IB+I:M ).
              */
-#ifdef COMPLEX
+#if defined(PRECISION_z) || defined(PRECISION_c)
             LAPACKE_zlacgv_work(ni, &A2[j], LDA2);
             LAPACKE_zlacgv_work(ione, &A1[LDA1*j+j], LDA1);
 #endif
@@ -216,7 +214,7 @@ int CORE_zttlqt(int M, int N, int IB,
 
             }
 
-#ifdef COMPLEX
+#if defined(PRECISION_z) || defined(PRECISION_c)
             LAPACKE_zlacgv_work(ni, &A2[j], LDA2 );
             LAPACKE_zlacgv_work(ione, &A1[LDA1*j+j], LDA1 );
 #endif
diff --git a/coreblas/compute/core_zttqrt.c b/coreblas/compute/core_zttqrt.c
index f2d4dfbcf..a55d6d7d3 100644
--- a/coreblas/compute/core_zttqrt.c
+++ b/coreblas/compute/core_zttqrt.c
@@ -25,8 +25,6 @@
  */
 #include "coreblas/lapacke.h"
 #include "coreblas.h"
-#undef REAL
-#define COMPLEX
 
 /**
  *
@@ -166,7 +164,7 @@ int CORE_zttqrt(int M, int N, int IB,
                     &A1[LDA1*(j+1)+j], LDA1,
                     WORK, 1);
 
-#ifdef COMPLEX
+#if defined(PRECISION_z) || defined(PRECISION_c)
                 LAPACKE_zlacgv_work(ni, WORK, 1);
 #endif
                 cblas_zgemv(
@@ -175,7 +173,7 @@ int CORE_zttqrt(int M, int N, int IB,
                     CBLAS_SADDR(zone), &A2[LDA2*(j+1)], LDA2,
                                        &A2[LDA2*j],     1,
                     CBLAS_SADDR(zone), WORK,            1);
-#ifdef COMPLEX
+#if defined(PRECISION_z) || defined(PRECISION_c)
                 LAPACKE_zlacgv_work(ni, WORK, 1);
 #endif
                 alpha = -conj(TAU[j]);
@@ -183,7 +181,7 @@ int CORE_zttqrt(int M, int N, int IB,
                     ni, CBLAS_SADDR(alpha),
                     WORK, 1,
                     &A1[LDA1*(j+1)+j], LDA1);
-#ifdef COMPLEX
+#if defined(PRECISION_z) || defined(PRECISION_c)
                 LAPACKE_zlacgv_work(ni, WORK, 1);
 #endif
                 cblas_zgerc(
-- 
GitLab