28#if defined(__APPLE__) && defined(__clang__) && defined(APPLE_ACCELERATE_FOUND)
29#include <Availability.h>
30#if defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && \
31 __MAC_OS_X_VERSION_MAX_ALLOWED >= 130300
32#define VOTCA_XTP_ACCELERATE_LAPACK
36#ifdef VOTCA_XTP_ACCELERATE_LAPACK
37#define ACCELERATE_NEW_LAPACK
38#include <Accelerate/Accelerate.h>
47#ifdef VOTCA_XTP_ACCELERATE_LAPACK
50 if (__builtin_available(macOS 13.3, *)) {
56int dsyevd(
char jobz,
char uplo,
long n,
double* a,
long lda,
double* w) {
57 if (__builtin_available(macOS 13.3, *)) {
58 const __LAPACK_int N =
static_cast<__LAPACK_int
>(n);
59 const __LAPACK_int LDA =
static_cast<__LAPACK_int
>(std::max(1L, lda));
60 __LAPACK_int info = 0;
62 double work_query = 0.0;
63 __LAPACK_int iwork_query = 0;
64 __LAPACK_int lwork = -1;
65 __LAPACK_int liwork = -1;
66 dsyevd_(&jobz, &uplo, &N, a, &LDA, w, &work_query, &lwork, &iwork_query,
69 return static_cast<int>(info);
71 lwork =
static_cast<__LAPACK_int
>(work_query);
73 std::vector<double> work(
74 static_cast<std::size_t
>(std::max<__LAPACK_int>(1, lwork)));
75 std::vector<__LAPACK_int> iwork(
76 static_cast<std::size_t
>(std::max<__LAPACK_int>(1, liwork)));
77 dsyevd_(&jobz, &uplo, &N, a, &LDA, w, work.data(), &lwork, iwork.data(),
79 return static_cast<int>(info);
84int dpotrf(
char uplo,
long n,
double* a,
long lda) {
85 if (__builtin_available(macOS 13.3, *)) {
86 const __LAPACK_int N =
static_cast<__LAPACK_int
>(n);
87 const __LAPACK_int LDA =
static_cast<__LAPACK_int
>(std::max(1L, lda));
88 __LAPACK_int info = 0;
89 dpotrf_(&uplo, &N, a, &LDA, &info);
90 return static_cast<int>(info);
95int dpotri(
char uplo,
long n,
double* a,
long lda) {
96 if (__builtin_available(macOS 13.3, *)) {
97 const __LAPACK_int N =
static_cast<__LAPACK_int
>(n);
98 const __LAPACK_int LDA =
static_cast<__LAPACK_int
>(std::max(1L, lda));
99 __LAPACK_int info = 0;
100 dpotri_(&uplo, &N, a, &LDA, &info);
101 return static_cast<int>(info);
109int dsyevd(
char,
char,
long,
double*,
long,
double*) {
LAPACK routines of Apple Accelerate, called directly.
bool LapackAvailable()
Whether the routines below can run here (Accelerate build, macOS 13.3+).
int dpotrf(char uplo, long n, double *a, long lda)
Cholesky factorisation of a symmetric positive definite matrix.
int dpotri(char uplo, long n, double *a, long lda)
Inverse from the Cholesky factor of dpotrf (one triangle).
int dsyevd(char jobz, char uplo, long n, double *a, long lda, double *w)
constexpr int kAccelerateUnavailable
Charge transport classes.
Provides a means for comparing floating point numbers.