MCPcopy
hub / github.com/cpmech/gosl

github.com/cpmech/gosl @v1.2.12 sqlite

repository ↗ · DeepWiki ↗ · release v1.2.12 ↗
2,249 symbols 12,801 edges 356 files 1,450 documented · 64%
README

Gosl - Go scientific library

Go Reference Go Report Card codecov Awesome

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 the other 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, it works on Windows, Linux, and macOS out of the box.

Containerized

  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."

Debian/Ubuntu GNU Linux

First, install Go as explained in https://golang.org/doc/install

Second, install some libraries:

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

Finally, download and compile Gosl:

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

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)

For the sake of maintenance (see next section), we have removed the previous mpi sub-package. However, we recommend the external library gompi if you plan to use MPI.

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.

Extension points exported contracts — how you extend this code

Distribution (Interface)
Distribution defines a probability distribution [5 implementers]
rnd/distribution.go
SparseSolver (Interface)
real //////////////////////////////////////////////////////////////////////////////////////////// SparseSolver solves sp [4 …
la/sparse_solver.go
QuadElementary (Interface)
The algorithms below are based on [1] REFERENCES: [1] Press WH, Teukolsky SA, Vetterling WT, Fnannery BP (2007) Numerica [2 …
num/quadElementary.go
Observer (Interface)
Observer is an interface to objects that need to observe something [1 implementers]
utl/observer.go
OutFcnType (FuncType)
OutFcnType is a function that sets the "u" array with an output @ time "t"
utl/postprocess.go
Ss (FuncType)
Ss defines a scalar function f(s) of a scalar argument s (scalar scalar) Input: s -- input scalar Returns: scalar
fun/definitions.go
Entity (Interface)
Octree ///////////////////////////////////////////////////////////////////////////////////////// Entity defines the geom
gm/octree.go
ShapeFunction (FuncType)
ShapeFunction computes the shape function and derivatives
gm/msh/shapes.go

Core symbols most depended-on inside this repo

Array
called by 618
chk/testing.go
PrintTitle
called by 560
chk/print.go
Pf
called by 550
io/basic.go
Float64
called by 490
chk/testing.go
Ints
called by 417
chk/testing.go
Panic
called by 409
chk/chk.go
NewVector
called by 397
la/vector.go
Set
called by 357
utl/params.go

Shape

Function 1,423
Method 655
Struct 119
FuncType 28
TypeAlias 13
Interface 11

Languages

Go99%
Python1%

Modules by API surface

la/matrix.go50 symbols
utl/mylab.go47 symbols
gm/grid.go42 symbols
fun/genorthopoly.go42 symbols
utl/sorting.go41 symbols
io/basic.go39 symbols
la/oblas/t_oblas_test.go34 symbols
fun/functions.go34 symbols
gm/nurbs.go32 symbols
la/sparse_matrix.go30 symbols
la/vector.go28 symbols
la/oblas/oblas.go28 symbols

For agents

$ claude mcp add gosl \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact