Socket
Socket
Sign inDemoInstall

github.com/gorgonia/vecf64

Package Overview
Dependencies
3
Alerts
File Explorer

Install Socket

Detect and block malicious and high-risk dependencies

Install

    github.com/gorgonia/vecf64

Package vecf64 provides common functions and methods for slices of float64. In the days of yore, scientists who computed with computers would use arrays to represent vectors, each value representing magnitude and/or direction. Then came the C++ Standard Templates Library, which sought to provide this data type in the standard library. Now, everyone conflates a term "vector" with dynamic arrays. In the C++ book, Bjarne Stroustrup has this to say: Go has a better name for representing dynamically allocated arrays of any type - "slice". However, "slice" is both a noun and verb and many libraries that I use already use "slice"-as-a-verb as a name, so I had to settle for the second best name: "vector". It should be noted that while the names used in this package were definitely mathematically inspired, they bear only little resemblance the actual mathematical operations performed. The names of the operations assume you're working with slices of float64s. Hence `Add` performs elementwise addition between two []float64. Operations between []float64 and float64 are also supported, however they are differently named. Here are the equivalents: You may note that for the []float64 - float64 binary operations, the scalar (float64) is always the first operand. In operations that are not commutative, an additional function is provided, suffixed with "R" (for reverse) This package does not provide range checking. If indices are out of range, the functions will panic. This package should play well with BCE. TODO: provide SIMD vectorization for Incr and []float32-float64 functions. Pull requests accepted


Version published

Readme

Source

vecf64 GoDoc Build Status Coverage Status

Package vecf64 provides common functions and methods for slices of float64

Installation

go get -u gorgonia.org/vecf64

This package uses the standard library only. For testing this package uses testify/assert, which is licenced with a MIT/BSD-like licence

Build Tags

The point of this package is to provide operations that are accelerated by SIMD. However, this pakcage by default does not use SIMD. To use SIMD, build tags must be used. The supported build tags are sse and avx. Here's an example on how to use them:

  • SSE - `go build -tags='sse' ...
  • AVX - `go build -tags='avx' ...

Why are there so many a = a[:len(a)] lines?

This is mainly done to eliminate bounds checking in a loop. The idea is the bounds of the slice is checked early on, and if need be, panics early. Then if everything is normal, there won't be bounds checking while in the loop.

To check for boundschecking and bounds check elimination (an amazing feature that landed in Go 1.7), compile your programs with -gcflags='-d=ssa/check_bce/debug=1'.

Contributing

Contributions are welcome. The typical process works like this:

  1. File an issue on the topic you want to contribute
  2. Fork this repo
  3. Add your contribution
  4. Make a pull request
  5. The pull request will be merged once tests pass, and code reviewed.
  6. Add your name (if it hasn't already been added to CONTRIBUTORS.md)

Pull Requests

This package is very well tested. Please ensure tests are written if any new features are added. If bugs are fixed, please add the bugs to the tests as well.

Licence

Package vecf64 is licenced under the MIT licence.

FAQs

Last updated on 04 Sep 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc