Documentation
¶
Index ¶
- func Add(dst []int, slices ...[]int) []int
- func AddConst(c int, s []int)
- func AddScaled(dst []int, alpha int, s []int)
- func AddScaledTo(dst []int, y []int, alpha int, s []int) []int
- func Apply(f func(int) int, s []int)
- func Argsort(s []int, inds []int)
- func Count(f func(int) bool, s []int) int
- func CumProd(dst, s []int) []int
- func CumSum(dst, s []int) []int
- func Div(s []int, t []int)
- func DivTo(dst []int, s []int, t []int) []int
- func Dot(s1, s2 []int) int
- func Equal(s1, s2 []int) bool
- func EqualFunc(s1, s2 []int, f func(int, int) bool) bool
- func EqualLengths(slices ...[]int) bool
- func Fill(f func() int, s []int)
- func Find(inds []int, f func(int) bool, s []int, k int) ([]int, error)
- func Max(s []int) (max int, ind int)
- func Min(s []int) (min int, ind int)
- func Mul(s []int, t []int)
- func MulTo(dst []int, s []int, t []int) []int
- func Prod(s []int) (prod int)
- func Scale(c int, s []int)
- func Span(dst []int, l, u int) []int
- func Sub(s, t []int)
- func SubTo(dst, s, t []int) []int
- func Sum(s []int) (sum int)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Add ¶
Add returns the element-wise sum of all the slices with the results stored in the first slice. For computational efficiency, it is assumed that all of the variadic arguments have the same length. If this is in doubt, EqLen can be used.
func AddScaled ¶
AddScaled performs dst = dst + alpha * s. It panics if the lengths of dst and s are not equal.
func AddScaledTo ¶
AddScaledTo performs dst = y + alpha * s. It panics if the lengths of dst, y, and s are not equal.
func Apply ¶
ApplyFunc applies a function f (math.Exp, math.Sin, etc.) to every element of the slice s.
func Argsort ¶
Argsort sorts the elements of s while tracking their original order. At the conclusion of Argsort, s will contain the original elements of s but sorted in increasing order, and inds will contain the original position of the elements in the slice such that s[i] = sOrig[inds[i]].
func Count ¶
Count applies the function f to every element of s and returns the number of times the function returned true.
func CumProd ¶
Cumprod finds the cumulative product of the first i elements in s and puts them in place into the ith element of the destination. A panic will occur if lengths of do not match.
func CumSum ¶
Cumsum finds the cumulative sum of the first i elements in s and puts them in place into the ith element of the destination. A panic will occur if lengths of arguments do not match.
func Div ¶
Div performs element-wise division between s and t and stores the value in s. It panics if the lengths of s and t are not equal.
func DivTo ¶
DivTo performs element-wise division between s and t and stores the value in dst. It panics if the lengths of s, t, and dst are not equal.
func Dot ¶
Dot computes the dot product of s1 and s2, i.e. sum_{i = 1}^N s1[i]*s2[i]. A panic will occur if lengths of arguments do not match.
func Equal ¶
Equal returns true if the slices have equal lengths and all elements are numerically identical.
func EqualFunc ¶
EqualsFunc returns true if the slices have the same lengths and the function returns true for all element pairs.
func EqualLengths ¶
Eqlen returns true if all of the slices have equal length, and false otherwise. Returns true if there are no input slices.
func Fill ¶
Fill loops over the elements of s and stores a value generated from f. f is called n times, where n = len(s)
func Find ¶
Find applies f to every element of s and returns the indices of the first k elements for which the f returns true, or all such elements if k < 0. Find will reslice inds to have 0 length, and will append found indices to inds. If k > 0 and there are fewer than k elements in s satisfying f, all of the found elements will be returned along with an error.
func Max ¶
Max returns the maximum value in the slice and the location of the maximum value. If the input slice is empty, Max will panic.
func Min ¶
Min returns the minimum value in the slice and the index of the minimum value. If the input slice is empty, Min will panic.
func Mul ¶
Mul performs element-wise multiplication between s and t and stores the value in s. Panics if the lengths of s and t are not equal.
func MulTo ¶
MulTo performs element-wise multiplication between s and t and stores the value in dst. Panics if the lengths of s, t, and dst are not equal.
func Span ¶
Span returns a set of N equally spaced points between l and u, where N is equal to the length of the destination. The first element of the destination is l, the final element of the destination is u. Panics if len(dst) < 2.
func Sub ¶
func Sub(s, t []int)
Sub subtracts, element-wise, the first argument from the second. Assumes the lengths of s and t match (can be tested with EqLen).
Types ¶
This section is empty.