12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- package stats
- import (
- "sort"
- "time"
- )
- // float64ToInt rounds a float64 to an int
- func float64ToInt(input float64) (output int) {
- r, _ := Round(input, 0)
- return int(r)
- }
- // unixnano returns nanoseconds from UTC epoch
- func unixnano() int64 {
- return time.Now().UTC().UnixNano()
- }
- // copyslice copies a slice of float64s
- func copyslice(input Float64Data) Float64Data {
- s := make(Float64Data, input.Len())
- copy(s, input)
- return s
- }
- // sortedCopy returns a sorted copy of float64s
- func sortedCopy(input Float64Data) (copy Float64Data) {
- copy = copyslice(input)
- sort.Float64s(copy)
- return
- }
- // sortedCopyDif returns a sorted copy of float64s
- // only if the original data isn't sorted.
- // Only use this if returned slice won't be manipulated!
- func sortedCopyDif(input Float64Data) (copy Float64Data) {
- if sort.Float64sAreSorted(input) {
- return input
- }
- copy = copyslice(input)
- sort.Float64s(copy)
- return
- }
|