Documentation ¶
Index ¶
- Constants
- Variables
- func AbsMax[T Number](values []T) (T, error)
- func Last[T any](values []T) (T, error)
- func Max[T cmp.Ordered](values []T) (T, error)
- func MaxSpectra(data [][]fft.FrequencyPower) ([]fft.FrequencyPower, error)
- func UpperSpectra(data [][]fft.FrequencyPower) ([]fft.FrequencyPower, error)
- type Number
Constants ¶
const ( ErrEmpty = errs.Kind("empty") ErrValueSet = errs.Entity("set of values") )
Variables ¶
var ErrEmptyValueSet = errs.WithDomain(errDomain, ErrEmpty, ErrValueSet)
Functions ¶
func AbsMax ¶
AbsMax finds the absolute maximum Number value in the input slice.
Using and absolute-approach, the function will return the biggest value in the slice, regardless if it is positive or negative. For example, calling AbsMax on the following slice would return the negative value of -1.9: []float64{0.1, 0.9, -0.3, -1.9}.
AbsMax may be slower than Max, and also it will not be compatible with its support for uintptr and string types.
func Max ¶
Max finds the biggest (ordered) value in a slice of a given type, with a bigger-than approach, meaning that it will work for positive integer and float values.
To include negative values, an AbsMax approach would be required.
func MaxSpectra ¶
func MaxSpectra(data [][]fft.FrequencyPower) ([]fft.FrequencyPower, error)
MaxSpectra reduces a matrix of frequencies (several registries of sets of frequencies), into a single (ordered) set.
Its strategy involves sorting each set in the matrix to present the strongest magnitude frequencies as the first element, and collects these into a new slice (of the same capacity as the matrix).
Finally, it sorts the final slice once again, putting the strongest magnitude frequencies at the beginning of the slice, so consumers can consume it up straight away.
func UpperSpectra ¶
func UpperSpectra(data [][]fft.FrequencyPower) ([]fft.FrequencyPower, error)
UpperSpectra is like MaxSpectra, but keeps the spectrum slice intact in terms of its frequency distribution.
Unlike MaxSpectra, this function will return a full spectrum of the same size as the input spectra, but only containing the most powerful values registered for a given frequency.