Documentation
¶
Overview ¶
Package num provides tools for floats arithmetic.
Overview ¶
The aim of this package is to provide Antha users with a library containing basic float vectors operations.
The package supplements the gonum package and provides a simpler interface for some of its parts. While gonum focuses on efficiency and tends to avoid allocations inside its functions, the num package allows to do multiple element-wise operations more concisely (though at the cost of some additional allocations).
Example:
x := []float64{1, 2, 3} linear_transformed_x := num.Add(num.Mul(a, x), b)
Also num is aimed at implementing at least some basic numpy functionality currently missing in gonum.
Index ¶
- Constants
- func Add(a, b []float64) []float64
- func AddConst(a []float64, b float64) []float64
- func Arange(start int, stop int) []float64
- func Convolve(a, v []float64, mode ConvolutionMode) []float64
- func Div(a, b []float64) []float64
- func DivByConst(a []float64, b float64) []float64
- func DivConst(a float64, b []float64) []float64
- func Linspace(start, end float64, num int) []float64
- func LstSq(a, b *mat.Dense) *mat.Dense
- func Mul(a, b []float64) []float64
- func MulByConst(a []float64, b float64) []float64
- func Ones(size int) []float64
- func SavGolFilter(x []float64, window_length int, polyorder int, deriv int, delta float64) []float64
- func Sub(a, b []float64) []float64
- func SubConst(a []float64, b float64) []float64
- func SubFromConst(a float64, b []float64) []float64
- func Zeroes(size int) []float64
- type ConvolutionMode
Constants ¶
const ( // Full - returns the convolution at each point of overlap, i.e. of length N+M-1. Full = iota // Same - returns the output of length max(M, N). Same // Valid - returns the output of length max(M, N) - min(M, N) + 1. Valid )
Variables ¶
This section is empty.
Functions ¶
func Arange ¶
Arange implements `np.arange` - i.e. returns a list of integers (start, ..., stop - 1) in the form of []float64
func Convolve ¶
func Convolve(a, v []float64, mode ConvolutionMode) []float64
Convolve is a (very naive) implementation of precise discrete convolution. The results are numerically equivalent to `np.convolve(a, v, mode)` - it looks like that `np.convolve` uses precise convolution as well (but not an FFT approximation). TODO: optimize the implementation - the current one has O((M+N)^2) time complexity. Looks like it's possible to achieve at least O(MN).
func DivByConst ¶
DivByConst divides a vector by a scalar.
func Linspace ¶
Linspace implements `np.linspace` - i.e. splits the interval [start, end] into `num - 1` equal intervals and returns `num` split points.
func LstSq ¶
LstSq computes least-squares solution to equation A*x = b, i.e. computes a vector x such that the 2-norm “|b - A x|“ is minimized. Based on: https://github.com/scipy/scipy/blob/v1.3.0rc1/scipy/linalg/basic.py#L1042
func MulByConst ¶
MulByConst multiplies a vector by a scalar.
func SavGolFilter ¶
func SavGolFilter(x []float64, window_length int, polyorder int, deriv int, delta float64) []float64
SavGolFilter implements Savitzky-Golay filter (https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.savgol_filter.html) based on: https://github.com/scipy/scipy/blob/v1.3.0rc1/scipy/signal/_savitzky_golay.py#L227
func SubFromConst ¶
SubFromConst subtracts a vector from a scalar.
Types ¶
type ConvolutionMode ¶
type ConvolutionMode int
ConvolutionMode defines convolution output array length.