Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix no-complex build for bml_elemental code #649

Merged
merged 1 commit into from
Aug 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/C-interface/bml_elemental.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
#include "ellpack/bml_elemental_ellpack.h"
#include "ellsort/bml_elemental_ellsort.h"

#ifdef BML_COMPLEX
#include <complex.h>
#endif

/** Return a single matrix element.
*
Expand Down Expand Up @@ -77,7 +79,7 @@ bml_get_element_double_real(
* \param A The bml matrix
* \return The matrix element
*/
float complex
float _Complex
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why change that to _Complex? They are the same but we are using complex everywhere else in the library.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah true, I missed that. But we are also using complex here

float complex
bml_get_element_ellpack_single_complex(
bml_matrix_ellpack_t * A,
int i,
int j)

for example.

Let's merge this PR then as it is and then follow up with a clean up so that the use of comple / _Complex is consistent throughout.

While _Complex is equivalent to complex the former is never mentioned in any API documentation. For example:

CABS(3)

NAME
       cabs, cabsf, cabsl - absolute value of a complex number

SYNOPSIS
       #include <complex.h>

       double cabs(double complex z);
       float cabsf(float complex z);
       long double cabsl(long double complex z);

       Link with -lm.

Also, symbols with preceding _ are typically interpreted as internal symbols not meant for external use.

To make a long story short, I would prefer the consistent use of complex 😄

bml_get_element_single_complex(
bml_matrix_t * A,
int i,
Expand Down Expand Up @@ -108,7 +110,7 @@ bml_get_element_single_complex(
* \param A The bml matrix
* \return The matrix element
*/
double complex
double _Complex
bml_get_element_double_complex(
bml_matrix_t * A,
int i,
Expand Down
8 changes: 6 additions & 2 deletions src/C-interface/bml_elemental.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@

#include "bml_types.h"

#ifdef BML_COMPLEX
#include <complex.h>
#endif

float bml_get_element_single_real(
bml_matrix_t * A,
Expand All @@ -15,14 +17,16 @@ double bml_get_element_double_real(
int i,
int j);

float complex bml_get_element_single_complex(
#ifdef BML_COMPLEX
float _Complex bml_get_element_single_complex(
bml_matrix_t * A,
int i,
int j);

double complex bml_get_element_double_complex(
double _Complex bml_get_element_double_complex(
bml_matrix_t * A,
int i,
int j);
#endif

#endif
8 changes: 6 additions & 2 deletions src/C-interface/dense/bml_elemental_dense.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
#include "bml_elemental_dense.h"
#include "bml_types_dense.h"

#ifdef BML_COMPLEX
#include <complex.h>
#endif

/** Return a single matrix element.
*
Expand Down Expand Up @@ -57,14 +59,15 @@ bml_get_element_dense_double_real(
return ((double *) A->matrix)[ROWMAJOR(i, j, A->N, A->N)];
}

#ifdef BML_COMPLEX
/** Return a single matrix element.
*
* \param A The bml matrix
* \param i The row index
* \param j The column index
* \return The matrix element
*/
float complex
float _Complex
bml_get_element_dense_single_complex(
bml_matrix_dense_t * A,
int i,
Expand All @@ -90,7 +93,7 @@ bml_get_element_dense_single_complex(
* \param j The column index
* \return The matrix element
*/
double complex
double _Complex
bml_get_element_dense_double_complex(
bml_matrix_dense_t * A,
int i,
Expand All @@ -108,3 +111,4 @@ bml_get_element_dense_double_complex(
}
return ((double complex *) A->matrix)[ROWMAJOR(i, j, A->N, A->N)];
}
#endif
8 changes: 6 additions & 2 deletions src/C-interface/dense/bml_elemental_dense.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@

#include "bml_types_dense.h"

#ifdef BML_COMPLEX
#include <complex.h>
#endif

float bml_get_element_dense_single_real(
bml_matrix_dense_t * A,
Expand All @@ -15,14 +17,16 @@ double bml_get_element_dense_double_real(
int i,
int j);

float complex bml_get_element_dense_single_complex(
#ifdef BML_COMPLEX
float _Complex bml_get_element_dense_single_complex(
bml_matrix_dense_t * A,
int i,
int j);

double complex bml_get_element_dense_double_complex(
double _Complex bml_get_element_dense_double_complex(
bml_matrix_dense_t * A,
int i,
int j);
#endif

#endif
8 changes: 6 additions & 2 deletions src/C-interface/ellpack/bml_elemental_ellpack.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
#include "bml_elemental_ellpack.h"
#include "bml_types_ellpack.h"

#ifdef BML_COMPLEX
#include <complex.h>
#endif

/** Return a single matrix element.
*
Expand Down Expand Up @@ -72,14 +74,15 @@ bml_get_element_ellpack_double_real(
return 0;
}

#ifdef BML_COMPLEX
/** Return a single matrix element.
*
* \param A The bml matrix
* \param i The row index
* \param j The column index
* \return The matrix element
*/
float complex
float _Complex
bml_get_element_ellpack_single_complex(
bml_matrix_ellpack_t * A,
int i,
Expand Down Expand Up @@ -113,7 +116,7 @@ bml_get_element_ellpack_single_complex(
* \param j The column index
* \return The matrix element
*/
double complex
double _Complex
bml_get_element_ellpack_double_complex(
bml_matrix_ellpack_t * A,
int i,
Expand All @@ -139,3 +142,4 @@ bml_get_element_ellpack_double_complex(
}
return 0;
}
#endif
8 changes: 6 additions & 2 deletions src/C-interface/ellpack/bml_elemental_ellpack.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@

#include "bml_types_ellpack.h"

#ifdef BML_COMPLEX
#include <complex.h>
#endif

float bml_get_element_ellpack_single_real(
bml_matrix_ellpack_t * A,
Expand All @@ -15,14 +17,16 @@ double bml_get_element_ellpack_double_real(
int i,
int j);

float complex bml_get_element_ellpack_single_complex(
#ifdef BML_COMPLEX
float _Complex bml_get_element_ellpack_single_complex(
bml_matrix_ellpack_t * A,
int i,
int j);

double complex bml_get_element_ellpack_double_complex(
double _Complex bml_get_element_ellpack_double_complex(
bml_matrix_ellpack_t * A,
int i,
int j);
#endif

#endif
8 changes: 6 additions & 2 deletions src/C-interface/ellsort/bml_elemental_ellsort.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
#include "bml_elemental_ellsort.h"
#include "bml_types_ellsort.h"

#ifdef BML_COMPLEX
#include <complex.h>
#endif

/** Return a single matrix element.
*
Expand Down Expand Up @@ -72,14 +74,15 @@ bml_get_element_ellsort_double_real(
return 0;
}

#ifdef BML_COMPLEX
/** Return a single matrix element.
*
* \param A The bml matrix
* \param i The row index
* \param j The column index
* \return The matrix element
*/
float complex
float _Complex
bml_get_element_ellsort_single_complex(
bml_matrix_ellsort_t * A,
int i,
Expand Down Expand Up @@ -113,7 +116,7 @@ bml_get_element_ellsort_single_complex(
* \param j The column index
* \return The matrix element
*/
double complex
double _Complex
bml_get_element_ellsort_double_complex(
bml_matrix_ellsort_t * A,
int i,
Expand All @@ -139,3 +142,4 @@ bml_get_element_ellsort_double_complex(
}
return 0;
}
#endif
8 changes: 6 additions & 2 deletions src/C-interface/ellsort/bml_elemental_ellsort.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@

#include "bml_types_ellsort.h"

#ifdef BML_COMPLEX
#include <complex.h>
#endif

float bml_get_element_ellsort_single_real(
bml_matrix_ellsort_t * A,
Expand All @@ -15,14 +17,16 @@ double bml_get_element_ellsort_double_real(
int i,
int j);

float complex bml_get_element_ellsort_single_complex(
#ifdef BML_COMPLEX
float _Complex bml_get_element_ellsort_single_complex(
bml_matrix_ellsort_t * A,
int i,
int j);

double complex bml_get_element_ellsort_double_complex(
double _Complex bml_get_element_ellsort_double_complex(
bml_matrix_ellsort_t * A,
int i,
int j);
#endif

#endif