You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

dpotrf_bug2562.cpp 712 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #include <string.h>
  2. #include <math.h>
  3. #include <string>
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. void dpotrf_(const char *uplo, const int *n, double *a, const int *lda,
  8. int *info);
  9. #ifdef __cplusplus
  10. }
  11. #endif
  12. int main(void)
  13. {
  14. const size_t n = 32768;
  15. // Create positive definite N X N matrix
  16. double *A = static_cast<double *>(malloc (n * n *sizeof(double)));
  17. for (size_t i = 0; i < n; i++) {
  18. for (size_t j = 0; j < n; j++) {
  19. if (j == i) {
  20. A[i * n + j] = n - 1;
  21. } else {
  22. A[i * n + j] = 1;
  23. }
  24. }
  25. }
  26. // Factorize
  27. const char *uplo = "U";
  28. const int int_n = static_cast<int>(n);
  29. int info;
  30. dpotrf_(uplo, &int_n, A, &int_n, &info);
  31. // Free matrix
  32. free(A);
  33. return 0;
  34. }