Skip to content

jacobwilliams/nlesolver-fortran

Repository files navigation

nlesolver-fortran

Nonlinear Equation Solver with Modern Fortran.

A basic Newton-Raphson type nonlinear equation solver for dense systems with m functions of n input variables.

A work in progress.

Status

Language CI Status GitHub release codecov last-commit

Features

  • Is object-oriented.
  • Works with square, under-determined, or over-determined systems.
  • Can use different methods to solve the linear system:
    1. LAPACK routines (dgesv or dgels) for dense systems: If n=m, uses dgesv (LU decomposition). If n/=m, uses dgels (if m>n uses QR factorization, if m<n uses LQ factorization).
    2. lsqr -- a conjugate-gradient type method for solving sparse linear equations and sparse least-squares problems.
    3. lusol -- A sparse LU factorization for square and rectangular matrices, with Bartels-Golub-Reid updates for column replacement and other rank-1 modifications.
    4. lsmr -- a conjugate-gradient type method for solving sparse linear equations and sparse least-squares problems
    5. The user can also provide a custom linear solver.
  • Has a Broyden update option (sparse and dense versions).
  • Has various line search options.
    • use a specified constant step size (0,1]
    • backtracking linesearch method
    • exact linesearch method using fmin minimizer
    • evaluate function at specified fixed points

Compiling

  • A Fortran Package Manager file is also included, so that the library and tests cases can be compiled with FPM. For example:
fpm build --profile release
fpm test --profile release

By default, the library is built with double precision (real64) real values. Explicitly specifying the real kind can be done using the following preprocessor flags:

Preprocessor flag Kind Number of bytes
REAL32 real(kind=real32) 4
REAL64 real(kind=real64) 8
REAL128 real(kind=real128) 16

For example, to build a single precision version of the library, use:

fpm build --profile release --flag "-DREAL32"

To use nlesolver within your fpm project, add the following to your fpm.toml file:

[dependencies]
nlesolver-fortran = { git="https://github.com/jacobwilliams/nlesolver-fortran.git" }

Or to use a specific version:

[dependencies]
nlesolver-fortran = { git="https://github.com/jacobwilliams/nlesolver-fortran.git", tag="1.1.0" }

Note that LAPACK is required to build. The fmin, lsqr, lusol, and lsmr libraries are also dependencies (which will be automatically downloaded by fpm).

Documentation

  • The API documentation for the current master branch can be found here. This is generated by processing the source files with FORD.

License

  • The NLESolver-Fortran source code and related files and documentation are distributed under a permissive free software license (BSD-3).

References

See also

  • MINPACK -- Modernized Minpack: for solving nonlinear equations and nonlinear least squares problems
  • LUSOL Stanford University Systems Optimization Laboratory
  • qr_mumps -- a software package for the solution of sparse, linear systems on multicore computers.