This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Sparse LDLT solver with complex valued matrices

Tags: None
(comma "," separated)
bhasircioglu
Registered Member
Posts
1
Karma
0
Hello,

Does SimplicialLDLT class of SparseCholesky module support matrices whose elements are complex numbers? If so, what is the definition of positive definiteness? I am trying to use it but I am getting the wrong results. According to the definition here (http://mathworld.wolfram.com/PositiveDe ... atrix.html), my matrix is positive definite (eigenvalues of Hermitan part are positive). My code is the following:

Code: Select all
int main() {

  Matrix<complex<double>, Dynamic, 1>  x(4),b(4);

  SparseMatrix<complex<double>> Y_LL(4, 4);
  SimplicialLDLT<SparseMatrix<complex<double>>>   solver;


Y_LL.insert(0,0)=complex<double> (9,2);
Y_LL.insert(0,1)=complex<double> (1,0.5);
Y_LL.insert(1,0)=complex<double> (1,0.5);
Y_LL.insert(1,1)=complex<double> (3.1,2.1); 
Y_LL.insert(1,2)=complex<double> (0.3,1);
Y_LL.insert(2,1)=complex<double> (0.3,1);
Y_LL.insert(2,2)=complex<double> (11,1);
Y_LL.insert(3,2)=complex<double> (9,1.5);
Y_LL.insert(2,3)=complex<double> (9,1.5);
Y_LL.insert(3,3)=complex<double> (8,2);

b<<1,2,3,4;

//cout<<Y_LL<<endl;
//cout<<"b:"<<b<<endl;
solver.compute(Y_LL);

x=solver.solve(b);
cout<<"x:"<<x<<endl;
return 0;
}


The output is:
x:(0.120667,0.360651)
(1.22954,-2.63109)
(-7.57886,0.521748)
(9.12405,0.83407)


However, the correct solution (computed by MATLAB) is:
x =

0.0170 - 0.0537i
0.7715 + 0.0638i
-1.7095 - 0.2113i
2.3747 - 0.0354i


Thanks in advance for any help.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
Your matrix is not self-adjoint (synonym for Hermitian), but symmetric. Its eigenvalues are not even real but complex.


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Google [Bot], Yahoo [Bot]