Bounded Variable Least Squares Solver

BVLS is a FORTRAN77 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.

The original source code is available through NETLIB at


BVLS is available in a FORTRAN77 version and a FORTRAN90 version.

Related Data and Programs:

BRENT, a FORTRAN77 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.

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

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

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

TOMS611, a FORTRAN77 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.