-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimple_debug.cpp
More file actions
35 lines (27 loc) · 1.05 KB
/
simple_debug.cpp
File metadata and controls
35 lines (27 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <iostream>
#include <vector>
// LAPACK function
extern "C" {
void dpotrf_(const char* uplo, const int* n, double* a, const int* lda, int* info);
}
int main() {
std::cout << "Testing basic LAPACK Cholesky on identity matrix\n";
// 2x2 identity matrix in column-major order
int n = 2;
double matrix[4] = {1.0, 0.0, 0.0, 1.0}; // column-major: [1,0; 0,1]
std::cout << "Original matrix (column-major):\n";
std::cout << matrix[0] << " " << matrix[2] << "\n";
std::cout << matrix[1] << " " << matrix[3] << "\n";
int info;
dpotrf_("U", &n, matrix, &n, &info);
std::cout << "After Cholesky factorization, info = " << info << "\n";
std::cout << "Factorized matrix:\n";
std::cout << matrix[0] << " " << matrix[2] << "\n";
std::cout << matrix[1] << " " << matrix[3] << "\n";
if (info == 0) {
std::cout << "SUCCESS: Cholesky factorization worked\n";
} else {
std::cout << "FAILED: Cholesky factorization failed with info = " << info << "\n";
}
return 0;
}