Documentation ¶
Index ¶
- func AlikeC128(a, b complex128) bool
- func AlikeF32(a, b float32) bool
- func AlikeF64(a, b float64) bool
- func AllClose(a, b interface{}, approxFn ...interface{}) bool
- func CloseC128(a, b complex128) bool
- func CloseEnoughF64(a, b float64) bool
- func CloseF32(a, b float32) bool
- func CloseF64(a, b float64) bool
- func ToleranceC128(a, b complex128, e float64) bool
- func ToleranceF32(a, b, e float32) bool
- func ToleranceF64(a, b, e float64) bool
- func VeryCloseC128(a, b complex128) bool
- func VeryCloseF32(a, b float32) bool
- func VeryCloseF64(a, b float64) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AlikeC128 ¶
func AlikeC128(a, b complex128) bool
AlikeC128 checks that a and b are alike:
- NaNs are considered to be equal
- Both have the same sign bits for both the real and imaginary components
func AlikeF32 ¶
AlikeF32 checks that a and b are alike:
- NaNs are considered to be equal
- Both have the same sign bits
func AlikeF64 ¶
AlikeF64 checks that a and b are alike:
- NaNs are considered to be equal
- Both have the same sign bits
func AllClose ¶
func AllClose(a, b interface{}, approxFn ...interface{}) bool
AllClose checks slices a and b are close together. An optional approximation function is accepted. If nothing is passed in, the CloseF64, CloseF32, CloseC128 functions will be used
This is not an exhasutive function. It only recognizes these types:
[]float64 []float32 []complex64 []complex128
This function will panic if other types are passed in, or if a and b do not have matching types.
func CloseC128 ¶
func CloseC128(a, b complex128) bool
CloseC128 checks that a and b are within 1e-14 tolerance
func CloseEnoughF64 ¶
CloseEnoughF64 checks that a and b are within 1e-8 tolerance.
func CloseF32 ¶
CloseF32 checks that a and b are within 1e-5 tolerance. The tolerance number gotten from the cfloat standard. By contrast, Haskell's Linear package uses 1e-6 for floats
func ToleranceC128 ¶
func ToleranceC128(a, b complex128, e float64) bool
ToleranceC128 is a test to see if two float64s, a and b are equal, within the specified tolerance e.
a: actual value b: expected value e: allowed errors (i.e. the values are within this range)
NOTE: e is a float64, which will be used in the individual comparison of both real and imaginary components
This function was adapted from the test files in the Go stdlib package math/cmplx, which has the Go licence.
func ToleranceF32 ¶
TolereranceF32 is a test to see if two float64s, a and b are equal, within the specified tolerance e.
a: actual value b: expected value e: allowed errors (i.e. the values are within this range)
This function was adapted from the test files of the package github.com/chewxy/math32, which in turn was adapted from the test files of the Go stdlib package math, which has the Go licence.
func ToleranceF64 ¶
ToleranceF64 is a test to see if two float64s, a and b are equal, within the specified tolerance e.
a: actual value b: expected value e: allowed errors (i.e. the values are within this range)
This function was taken from tthe test files in the Go stdlib package math, which has the Go licence.
func VeryCloseC128 ¶
func VeryCloseC128(a, b complex128) bool
VeryCloseC128 checks that a and b are within 1e-16 tolerance
func VeryCloseF32 ¶
VeryCloseF32 checks that a and b are within 1e-6 tolerance. This number was acquired from Haskell's linear package, as well as wikipedia
func VeryCloseF64 ¶
VeryCloseF64 checks that a and b are within 4e-16 tolerance.
Types ¶
This section is empty.