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; +}