dsp

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MaxIndex

func MaxIndex(a []FLOAT) int

MaxIndex returns the index of the maximum value in a. If a is empty, -1 is returned.

func MinIndex

func MinIndex(a []FLOAT) int

MinIndex returns the index of the minimum value in a. If a is empty, -1 is returned.

func MinMax

func MinMax(a []FLOAT) (minIndex int, minValue FLOAT, maxIndex int, maxValue FLOAT)

MinMax returns the indices and values of the minimum and maximum values in a. If a is empty, the indices are -1, the minimum is +INF and the maximum is is -INF.

Types

type FLOAT

type FLOAT = float32

func Abs

func Abs(x []FLOAT) []FLOAT

Abs returns a new array, the same length as x, with all values the absolute values of x, i.e. the value itself if it is >= 0 and the negative value if it is < 0.

func AbsValue

func AbsValue(x FLOAT) FLOAT

Abs returns the absolute value of x, i.e. the value itself if it is >= 0 and the negative value if it is < 0.

func Add

func Add(a ...[]FLOAT) []FLOAT

Add returns an array of the sums of the elements in all arrays of a. If the arrays in a have different lengths, the smallest of all lengths is used for the result.

func AddOffset

func AddOffset(a []FLOAT, offset FLOAT) []FLOAT

AddOffset returns a new array with all values offset greater than in a.

func Average

func Average(a []FLOAT) FLOAT

Average returns the average vaue over a or 0 if a is empty.

func AverageFilter

func AverageFilter(a []FLOAT, width int) []FLOAT

AverageFilter returns a new array of average filtered values over a. The resulting array is width-1 smaller than a. Neighboring elements (width neighbors) are averaged. If the width is 1 or smaller, a copy of the input array is returned. If width is greater than len(a), a one-element array with the average value over a is returned. For an empty input an empty output is returned.

func Copy

func Copy(a []FLOAT) []FLOAT

Copy returns a copy of the given slice.

func Derivative

func Derivative(a []FLOAT) []FLOAT

Derivative returns a slice one item smaller than a, with the differences between neighboring items. Result 0 is a[1]-a[0] and so on.

func EveryNth

func EveryNth(a []FLOAT, n int) []FLOAT

EveryNth constructs a new array from every nth item in a. The first item is always used. If n is <= 0, an empty array is returned.

func MaxValue

func MaxValue(a []FLOAT) FLOAT

MaxValue returns the minimum value in a. If a is empty, -INF is returned.

func MedianFilter

func MedianFilter(a []FLOAT, width int) []FLOAT

MedianFilter returns a new array of median filtered values over a. The resulting array is width-1 smaller than a. Neighboring elements (width neighbors) are sorted and the middle element replaces the origial. If the width is 1 or smaller, a copy of the input array is returned. If width is greater than len(a), a one-element array with the median value over a is returned. For an empty input an empty output is returned.

func MinValue

func MinValue(a []FLOAT) FLOAT

MinValue returns the minimum value in a. If a is empty, +INF is returned.

func Negative

func Negative(a []FLOAT) []FLOAT

Negative returns a slice of the length of a with all elements the negations of those in a.

func NthDerivative

func NthDerivative(a []FLOAT, n int) []FLOAT

NthDerivative applies Derivative n times to a. If n is <= 0, a copy of a is returned.

func Range

func Range(a, b int) []FLOAT

Range returns an array containing all integer numbers in the range from a to b, both inclusive. The order of the number is the same as the order from a to b.

Examples:

Range(5, 8)  =>  {5.0, 6.0, 7.0, 8.0}
Range(2, -3) =>  {2.0, 1.0, 0.0, -1.0, -2.0, -3.0}

func Repeat

func Repeat(x FLOAT, n int) []FLOAT

Repeat makes a slice of FLOAT of length n and sets all values to x. If n <= 0 the returned slice is empty.

func Reverse

func Reverse(x []FLOAT) []FLOAT

Reverse returns a copy of x with elements in reverse order, e.g. 1,2,3 -> 3,2,1.

func Scale

func Scale(a []FLOAT, factor FLOAT) []FLOAT

Scale returns a new array with all values in a scaled by factor.

func Sub

func Sub(a ...[]FLOAT) []FLOAT

Sub uses the first array in a as the base and subtracts all other arrays from it. If the arrays in a have different lengths, the smallest of all lengths is used for the result.

Directories

Path Synopsis
dsp32
dsp
dsp64
dsp

Jump to

Keyboard shortcuts

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