math

package
v0.0.0-...-5f938cf Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: GPL-3.0 Imports: 4 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Abs

func Abs[T Number](n T) T

func GCD

func GCD[T Integer](a, b T) T

func IsMonotonicWithinRange

func IsMonotonicWithinRange[S ~[]T, T Number](in S, minDiff, maxDiff T) bool

func LCM

func LCM[T Integer](a, b T) T

func Max

func Max[T Number](nums ...T) T

func MaxN

func MaxN[T Number](nums []T, n int) []T

func Min

func Min[T Number](nums ...T) T

func MinBranchless

func MinBranchless[T Number](nums ...T) T

func MinMax

func MinMax[T Number](nums ...T) (T, T)

func MinN

func MinN[T Number](nums []T, n int) []T

func MinTraditional

func MinTraditional[T Number](nums ...T) T

func Pow

func Pow[T Number](base T, exponent T) T

func Product

func Product[T Number](vector []T) T

func Sign

func Sign[T Signed](n T) T

func Sum

func Sum[T Number](vector []T) T

func ToF

func ToF[T Number](in T) float64

func Within

func Within[T Number](n, lowerBound, upperBound T) bool

Types

type Integer

type Integer interface {
	~int | ~int32 | ~int64 | ~uint
}

type Number

type Number interface {
	uint | Signed
}

type Point

type Point struct {
	X, Y int
}

func (Point) Add

func (p Point) Add(other Point) Point

func (Point) Equal

func (p Point) Equal(other Point) bool

func (Point) EuclideanDist

func (p Point) EuclideanDist(other Point) float64

func (Point) ManhattanDist

func (p Point) ManhattanDist(other Point) int

func (Point) Max

func (p Point) Max(other Point) Point

func (Point) Min

func (p Point) Min(other Point) Point

func (Point) String

func (p Point) String() string

func (Point) Sub

func (p Point) Sub(other Point) Point

type Signed

type Signed interface {
	int | float32 | float64
}

Jump to

Keyboard shortcuts

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