Linear algebra, eigenvalues, FFT, Bessel, elliptic, orthogonal polys, geometry, NURBS, numerical quadrature, 3D transfinite interpolation, random numbers, Mersenne twister, probability distributions, optimisation, differential equations.

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.

Containerized (recommended)

  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 \
  libopenmpi-dev \
  liblapacke-dev \
  libopenblas-dev \
  libmetis-dev \
  libsuitesparse-dev \
  libmumps-dev \
  libfftw3-dev \
  libfftw3-mpi-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
  • mpi. Message Passing Interface for parallel computing
  • 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.

Owner
Dorival Pedroso
Comp Mech (cpmech), Optimization, Machine Learning, Artificial Intelligence, Evolutionary Algorithms, Finite Element Method
Dorival Pedroso
Comments
  • compiling la failed

    compiling la failed

    Hi, Was working through the steps as described in https://github.com/cpmech/gosl/blob/master/doc/InstallationOnMacOS.md and got literally stuck on the very last step. So, while trying to install the gosl package everything went well until gosl/la where I got this in my terminal:

    compiling la <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< signal: killed FAIL github.com/cpmech/gosl/la 0.005s

    I was not able to find a solution on the net, so I hope to work out a solution with you guys, since my Bachelor Thesis program using Go should run as efficient as possible.

    My macbook pro (early 2011) is running macOS Sierra (10.12.5) and has a Intel GPU, therefore no CUDA.

    terminal1

  • Iterative solver for sparse linear systems with supporting of initial guess.

    Iterative solver for sparse linear systems with supporting of initial guess.

    Hi @cpmech, is there any iterative solver for sparce linear systems with supporting of linitial guess?

    For example, something like scipy scipy.sparse.linalg.bicgstab method.

    P.S. If no, I am interested in contributing.

  • libblas error

    libblas error

    After following your directions, I get the following error: === compiling la/oblas ============================================================= /tmp/go-build948894470/b001/oblas.test: symbol lookup error: /usr/lib/libblas.so.3: undefined symbol: gotoblas exit status 127 FAIL github.com/cpmech/gosl/la/oblas 0.002s

    Any suggestions? Best, Dave

  • Is there a reason OSX isn't supported for mpi?

    Is there a reason OSX isn't supported for mpi?

    I just commented out all the build directives and removed mpi_notlinux.go and things appear to work on OSX 10.13.3 with openmpi 3.0.0 installed via homebrew.

    Is there a reason I shouldn't do this? I've only tested a trivial program so far.

  • hdf5.h error

    hdf5.h error

    === compiling io/h5 =============================================================

    github.com/cpmech/gosl/io/h5

    .\array.go:8:10: fatal error: hdf5.h: No such file or directory #include "hdf5.h" ^~~~~~~~ compilation terminated.

  • Allow building gosl on aarch64

    Allow building gosl on aarch64

    These patches auto-generate some code to allow their cgo flags to adapt to different architectures, including aarch64. This does not complete aarch64 support, since a few tests fail due to precision issues that I am currently fixing up, but the build itself (without the go test) completes successfully with these patches.

  • Example problem?

    Example problem?

    Great package! I was trying the examples and got the following error. Am I missing something?

    running vtk_isosurf01.go <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

    github.com/cpmech/gosl/vtk

    In file included from connectgovtk.cpp:10:0: clrmap.h:12:28: fatal error: vtkLookupTable.h: No such file or directory compilation terminated.

  • compiling la failed

    compiling la failed

    Hi, I am so sorry to bother you again. After formatting my SSD and freshly installed the macOS, I tried again to install gosl on my macbook pro (13" early 2011) which is running macOS Sierra (10.12.6), as described in https://github.com/cpmech/gosl/blob/master/doc/InstallationOnMacOS.md. I got an Fail during compiling la in the end when I executed ./all.bash (see attachment). Is the possibly a way to fix this issue?

    By the way, there is a typo in 2 HomeBrew and dependencies: brew install homebrew/science/suitesparse only worked with: brew install homebrew/science/suite-sparse

    (go version: go version go1.9 darwin/amd64)

    screen_shot1 screen_shot2

  • Munkres doesn't return the best value

    Munkres doesn't return the best value

    For the following matrix we have an issue with the munkres implementation:

    matrix := [][]int{
    	[]int{11757, 6957},
    	[]int{28985, 24171},
    	[]int{33857, 29057},
    }
    

    Expected result:

     []int{0, -1, 1}
    

    Actual result:

    []int{1, 0, -1}
    

    cc @christophe-dufour @Nyks06 @skateinmars

  • mpi code location

    mpi code location

    Hi gosl folks,

    A while back I extracted the MPI code because I needed to do some work with it. I noticed you're no longer bundling it. Perhaps you might put a link to my repo somewhere in your README in case folks are still looking for it?

    https://github.com/sbromberger/gompi is the repo. (Also, if you have any comments/suggestions on the code I'd be grateful!)

    Thanks.

  • Installation

    Installation

    Hi! I'm new to go and I'm new to gosl. Trying to install it on MacOS following the instructions. When testing, it fails on the h5-tests:

    compiling io/h5 ============================================================= github.com/cpmech/gosl/io/h5 Undefined symbols for architecture x86_64: ... ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

    How to fix that? I was ignoring this warning: Warning: hdf5 dependency gcc was built with a different C++ standard

    Kind regards

Sparse matrix formats for linear algebra supporting scientific and machine learning applications

Sparse matrix formats Implementations of selected sparse matrix formats for linear algebra supporting scientific and machine learning applications. Co

Jan 8, 2023
An ordinary differential equation solving library in golang.

ode An ordinary differential equation solving library in golang. Features Multi-dimensional state vector (i.e. extended states) Channel based stopping

Oct 19, 2022
Types and utilities for working with 2d geometry in Golang

orb Package orb defines a set of types for working with 2d geo and planar/projected geometric data in Golang. There are a set of sub-packages that use

Dec 28, 2022
Probability distributions and associated methods in Go

godist godist provides some Go implementations of useful continuous and discrete probability distributions, as well as some handy methods for working

Sep 27, 2022
Utilities for working with discrete probability distributions and other tools useful for doing NLP work

GNLP A few structures for doing NLP analysis / experiments. Basics counter.Counter A map-like data structure for representing discrete probability dis

Nov 28, 2022
tiny linear interpolation library for go (factored out from https://github.com/sgreben/yeetgif)

piecewiselinear A tiny library for linear interpolation. O(log(N)) per evaluation for N control points. import "github.com/sgreben/piecewiselinear" Ge

Sep 27, 2022
Random is a package written in Go that implements pseudo-random number generators for various distributions.

Random This package implements pseudo-random number generators for various distributions. For integers, there is a function for random selection from

Jul 11, 2022
Go implementation of BLAS (Basic Linear Algebra Subprograms)

Go implementation of BLAS (Basic Linear Algebra Subprograms) Any function is implemented in generic Go and if it is justified, it is optimized for AMD

Dec 11, 2022
Sparse matrix formats for linear algebra supporting scientific and machine learning applications

Sparse matrix formats Implementations of selected sparse matrix formats for linear algebra supporting scientific and machine learning applications. Co

Dec 12, 2022
Sparse matrix formats for linear algebra supporting scientific and machine learning applications

Sparse matrix formats Implementations of selected sparse matrix formats for linear algebra supporting scientific and machine learning applications. Co

Jan 8, 2023
Open-in-linear - A tool provides a shortcut to opening a linear issue in the desktop app or browser

This tool provides a shortcut to opening a linear issue in the desktop app or browser.

Jan 25, 2022
Evolutionary optimization library for Go (genetic algorithm, partical swarm optimization, differential evolution)
Evolutionary optimization library for Go (genetic algorithm, partical swarm optimization, differential evolution)

eaopt is an evolutionary optimization library Table of Contents Changelog Example Background Features Usage General advice Genetic algorithms Overview

Dec 30, 2022
An ordinary differential equation solving library in golang.

ode An ordinary differential equation solving library in golang. Features Multi-dimensional state vector (i.e. extended states) Channel based stopping

Oct 19, 2022
Encriptator using random generated numbers

public-private-key-encrypter Encriptator using random generated numbers The input file must be in one file called 'data.txt' The execution will genera

Oct 15, 2021
Filling a matrix with unique, random, int numbers

randmatrix The task is to fill a matrix (m × n) with random, int, unique numbers from a certain range (for example for the range 1-3 possible numbers

Dec 4, 2021
GoApiRandom - Api to get random numbers

GoApiRandom - Api to get random numbers

Jan 18, 2022
Image resizing for the Go programming language with common interpolation methods

This package is no longer being updated! Please look for alternatives if that bothers you. Resize Image resizing for the Go programming language with

Dec 14, 2021
Fast, realtime regex-extraction, and aggregation into common formats such as histograms, numerical summaries, tables, and more!
Fast, realtime regex-extraction, and aggregation into common formats such as histograms, numerical summaries, tables, and more!

rare A file scanner/regex extractor and realtime summarizor. Supports various CLI-based graphing and metric formats (histogram, table, etc). Features

Dec 29, 2022
Package shapes provides an algebra for handling shapes

About Package shapes provides the algebra and machinery for dealing with the metainformation of shapes of a tensor. Why a shape package? The shape pac

Jan 14, 2022
Go-integrals - A numerical integration library in GoLang

Go Integrals About Go Integrals is an implementation of numerical integration al

Jan 19, 2022