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

lib/gmath: properly guard BLAS and LAPACK dependent code #4346

Merged
merged 5 commits into from
Sep 20, 2024
Merged
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
41 changes: 15 additions & 26 deletions lib/gmath/la.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,24 @@
******************************************************************************/

#include <grass/config.h>
#include <grass/gis.h>
#include <grass/glocale.h>
#include <grass/la.h>

#if defined(HAVE_LIBLAPACK) && defined(HAVE_LIBBLAS)
#if defined(HAVE_LIBBLAS) && defined(HAVE_LIBLAPACK)

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <lapacke.h>
#if defined(HAVE_CBLAS_ATLAS_H)
#include <cblas-atlas.h>
#else
#include <cblas.h>
#endif
#endif
#endif // HAVE_CBLAS_ATLAS_H

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
#include <grass/glocale.h>
#include <grass/la.h>

static int egcmp(const void *pa, const void *pb);

Expand Down Expand Up @@ -335,8 +336,6 @@ mat_struct *G__matrix_add(mat_struct *mt1, mat_struct *mt2, const double c1,
return mt3;
}

#if defined(HAVE_LIBBLAS)

/*!
* \fn mat_struct *G_matrix_product (mat_struct *mt1, mat_struct *mt2)
*
Expand Down Expand Up @@ -386,8 +385,6 @@ mat_struct *G_matrix_product(mat_struct *mt1, mat_struct *mt2)
return mt3;
}

#endif /* defined(HAVE_LIBBLAS) */

/*!
* \fn mat_struct *G_matrix_transpose (mat_struct *mt)
*
Expand Down Expand Up @@ -442,8 +439,6 @@ mat_struct *G_matrix_transpose(mat_struct *mt)
return mt1;
}

#if defined(HAVE_LIBBLAS) && defined(HAVE_LIBLAPACK)

/*!
* \fn int G_matrix_LU_solve (const mat_struct *mt1, mat_struct **xmat0,
* const mat_struct *bmat, mat_type mtype)
Expand Down Expand Up @@ -578,10 +573,6 @@ int G_matrix_LU_solve(const mat_struct *mt1, mat_struct **xmat0,
return 0;
}

#endif /* defined(HAVE_LIBBLAS) && defined(HAVE_LIBLAPACK) */

#if defined(HAVE_LIBBLAS) && defined(HAVE_LIBLAPACK)

/*!
* \fn mat_struct *G_matrix_inverse (mat_struct *mt)
*
Expand Down Expand Up @@ -637,8 +628,6 @@ mat_struct *G_matrix_inverse(mat_struct *mt)
}
}

#endif /* defined(HAVE_LIBBLAS) && defined(HAVE_LIBLAPACK) */

/*!
* \fn void G_matrix_free (mat_struct *mt)
*
Expand Down Expand Up @@ -1149,8 +1138,6 @@ int G_vector_set(vec_struct *A, int cells, int ldim, vtype vt, int vindx)
return 0;
}

#if defined(HAVE_LIBBLAS)

/*!
* \fn double G_vector_norm_euclid (vec_struct *vc)
*
Expand Down Expand Up @@ -1192,8 +1179,6 @@ double G_vector_norm_euclid(vec_struct *vc)
return cblas_dnrm2(Nval, startpt, incr);
}

#endif /* defined(HAVE_LIBBLAS) */

/*!
* \fn double G_vector_norm_maxval (vec_struct *vc, int vflag)
*
Expand Down Expand Up @@ -1655,3 +1640,7 @@ static int egcmp(const void *pa, const void *pb)

return 0;
}

#endif // HAVE_LIBLAPACK HAVE_LIBBLAS

typedef int suppress_empty_translation_unit_compiler_warning;
Loading