Documentation ¶
Overview ¶
Package floats64 provide a library for working with slice of 64 bit float.
Index ¶
- func Count(d []float64, class float64) (count int)
- func Counts(d, classes []float64) (counts []int)
- func IndirectSort(d []float64, asc bool) (sortedIdx []int)
- func InplaceInsertionSort(d []float64, ids []int, l, r int, asc bool)
- func InplaceMergesort(d []float64, idx []int, l, r int, asc bool)
- func IsExist(d []float64, v float64) bool
- func Max(d []float64) (v float64, i int, ok bool)
- func MaxCountOf(d, classes []float64) (float64, bool)
- func MaxRange(d []float64, l, r int) (m int)
- func Min(d []float64) (v float64, i int, ok bool)
- func MinRange(d []float64, l, r int) (m int)
- func SortByIndex(d *[]float64, sortedIds []int)
- func Sum(d []float64) (sum float64)
- func Swap(d []float64, x, y int)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Counts ¶
Counts count class in data and return each of the counter.
For example, if data is "[1,1,2]" and class is "[1,2]", this function will return "[2,1]".
func IndirectSort ¶
IndirectSort sort the data and return the sorted index.
func InplaceInsertionSort ¶
InplaceInsertionSort will sort the data using insertion-sort algorithm.
Parameters: `data` is slice that will be sorted, `idx` is indices of data, `l` is starting index of slice to be sorted, and `r` is end index of slice to be sorted.
func InplaceMergesort ¶
InplaceMergesort in-place merge-sort without memory allocation.
func IsExist ¶
IsExist will return true if value `v` exist in slice of `d`, otherwise it will return false.
func Max ¶
Max find the maximum value in slice and and return its value and index.
If data is empty, it will return false in ok.
Example, given data: [0.0 0.1 0.2 0.2 0.4], it will return 0.4 as max and 4 as index of maximum value.
func MaxCountOf ¶
MaxCountOf will count number of occurrence of each element of classes in data and return the class with maximum count.
If `classes` is empty, it will return -1 and false. If `data` is empty, it will return -2 and false. If classes has the same count value, then the first max in the class will be returned.
For example, given a data [5, 6, 5, 6, 5] and classes [5, 6, 7], the function will count 5 as 3, 6 as 2, and 7 as 0. Since frequency of 5 is greater than 6 and 7, then it will return `5` and `true`.
func MaxRange ¶
MaxRange find the (last) maximum value in slice between index "l" and "r".
WARNING: This function does not check index out of range.
func Min ¶
Min find the minimum value in slice and and return it with their index.
If data is empty, return 0 in value and index, and false in ok.
Example, given data: [0.0 0.1 0.2 0.2 0.4], it will return 0 as min and 0 as index of minimum value.
func MinRange ¶
MinRange find the (last) minimum value in slice between index "l" and "r".
WARNING: This function does not check index out of range.
func SortByIndex ¶
SortByIndex sort the slice of float using sorted index.
Types ¶
This section is empty.