gosl

module
v1.2.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 28, 2026 License: BSD-3-Clause

README

Gosl — a Go library for scientific computing

Go Reference Go Report Card Awesome

Gosl is a set of tools for developing scientific simulations in Go. Its focus is numerical methods and solvers for differential equations. It also provides fast Fourier transforms, random-number generation, probability distributions, and computational geometry.

The library covers the linear algebra that numerical work requires — operations between all combinations of vectors and matrices, eigenvalues and eigenvectors, and linear solvers — together with the building blocks of numerical methods, such as numerical quadrature.

Gosl links against C and Fortran libraries: OpenBLAS, LAPACK, UMFPACK, MUMPS, QUADPACK, and FFTW3. These libraries have underpinned high-performance simulation for decades, and a rewrite in native Go is unlikely to match their speed: in our benchmark, a naive Go matrix-matrix multiplication runs more than 100 times slower than OpenBLAS.

Installation

Because Gosl links against these libraries, Docker is the easiest way to work with it. With Docker and VS Code installed, you can be running numerical simulations within minutes, on Windows, Linux, or macOS.

  1. Install Docker.
  2. Install Visual Studio Code.
  3. Install the Remote Development extension for VS Code.
  4. Clone https://github.com/cpmech/hello-gosl.
  5. Create your application inside a container (see the recording below).

Your system stays clean.

Native install (Debian/Ubuntu Linux)

This is the path the CI workflow uses, on Ubuntu with Go 1.20 or newer.

First, install Go as explained in https://go.dev/doc/install.

Second, install the C and Fortran libraries that Gosl links against:

sudo apt-get install \
  gcc \
  gfortran \
  libfftw3-dev \
  liblapacke-dev \
  libmetis-dev \
  libmumps-seq-dev \
  libopenblas-dev \
  libsuitesparse-dev

Finally, clone, build, and test Gosl:

git clone https://github.com/cpmech/gosl.git
cd gosl
./all.bash

./all.bash builds every package and runs its tests; it prints SUCCESS! when it is done.

Documentation

Gosl includes the following essential packages:

  • chk — checks on numerical results, and helpers for unit testing.
  • io — input/output, including printing to the terminal and handling files.
  • utl — series generation (e.g. linspace) and other functions as in pylab, MATLAB, and Octave.
  • la — linear algebra: vectors, matrices, efficient sparse solvers, eigenvalues, and decompositions.

Gosl includes the following main packages:

  • fun — special functions, DFT, FFT, Bessel functions, elliptic integrals, orthogonal polynomials, and interpolators.
  • gm — geometry algorithms and structures.
  • hb — the pseudo-hierarchical binary (hb) data file format.
  • num — fundamental numerical methods, such as root solvers, nonlinear solvers, numerical derivatives, and quadrature.
  • ode — solvers for ordinary differential equations.
  • opt — numerical optimization: interior point, conjugate gradients, Powell, and gradient descent.
  • pde — solvers for partial differential equations (FDM, spectral, FEM).
  • rnd — random numbers and probability distributions.

See each subdirectory for more information.

The previous mpi sub-package has been removed for maintenance reasons. If you need MPI, we recommend the external library gompi.

Status

Gosl is mature and in maintenance mode. It is stable and is used in published work, but new development has moved to Russell, its successor. Reports about existing functionality are welcome; new features are unlikely.

Directories

Path Synopsis
Package chk contains functions for checking and testing computations
Package chk contains functions for checking and testing computations
fun
Package fun (functions) implements special functions such as elliptical, orthogonal polynomials, Bessel, discrete Fourier transform, polynomial interpolators, and more.
Package fun (functions) implements special functions such as elliptical, orthogonal polynomials, Bessel, discrete Fourier transform, polynomial interpolators, and more.
fftw
Package fftw wraps the FFTW library to perform Fourier Transforms using the "fast" method by Cooley and Tukey
Package fftw wraps the FFTW library to perform Fourier Transforms using the "fast" method by Cooley and Tukey
gm
Package gm (geometry and meshes) implements auxiliary functions for handling geometry and mesh structures
Package gm (geometry and meshes) implements auxiliary functions for handling geometry and mesh structures
msh
Package msh defines mesh data structures and implements interpolation functions for finite element analyses (FEA)
Package msh defines mesh data structures and implements interpolation functions for finite element analyses (FEA)
tri
Package tri wraps Triangle to perform mesh generation a Delaunay triangulation
Package tri wraps Triangle to perform mesh generation a Delaunay triangulation
Package hb implements a pseudo hierarchical binary (hb) data file format
Package hb implements a pseudo hierarchical binary (hb) data file format
Package io (input/output) implements auxiliary functions for printing, parsing, handling files, directories, etc.
Package io (input/output) implements auxiliary functions for printing, parsing, handling files, directories, etc.
la
Package la implements functions and structure for Linear Algebra computations.
Package la implements functions and structure for Linear Algebra computations.
oblas
Package oblas implements lower-level linear algebra routines using OpenBLAS for maximum efficiency.
Package oblas implements lower-level linear algebra routines using OpenBLAS for maximum efficiency.
num
Package num implements fundamental numerical methods such as numerical derivative and quadrature, root finding solvers (Brent's and Newton's methods), among others.
Package num implements fundamental numerical methods such as numerical derivative and quadrature, root finding solvers (Brent's and Newton's methods), among others.
qpck
Package qpck wraps the QUADPACK library for numerical integration
Package qpck wraps the QUADPACK library for numerical integration
Package ode implements solvers for ordinary differential equations, including explicit and implicit Runge-Kutta methods; e.g.
Package ode implements solvers for ordinary differential equations, including explicit and implicit Runge-Kutta methods; e.g.
Package opt implements routines for solving optimization problems
Package opt implements routines for solving optimization problems
Package pde implements numerical methods for the solution of Partial Differential Equations.
Package pde implements numerical methods for the solution of Partial Differential Equations.
rnd
Package rnd implements random numbers generators (wrapping the standard functions or the Mersenne Twister library).
Package rnd implements random numbers generators (wrapping the standard functions or the Mersenne Twister library).
dsfmt
Package dsfmt wraps the dSFMT Double precision SIMD-oriented Fast Mersenne Twister
Package dsfmt wraps the dSFMT Double precision SIMD-oriented Fast Mersenne Twister
sfmt
Package sfmt wraps the SFMT SIMD-oriented Fast Mersenne Twister
Package sfmt wraps the SFMT SIMD-oriented Fast Mersenne Twister
Package utl implements functions for simplifying calculations and allocation of structures such as slices and slices of slices.
Package utl implements functions for simplifying calculations and allocation of structures such as slices and slices of slices.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL