Bounded Variable Least Squares Solver

BVLS is a FORTRAN90 library which solves a least squares problem with bounds on the variables, by Charles Lawson and Richard Hanson.

Given an M by N matrix, A, and an M-vector, B, BVLS computes an N-vector X that solves the least-squares problem:

A * X = B
subject to BND(1,J) <= X(J) <= BND(2,J) for 1 <= J <= N.

The program allows the user to bound some or all of the variables. The user is also free to constrain some variables with only a one-sided bounded. The values BND(1,J) = -huge(ONE) and BND(2,J) = huge(ONE) are suggested choices to designate that there is no constraint in that direction. The parameter ONE is 1.0 in the working precision.

This algorithm is a generalization of the routine NNLS, which solves the least-squares problem:

A * X = B
subject to 0 <= X(J) for all J.

The subroutine NNLS appeared in 'Solving Least Squares Problems' by Lawson and Hanson, Prentice-Hall, 1974. Work on BVLS was started by Charles Lawson and Richard Hanson at Jet Propulsion Laboratory, 1973 June 12. Many modifications were subsequently made.

This FORTRAN90 version was completed in April 1995 by Richard Hanson. Assumed shape arrays, automatic arrays, array operations, internal subroutines and FORTRAN90 elemental functions are used. Comments are prefixed with an exclamation mark. More than 72 characters appear on some lines. The BVLS package is an additional item for the reprinting of the book by SIAM Publications and the distribution of the code package using netlib and Internet or network facilities.

The original source code is available through NETLIB at


BVLS is available in a FORTRAN90 version.

Related Data and Programs:

BRENT, a FORTRAN90 library which contains Richard Brent's routines for finding the zero, local minimizer, or global minimizer of a scalar function of a scalar argument, without the use of derivative information.

DQED, a FORTRAN90 library which solves constrained least squares problems.

LAWSON, a FORTRAN90 library which solves least squares problems, and computes singular value decompositions.

NL2SOL, a FORTRAN90 library which implements an adaptive nonlinear least-squares algorithm.

PRAXIS, a FORTRAN90 library which minimizes a scalar function of several variables.

QR_SOLVE, a FORTRAN90 library which computes the least squares solution of a linear system A*x=b.

TEST_LS, a FORTRAN90 library which implements linear least squares test problems of the form A*x=b.

TOMS611, a FORTRAN90 library which seeks the minimizer of a scalar functional of multiple variables.


Charles Lawson, Richard Hanson.


  1. Charles Lawson, Richard Hanson,
    Solving Least Squares Problems,
    Revised edition,
    SIAM, 1995,
    ISBN: 0898713560,
    LC: QA275.L38.

Source Code:

Examples and Tests:

List of Routines:

You can go up one level to the FORTRAN90 source codes.

Last revised on 25 June 2014.