compactors

package
v0.0.0-...-a42f8bd Latest Latest
Warning

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

Go to latest
Published: May 29, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrEmpty = errs.Kind("empty")

	ErrValueSet = errs.Entity("set of values")
)

Variables

View Source
var ErrEmptyValueSet = errs.WithDomain(errDomain, ErrEmpty, ErrValueSet)

Functions

func AbsMax

func AbsMax[T Number](values []T) (T, error)

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 Last

func Last[T any](values []T) (T, error)

Last returns the last item in a slice, as a default one-fits-all compactor.

func Max

func Max[T cmp.Ordered](values []T) (T, error)

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.

Types

type Number

type Number interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64 |
		~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 |
		~float32 | ~float64
}

Number is a type constraint that only accepts any type of integer or floating-point number.

Jump to

Keyboard shortcuts

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