mathx

package
v1.7.5 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2025 License: MIT Imports: 4 Imported by: 96

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AtLeast added in v1.6.3

func AtLeast[T Numerical](x, lower T) T

AtLeast returns the greater of x or lower.

func AtMost added in v1.6.3

func AtMost[T Numerical](x, upper T) T

AtMost returns the smaller of x or upper.

func Between added in v1.6.3

func Between[T Numerical](x, lower, upper T) T

Between returns the value of x clamped to the range [lower, upper].

func CalcEntropy

func CalcEntropy(m map[any]int) float64

CalcEntropy calculates the entropy of m.

func MaxInt

func MaxInt(a, b int) int

MaxInt returns the larger one of a and b.

func MinInt

func MinInt(a, b int) int

MinInt returns the smaller one of a and b.

Types

type Numerical added in v1.6.5

type Numerical interface {
	~int | ~int8 | ~int16 | ~int32 | ~