cmpr

package
v0.0.0-...-ef20d55 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2025 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Equal

func Equal(a, b float64) bool

Equal returns true if a and b are within the DefaultTolerance of eachother.

func Max

func Max[T constraints.Ordered](a, b T) T

Max returns the greater value of a or b.

func MaxN

func MaxN[T constraints.Ordered](ts ...T) T

MaxN returns the least value in ts.

func Min

func Min[T constraints.Ordered](a, b T) T

Min returns the lesser value of a or b.

func MinN

func MinN[T constraints.Ordered](ts ...T) T

MinN returns the least value in ts.

func Zero

func Zero(x float64) bool

Zero returns true if x is within the DefaultTolerance of 0.

Types

type AssertEqualizer

type AssertEqualizer interface {
	AssertEqual(to interface{}, t Tolerance) error
}

AssertEqualizer allows a type to define an equality test.

Note that when fulfilling an interface Go will coerce a pointer type to it's base type, but not the other way. So if AssertEqual is on the base type and a pointer to that type is passed into geomtest.Equal it will be cast to the base type.

type Tolerance

type Tolerance float64

Tolerance represents a difference below which two floats can be considered equal.

var DefaultTolerance Tolerance = 1e-5

DefaultTolerance adjusts how close values must be to be considered equal

func (Tolerance) Equal

func (t Tolerance) Equal(a, b float64) bool

Equal returns true if a and b are within Tolerance t of eachother.

func (Tolerance) Unique

func (t Tolerance) Unique(s []float64) []float64

Unique takes a sorted list and returns all the unique values where two values within Tolerance of eachother are considered equal.

func (Tolerance) Zero

func (t Tolerance) Zero(x float64) bool

Zero returns true if x is within Tolerance t of value of 0.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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