97

Write scientific code with Gonum's numeric libraries for Go - JAXenter

 6 years ago
source link: https://jaxenter.com/gonum-numeric-libraries-go-137530.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Write scientific code with Gonum’s numeric libraries for Go

September 25, 2017Jane Elizabeth
#go

Contrary to popular belief, this isn’t a new language built off of Go. Instead, Gonum is a set of numeric libraries to be used on top of Go, making it easier to write clearer scientific code and algorithms.

Gonum is a set of packages designed to make writing numeric and scientific algorithms productive, performant, and scalable. Let’s be real clear here: this is NOT a new language. It’s still written in Go. You don’t need to learn another language.

Gonum is aimed at making life easier for the scientific world. It’s full of libraries for matrices and linear algebra. Also included: tools for statistics, probability distributions, and sampling. There are even tools for function differentiation, integration, and optimization as well as network creation and analysis. And more.

Gonum isn’t for the faint of heart: it’s intended for scientific clarity. So, you’re not likely to have any stupid sexy one-line pieces of code in Gonum.

SEE MORE: On the road to Go 2: Goals, constraints and roadmap

Main differences between Gonum and other popular scientific libraries

Gonum was designed to be simple, efficient, and composable. While we all aim for simplicity, sometimes this isn’t super great in scientific computing. Ease and clarity are often more important than an elegant one-liner. Gonum bridges that hap with reliable and predictable code that’s still easy to use.

One of the main differences between Gonum and other popular scientific libraries is that Go doesn’t allow operator or method overloading. This is why the same algorithm often needs a few more lines of code in Go. But hopefully, the extra clarity from the extra typing will be worth the effort.

Philosophically, the Gonum team is all for this extra work.

Science is built on understanding how an experiment was performed and what the results are. We believe scientific code should be no different.

Another distinguishing factor for Gonum is that you only need one programming language: Go. Most other libraries require a certain level of polyglotism. Gonum’s structure encourages users to implement algorithms in a uniform style, making the code easy to read and consistent across users.

SEE MORE: Go 1.9 is here

Thanks to a foundation based on Go, Gonum is fast, and great for parallel computing. Go is designed for big picture programming, making it easy to build an ecosystem of libraries working concurrently and building on top of one another. Go has extremely legible compile errors, full stack traces, trivial package downloading, automatic makefiles and import resolution, code formatting tools, easy code documentation, a race detector, and more.

Get up and Go

As the team behind Gonum puts it, you should use it if:

  • You are tired of sluggish performance, and fighting C and vectorization.
  • You are struggling with managing programs as they grow larger.
  • You struggle to re-use – even the code you tried to make reusable.
  • You would like easy access to parallel computing.
  • You want code to be fully transparent, and want the ability to read the source code you use.
  • You’d like a compiler to catch mistakes early, but hate fighting linker and unintelligible compile errors.

Interested? Head on over to the Go tour for a great intro to the Go programming language. The Go playground is a fun sandbox to get used to the language as well, but it sadly doesn’t support Gonum.

If you want to start with Gonum, the document packages are all available on GitHub here.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK