From a3c9caedf877ac52716cdd758055533be5c1a5f0 Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Sat, 13 Mar 2021 20:34:22 +0100 Subject: [PATCH] Add testcase from issue 2562 --- cpp_thread_test/dpotrf_bug2562.cpp | 42 ++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 cpp_thread_test/dpotrf_bug2562.cpp diff --git a/cpp_thread_test/dpotrf_bug2562.cpp b/cpp_thread_test/dpotrf_bug2562.cpp new file mode 100644 index 000000000..2e2699621 --- /dev/null +++ b/cpp_thread_test/dpotrf_bug2562.cpp @@ -0,0 +1,42 @@ +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +void dpotrf_(const char *uplo, const int *n, double *a, const int *lda, + int *info); + +#ifdef __cplusplus +} +#endif + +int main(void) +{ + const size_t n = 32768; + + // Create positive definite N X N matrix + double *A = static_cast(malloc (n * n *sizeof(double))); + for (size_t i = 0; i < n; i++) { + for (size_t j = 0; j < n; j++) { + if (j == i) { + A[i * n + j] = n - 1; + } else { + A[i * n + j] = 1; + } + } + } + + // Factorize + const char *uplo = "U"; + const int int_n = static_cast(n); + int info; + dpotrf_(uplo, &int_n, A, &int_n, &info); + + // Free matrix + free(A); + + return 0; +}