floats64

package
v0.17.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 5, 2020 License: BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Overview

Package floats64 provide a library for working with slice of 64 bit float.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Count

func Count(d []float64, class float64) (count int)

Count number of class in data.

func Counts

func Counts(d, classes []float64) (counts []int)

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

func IndirectSort(d []float64, asc bool) (sortedIdx []int)

IndirectSort sort the data and return the sorted index.

func InplaceInsertionSort

func InplaceInsertionSort(d []float64, ids []int, l, r int, asc bool)

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

func InplaceMergesort(d []float64, idx []int, l, r int, asc bool)

InplaceMergesort in-place merge-sort without memory allocation.

func IsExist

func IsExist(d []float64, v float64) bool

IsExist will return true if value `v` exist in slice of `d`, otherwise it will return false.

func Max

func Max(d []float64) (v float64, i int, ok bool)

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

func MaxCountOf(d, classes []float64) (float64, bool)

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

func MaxRange(d []float64, l, r int) (m int)

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

func Min(d []float64) (v float64, i int, ok bool)

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

func MinRange(d []float64, l, r int) (m int)

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

func SortByIndex(d *[]float64, sortedIds []int)

SortByIndex sort the slice of float using sorted index.

func Sum

func Sum(d []float64) (sum float64)

Sum value of slice.

func Swap

func Swap(d []float64, x, y int)

Swap swap two indices value of 64bit float.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL