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

Finding Inverse of sparse matrix

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

Finding Inverse of sparse matrix

Wed Jul 22, 2015 5:16 pm
I'm not understanding what's wrong with my implementation here - I pretty much just copied it from another example I saw.

Code: Select all
SparseMatrix< complex<float> > A(2, 2);

   A.insert(0, 0) = { 2, 0 };
   A.insert(0, 1) = { 3, 0 };
   A.insert(1, 0) = { 2, 0 };
   A.insert(1, 1) = { 2, 0 };

   SimplicialLLT<SparseMatrix<complex<float> > > solverA;
//   A.makeCompressed();
   solverA.compute(A);

   if (solverA.info() != Success) {
      cout << "Oh: Very bad" << endl;
   }

   SparseMatrix<float> eye(2, 2);
   eye.setIdentity();

   SparseMatrix<complex<float> > inv_A = solverA.solve(eye);

   cout << "A:\n" << A << endl;
   cout << "inv_A\n" << inv_A << endl;


The A matrix is specified as
[2 3]
[2 2]

The A inverse SHOULD be
[-1 3/2]
[1 -1]

but the program is outputting
[8.38861E6 -8.38861E6]
[-8.38861E6 8.38861E6]
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
SimplicialLLT is for symmetric matrices.


Bookmarks



Who is online

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