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

inversion of large sparse matrix

Tags: sparse matrix, inversion sparse matrix, inversion sparse matrix, inversion
(comma "," separated)
yuriir
Registered Member
Posts
1
Karma
0

inversion of large sparse matrix

Wed Aug 07, 2019 8:54 am
Greetings all,

I need to solve equation which is: b * A^(-1) = x
where
b - vector of double numbers
A - large matrix (90000 * 90000 elements of double type)
x - vector representing results

Due to large size of A matrix i should to make it sparse before solution. Next step it is inversion of A matrix. And the last one step is inversed sparse A matrix multiplication by vector b.

I had read documentation of Eigen and found that code below will work for me:
Code: Select all
VectorXd x(n), b(n);
SparseMatrix<double> A;
SparseLU<SparseMatrix<double>, COLAMDOrdering<int> >   solver;
// fill A and b;
// Compute the ordering permutation vector from the structural pattern of A
solver.analyzePattern(A);
// Compute the numerical factorization
solver.factorize(A);
//Use the factors to solve the linear system
x = solver.solve(b);


So i have two quastions:
1) is it most optimal scheme for solution of such type of equations?
2) what is the most efficient way to define and replace values in A and b ?

Thanks in advance!
andrewmarx
Registered Member
Posts
3
Karma
0

Re: inversion of large sparse matrix

Fri Aug 16, 2019 12:50 pm
This is how I do it with square matrices that have >10^6 rows and columns

Note:

b * A^(-1) = x
x = b * A^(-1)
x * A = b
(x * A)^T = (b)^T https://en.wikipedia.org/wiki/Transpose#Properties
A^T * x^T = b^T

There is your Ax=B form, and this is more-or-less what my code looks like:

Code: Select all
VectorXd x(n), b(n);
SparseMatrix<double> A;
SparseLU<SparseMatrix<double> > solver;

solver.compute(A.transpose());

x = solver.solve(b);


I'm not proficient enough with Eigen to know if this is better, but it's an alternative that might be. You just have to profile/benchmark it and see.


Bookmarks



Who is online

Registered users: Bing [Bot], Evergrowing, Google [Bot], rblackwell