lsqrtest_module Module

Test module for LSQR.

These routines define a class of least-squares test problems for testing algorithms LSQR and CRAIG (Paige and Saunders, ACM TOMS, 1982).

Author

  • Michael Saunders, Dept of Operations Research, Stanford University.

History

  • 1982---1991: Various versions implemented.
  • 06 Feb 1992: Test-problem generator lstp generalized to allow any m and n. lstp is now the same as the generator for LSQR and CRAIG.
  • 30 Nov 1993: Modified lstp. For a while, damp = 0 implied r = damp*s = 0. This was a result of generating x and s. Reverted to generating x and r as in LSQR paper.
  • 12 Nov 2019 : Jacob Williams : significant refactoring into modern Fortran.

Uses

  • module~~lsqrtest_module~~UsesGraph module~lsqrtest_module lsqrtest_module module~lsqpblas_module lsqpblas_module module~lsqrtest_module->module~lsqpblas_module module~lsqr_kinds lsqr_kinds module~lsqrtest_module->module~lsqr_kinds module~lsqr_module lsqr_module module~lsqrtest_module->module~lsqr_module module~lsqpblas_module->module~lsqr_kinds iso_fortran_env iso_fortran_env module~lsqr_kinds->iso_fortran_env module~lsqr_module->module~lsqpblas_module module~lsqr_module->module~lsqr_kinds

Used by

  • module~~lsqrtest_module~~UsedByGraph module~lsqrtest_module lsqrtest_module program~main main program~main->module~lsqrtest_module

Variables

Type Visibility Attributes Name Initial
integer, private, parameter :: lenrw = 10000

Derived Types

type, private, extends(lsqr_solver) ::  test_solver

Components

Type Visibility Attributes Name Initial
integer, public :: nout = -1

output unit for printing

real(kind=wp), public, dimension(lenrw) :: rw

workspace array

Type-Bound Procedures

procedure, public :: lsqr => LSQR

main solver routine

procedure, public :: acheck
procedure, public :: xcheck
procedure, public :: aprod => aprod_test_solver
procedure, public :: test
procedure, public :: aprod1
procedure, public :: aprod2
procedure, public :: lstp

Subroutines

public subroutine lsqr_test()

Unit test.

Arguments

None

private subroutine test(me, m, n, nduplc, npower, damp)

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).

Read more…

Arguments

Type IntentOptional Attributes Name
class(test_solver), intent(inout) :: me
integer :: m
integer :: n
integer :: nduplc
integer :: npower
real(kind=wp) :: damp

private subroutine aprod_test_solver(me, mode, m, n, x, y)

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.

Arguments

Type IntentOptional 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

private subroutine aprod1(me, m, n, maxmn, minmn, x, y, d, hy, hz, w)

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.

Arguments

Type IntentOptional 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)

private subroutine aprod2(me, m, n, maxmn, minmn, x, y, d, hy, hz, w)

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.

Arguments

Type IntentOptional 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)

private subroutine hprod(n, hz, x, y)

hprod applies a Householder transformation stored in hz to get y = ( I - 2hzhz(transpose) ) * x.

Arguments

Type IntentOptional Attributes Name
integer :: n
real(kind=wp) :: hz(n)
real(kind=wp) :: x(n)
real(kind=wp) :: y(n)

private subroutine lstp(me, m, n, maxmn, minmn, nduplc, npower, damp, x, b, d, hy, hz, w, acond, rnorm)

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.

Read more…

Arguments

Type IntentOptional 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