I am trying to solve a simple working example, a linear system $Ax=b$, where $A$ is sparse SPD and $b$ is dense, using CHOLMOD.
int main()
{
std::vector<double> A = {4.0, 0.0, 1.0,
0.0, 3.0, 1.0,
1.0, 1.0, 2.0};
std::vector<double> B = {1.0, 1.0, 1.0};
size_t n = sqrt(A.size());
b = cholmod_allocate_dense(n, 1, n, CHOLMOD_REAL, &c);
b->x = &*B.begin();
cholmod_triplet *T;
// Fill T
a = cholmod_triplet_to_sparse(T, Tx.size(), &c);
L = cholmod_analyze(a, &c);
cholmod_factorize(a, L, &c);
x = cholmod_solve(CHOLMOD_A, L, b, &c);
return 0;
}
Does someone know how to print the values of x = cholmod_solve(CHOLMOD_A, L, b, &c)
and how to assign his values to a std::vector
? As I do not know how to print and assign the values of the solution, I even know whether my code is working properly.
I have tried to print the values using std::cout and also printf.