| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer, | public | :: | nout | = | -1 |
output unit for printing |
|
| real(kind=wp), | public, | dimension(lenrw) | :: | rw |
workspace array |
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. |
This is the matrix-vector product routine required by subroutines LSQR and CRAIG for a test matrix of the form A = HYDHZ. The quantities defining D, HY, HZ are in the work array rw, followed by a work array w. These are passed to aprod1 and aprod2 in order to make the code readable.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(test_solver), | intent(inout) | :: | me | |||
| integer, | intent(in) | :: | mode | |||
| integer, | intent(in) | :: | m | |||
| integer, | intent(in) | :: | n | |||
| real(kind=wp), | intent(inout), | dimension(:) | :: | x |
dimension n |
|
| real(kind=wp), | intent(inout), | dimension(:) | :: | y |
dimension m |
This is an example driver routine for running LSQR. It generates a test problem, solves it, and examines the results. Note that subroutine aprod must be declared external if it is used only in the call to LSQR (and acheck).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(test_solver), | intent(inout) | :: | me | |||
| integer | :: | m | ||||
| integer | :: | n | ||||
| integer | :: | nduplc | ||||
| integer | :: | npower | ||||
| real(kind=wp) | :: | damp |
aprod1 computes y = y + Ax for subroutine aprod, where A is a test matrix of the form A = HYD*HZ, and the latter matrices HY, D, HZ are represented by input vectors with the same name.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(test_solver), | intent(inout) | :: | me | |||
| integer | :: | m | ||||
| integer | :: | n | ||||
| integer | :: | maxmn | ||||
| integer | :: | minmn | ||||
| real(kind=wp) | :: | x(n) | ||||
| real(kind=wp) | :: | y(m) | ||||
| real(kind=wp) | :: | d(minmn) | ||||
| real(kind=wp) | :: | hy(m) | ||||
| real(kind=wp) | :: | hz(n) | ||||
| real(kind=wp) | :: | w(maxmn) |
aprod2 computes x = x + A(t)y for subroutine aprod, where A is a test matrix of the form A = HYD*HZ, and the latter matrices HY, D, HZ are represented by input vectors with the same name.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(test_solver), | intent(inout) | :: | me | |||
| integer | :: | m | ||||
| integer | :: | n | ||||
| integer | :: | maxmn | ||||
| integer | :: | minmn | ||||
| real(kind=wp) | :: | x(n) | ||||
| real(kind=wp) | :: | y(m) | ||||
| real(kind=wp) | :: | d(minmn) | ||||
| real(kind=wp) | :: | hy(m) | ||||
| real(kind=wp) | :: | hz(n) | ||||
| real(kind=wp) | :: | w(maxmn) |
lstp generate a sparse least-squares test problem of the form ( A )x = ( b ) ( dampI ) ( 0 ) for solution by LSQR, or a sparse underdetermined system Ax + damps = b for solution by CRAIG. The matrix A is m by n and is constructed in the form A = HYD*HZ, where D is an m by n diagonal matrix, and HY and HZ are Householder transformations.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(test_solver), | intent(inout) | :: | me | |||
| integer | :: | m | ||||
| integer | :: | n | ||||
| integer | :: | maxmn | ||||
| integer | :: | minmn | ||||
| integer | :: | nduplc | ||||
| integer | :: | npower | ||||
| real(kind=wp) | :: | damp | ||||
| real(kind=wp) | :: | x(n) | ||||
| real(kind=wp) | :: | b(m) | ||||
| real(kind=wp) | :: | d(minmn) | ||||
| real(kind=wp) | :: | hy(m) | ||||
| real(kind=wp) | :: | hz(n) | ||||
| real(kind=wp) | :: | w(maxmn) | ||||
| real(kind=wp) | :: | acond | ||||
| real(kind=wp) | :: | rnorm |