main class to access the lsqr solver.
You can use this class directory by extending it
and specifying aprod
, or you can use the
lsqr_solver_ez class that has an easier
interface.
User function to access the sparse matrix A
.
User function to access the sparse matrix A
.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(lsqr_solver), | intent(inout) | :: | me | |||
integer, | intent(in) | :: | mode |
|
||
integer, | intent(in) | :: | m |
number of rows in |
||
integer, | intent(in) | :: | n |
number of columns in |
||
real(kind=wp), | intent(inout), | dimension(:) | :: | x | ||
real(kind=wp), | intent(inout), | dimension(:) | :: | y |
main solver routine
LSQR finds a solution to the following problems:
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(lsqr_solver), | intent(inout) | :: | me | |||
integer, | intent(in) | :: | m |
the number of rows in |
||
integer, | intent(in) | :: | n |
the number of columns in |
||
real(kind=wp), | intent(in) | :: | damp |
The damping parameter for problem 3 above.
(damp should be 0.0 for problems 1 and 2.)
If the system |
||
logical, | intent(in) | :: | wantse |
A logical variable to say if the array |
||
real(kind=wp), | intent(inout) | :: | u(m) |
The rhs vector |
||
real(kind=wp), | intent(inout) | :: | v(n) |
workspace |
||
real(kind=wp), | intent(inout) | :: | w(n) |
workspace |
||
real(kind=wp), | intent(out) | :: | x(n) |
Returns the computed solution |
||
real(kind=wp), | intent(out), | dimension(*) | :: | se |
If |
|
real(kind=wp), | intent(in) | :: | atol |
An estimate of the relative error in the data
defining the matrix |
||
real(kind=wp), | intent(in) | :: | btol |
An estimate of the relative error in the data
defining the rhs vector |
||
real(kind=wp), | intent(in) | :: | conlim |
An upper limit on |
||
integer, | intent(in) | :: | itnlim |
An upper limit on the number of iterations.
Suggested value:
* |
||
integer, | intent(in) | :: | nout |
File number for printed output. If nonzero,
a summary will be printed on file |
||
integer, | intent(out) | :: | istop |
An integer giving the reason for termination: |
||
integer, | intent(out) | :: | itn |
The number of iterations performed. |
||
real(kind=wp), | intent(out) | :: | anorm |
An estimate of the Frobenius norm of |
||
real(kind=wp), | intent(out) | :: | acond |
An estimate of |
||
real(kind=wp), | intent(out) | :: | rnorm |
An estimate of the final value of |
||
real(kind=wp), | intent(out) | :: | arnorm |
An estimate of the final value of
|
||
real(kind=wp), | intent(out) | :: | xnorm |
An estimate of the norm of the final
solution vector |
Checks the two modes of aprod for LSQR.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(lsqr_solver), | intent(inout) | :: | me | |||
integer, | intent(in) | :: | m |
No. of rows of A. |
||
integer, | intent(in) | :: | n |
No. of columns of A. |
||
integer, | intent(in) | :: | nout |
A file number for printed output. |
||
real(kind=wp), | intent(in) | :: | eps |
The machine precision. |
||
real(kind=wp) | :: | v(n) | ||||
real(kind=wp) | :: | w(m) | ||||
real(kind=wp) | :: | x(n) | ||||
real(kind=wp) | :: | y(m) | ||||
integer, | intent(out) | :: | inform |
Error indicator. inform = 0 if aprod seems to be consistent. inform = 1 otherwise. |
Tests if x
solves a certain least-squares problem.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(lsqr_solver), | intent(inout) | :: | me | |||
integer, | intent(in) | :: | m |
The number of rows in A. |
||
integer, | intent(in) | :: | n |
The number of columns in A. |
||
integer, | intent(in) | :: | nout |
A file number for printed output. If nout = 0, nothing is printed. |
||
real(kind=wp), | intent(in) | :: | anorm |
An estimate of norm(A) or norm( A, delta*I ) if delta > 0. Normally this will be available from LSQR or CRAIG. |
||
real(kind=wp), | intent(in) | :: | damp |
Possibly defines a damped problem. |
||
real(kind=wp), | intent(in) | :: | eps |
Machine precision. |
||
real(kind=wp), | intent(in) | :: | b(m) |
The right-hand side of Ax = b etc. |
||
real(kind=wp), | intent(out) | :: | u(m) |
On exit, u = r (where r = b - Ax). |
||
real(kind=wp), | intent(out) | :: | v(n) |
On exit, v = A'r. |
||
real(kind=wp), | intent(out) | :: | w(n) |
On exit, w = A'r - damp^2 x. |
||
real(kind=wp), | intent(in) | :: | x(n) |
The given estimate of a solution. |
||
integer, | intent(out) | :: | inform |
inform = 0 if b = 0 and x = 0. inform = 1, 2 or 3 if x seems to solve systems 1 2 or 3 above. |
||
real(kind=wp), | intent(out) | :: | test1 |
These are dimensionless quantities that should be "small" if x does seem to solve one of the systems. "small" means less than tol = eps**power, where power is defined as a parameter below. |
||
real(kind=wp), | intent(out) | :: | test2 |
These are dimensionless quantities that should be "small" if x does seem to solve one of the systems. "small" means less than tol = eps**power, where power is defined as a parameter below. |
||
real(kind=wp), | intent(out) | :: | test3 |
These are dimensionless quantities that should be "small" if x does seem to solve one of the systems. "small" means less than tol = eps**power, where power is defined as a parameter below. |
type,abstract,public :: lsqr_solver !! main class to access the [[lsqr]] solver. !! !! You can use this class directory by extending it !! and specifying `aprod`, or you can use the !! [[lsqr_solver_ez]] class that has an easier !! interface. private contains private procedure(aprod_func),deferred,public :: aprod !! User function to access the sparse matrix `A`. procedure,public :: lsqr !! main solver routine procedure,public :: acheck procedure,public :: xcheck end type lsqr_solver