gosl

module
v1.2.9 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2021 License: BSD-3-Clause

README

Gosl - Go scientific library

Gosl is a set of tools for developing scientific simulations using the Go language. We mainly consider the development of numerical methods and solvers for differential equations but also present some functions for fast Fourier transforms, the generation of random numbers, probability distributions, and computational geometry.

This library contains essential functions for linear algebra computations (operations between all combinations of vectors and matrices, eigenvalues and eigenvectors, linear solvers) and the development of numerical methods (e.g. numerical quadrature).

We link Gosl with existent libraries written in C and Fortran, such as OpenBLAS, LAPACK, UMFPACK, MUMPS, QUADPACK and FFTW3. These existing libraries have been fundamental for the development of high-performant simulations over many years. We believe that it is nearly impossible to rewrite these libraries in native Go and at the same time achieve the same speed delivered by them. Just for reference, a naive implementation of matrix-matrix multiplication in Go is more than 100 times slower than OpenBLAS.

Installation

Because of other (awesome) libraries, the easiest way to work with Gosl is via Docker. Having Docker and VS Code installed, you can start developing powerful numerical simulations using Gosl in a matter of minutes. Furthermore, the best part of it is that it works on Windows, Linux, and macOS out of the box.

  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 within a container (see gif below)

Done. And your system will "remain clean."

Our Docker Image also contains Go and the Go Tools for working with VS Code (or not). Below is a video showing the convenience of VS Code + the Go tools + Gosl. Note how fast VS Code is in finding the function ReadLines and the package gosl/io even under a clash with Go's io package. Upon file save, the Go tools automatically add the required imports. Note also the very convenient auto-completion of the callback function given to ReadLines. Also, Code + the Go tools nicely fill the function arguments with default values.

Another great thing about VS Code is it's IntelliSense. Here, as soon as we start typing "m comma n two-dot equal T dot", VS Code immediately offers Size() as the first option because it matches the preceding code. Fantastic!

Debian/Ubuntu GNU Linux

First we have to first install some extra libraries before calling go get.

Install dependencies

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

Download Gosl

go get github.com/cpmech/gosl

Done. Installation completed.

Documentation

Gosl includes the following essential packages:

  • chk. To check numerical results and for unit testing
  • io. Input/output including printing to the terminal and handling files
  • utl. To generate series (e.g. linspace) and other functions as in pylab/matlab/octave
  • la. Linear Algebra: vector, matrix, efficient sparse solvers, eigenvalues, decompositions

Gosl includes the following main packages:

  • fun. Special functions, DFT, FFT, Bessel, elliptical integrals, orthogonal polynomials, interpolators
  • gm. Geometry algorithms and structures
  • hb. Pseudo hierarchical binary (hb) data file format
  • num. Fundamental numerical methods such as root solvers, non-linear solvers, numerical derivatives and quadrature
  • ode. Solvers for ordinary differential equations
  • opt. Numerical optimization: Interior Point, Conjugate Gradients, Powell, Grad Descent
  • pde. Solvers for partial differential equations (FDM, Spectral, FEM)
  • rnd. Random numbers and probability distributions

(see each subdirectory for more information)

Examples

Please check out https://github.com/cpmech/gosl-examples

Benchmarks

Please check out https://github.com/cpmech/gosl-benchmarks

Previous version

The previous version, including more packages, is available here and can be used with the Docker image 1.1.3 as in this hello gosl example.

These other packages, such as machine learning, plotting, etc., have been removed because they do not depend on CGO and may be developed independently. We can now maintain the core of Gosl more efficiently, which has a focus on the foundation for other scientific code.

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 optimisation problems
Package opt implements routines for solving optimisation 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