cmpr

package
v0.0.0-...-157c9c8 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 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

func MaxN

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

func Min

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

func MinN

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

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 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
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 were 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