test_lls, a FORTRAN90 code which implements linear least squares (LLS) test problems which are given A and b, and seek a vector x which minimizes the L2 norm of the error ||Ax-b||.

Some linear least squares problems include constraints on the data, such as requiring that every entry of X be positive. This library only contains unconstrained problems. For such problems, the task is typically to find a vector X which minimizes the Euclidean norm of the residual r=Ax-b, or, in cases where multiple minimizers exist, to find the minimizer of minimal Euclidean norm.

TEST_LLS requires access to a compiled copy of the R8LIB library.


The computer code and data files described and made available on this web page are distributed under the MIT license


test_lls is available in a C version and a C++ version and a FORTRAN90 version and a MATLAB version and a Python version.

Related Data and Programs:

BVLS, a FORTRAN90 code which applies least squares methods to solve a linear system for which lower and upper constraints may have been placed on every variable, by Charles Lawson and Richard Hanson.

DQED, a FORTRAN90 code which solves constrained least squares problems, by Richard Hanson and Fred Krogh.

LAWSON, a FORTRAN90 code which contains routines for solving least squares problems and singular value decompositions (SVD), by Charles Lawson, Richard Hanson.

LLSQ, a FORTRAN90 code which solves the simple linear least squares problem of finding the formula of a straight line y=a*x+b which minimizes the root-mean-square error to a set of N data points.

MINPACK, a FORTRAN90 code which solves systems of nonlinear equations, or the least squares minimization of the residual of a set of linear or nonlinear equations.

NMS, a FORTRAN90 code which includes a wide variety of numerical software, including solvers for linear systems of equations, interpolation of data, numerical quadrature, linear least squares data fitting, the solution of nonlinear equations, ordinary differential equations, optimization and nonlinear least squares, simulation and random numbers, trigonometric approximation and Fast Fourier Transforms (FFT).

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

R8LIB, a FORTRAN90 code which contains many utility routines using double precision real (R8) arithmetic.



  1. Cleve Moler,
    Numerical Computing with MATLAB,
    SIAM, 2004,
    ISBN13: 978-0-898716-60-3,
    LC: QA297.M625,
    ebook: https://www.mathworks.com/moler/chapters.html

Source Code:

Last revised on 03 September 2020.