Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/harusametime/lsqrwitheigen
C++ Implementation of LSQR with Eigen
https://github.com/harusametime/lsqrwitheigen
Last synced: about 2 months ago
JSON representation
C++ Implementation of LSQR with Eigen
- Host: GitHub
- URL: https://github.com/harusametime/lsqrwitheigen
- Owner: harusametime
- License: apache-2.0
- Created: 2016-06-27T00:14:41.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2020-04-10T14:13:06.000Z (over 4 years ago)
- Last Synced: 2024-08-12T09:49:47.397Z (4 months ago)
- Language: C++
- Homepage:
- Size: 13.7 KB
- Stars: 15
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# LSQRwithEigen
## Motivation
LSQR[1] is an algorithm for solving linear system Ax=b in least-square sense. LSQR is similar to, but is more robust on ill-conditioned problems (the condition number of A is large) than Conjugate Gradient method. Although I found several implementaions of LSQR, I want a LSQR library that can deal with matrix A and vector b defined with [Eigen](http://eigen.tuxfamily.org/index.php).[1] Christopher C. Paige and Michael A. Saunders. 1982. LSQR: An Algorithm for Sparse Linear Equations and Sparse Least Squares. ACM Trans. Math. Softw. 8, 1 (March 1982), 43-71. DOI=http://dx.doi.org/10.1145/355984.355989
## Requirement
Source code of Eigen 3
( See the webpage of [Eigen](http://eigen.tuxfamily.org/index.php). )## How to use it
1. Put the source code of Eigen 3 to the same directory as *LSQR.cpp*, *LSQR.h*, and *example.cpp*.
2. In order to solve the linear system Ax =b, write the following code (See also *example.cpp*):```
LSQR lsqr = LSQR(A, b, x, 1.0e-8);
```
where A, b and x must be SparseMatrix, VectorXd and VectorXd of Eigen. LSQR starts to solve the problem using given *x* as the initial solution. **So please note that *x* must be initialized before solving**. If you can guess *x* by the other ways, you can input the guess to *x*. Otherwise, *x* is initialized as a zero vector in general.
3. We can get the solution by LSQR with:```
x = lsqr.SolutionX();
```