Documentation ¶
Overview ¶
Package chk contains functions for checking and testing computations
Index ¶
- Variables
- func AnaNum(tst *testing.T, msg string, tol, ana, num float64, verbose bool)
- func AnaNumC(tst *testing.T, msg string, tol float64, ana, num complex128, verbose bool)
- func Array(tst *testing.T, msg string, tol float64, res, correct []float64)
- func ArrayC(tst *testing.T, msg string, tol float64, res, correct []complex128)
- func Bools(tst *testing.T, msg string, a, b []bool)
- func CallerInfo(idx int)
- func CheckAndPrint(tst *testing.T, msg string, tol, diff float64)
- func Complex128(tst *testing.T, msg string, tolNorm float64, res, correct complex128)
- func Deep2(tst *testing.T, msg string, tol float64, res, correct [][]float64)
- func Deep2c(tst *testing.T, msg string, tol float64, res, correct [][]complex128)
- func Deep3(tst *testing.T, msg string, tol float64, a, b [][][]float64)
- func Deep4(tst *testing.T, msg string, tol float64, a, b [][][][]float64)
- func DerivScaSca(tst *testing.T, msg string, tol, gAna, xAt, h float64, verb bool, ...)
- func DerivScaVec(tst *testing.T, msg string, tol float64, gAna, xAt []float64, h float64, ...)
- func DerivVecSca(tst *testing.T, msg string, tol float64, gAna []float64, xAt, h float64, ...)
- func DerivVecVec(tst *testing.T, msg string, tol float64, gAna [][]float64, xAt []float64, ...)
- func Err(msg string, prm ...interface{}) error
- func Float64(tst *testing.T, msg string, tol, res, correct float64)
- func Float64assert(a, b float64)
- func Int(tst *testing.T, msg string, val, correct int)
- func Int32(tst *testing.T, msg string, val, correct int32)
- func Int32s(tst *testing.T, msg string, a, b []int32)
- func Int64(tst *testing.T, msg string, val, correct int64)
- func Int64s(tst *testing.T, msg string, a, b []int64)
- func IntAssert(a, b int)
- func IntAssertLessThan(a, b int)
- func IntAssertLessThanOrEqualTo(a, b int)
- func IntDeep2(tst *testing.T, msg string, res, correct [][]int)
- func Ints(tst *testing.T, msg string, a, b []int)
- func Panic(msg string, prm ...interface{})
- func PanicSimple(msg string, prm ...interface{})
- func PrintAnaNum(msg string, tol, ana, num float64, verbose bool) (e error)
- func PrintAnaNumC(msg string, tol float64, ana, num complex128, verbose bool) (e error)
- func PrintFail(msg string, prm ...interface{})
- func PrintOk(msg string, prm ...interface{})
- func PrintTitle(title string)
- func Recover()
- func RecoverTst(tst *testing.T)
- func RecoverTstPanicIsOK(tst *testing.T)
- func StrAssert(a, b string)
- func StrDeep2(tst *testing.T, msg string, res, correct [][]string)
- func String(tst *testing.T, str, correct string)
- func Strings(tst *testing.T, msg string, a, b []string)
- func Symmetry(tst *testing.T, msg string, X []float64)
Constants ¶
This section is empty.
Variables ¶
var ( // AssertOn activates or deactivates asserts AssertOn = true // Verbose turn on verbose mode Verbose = false // ColorsOn turn on use of colours on console ColorsOn = true )
Functions ¶
func ArrayC ¶
func ArrayC(tst *testing.T, msg string, tol float64, res, correct []complex128)
ArrayC compares two slices of complex nummbers
func CallerInfo ¶
func CallerInfo(idx int)
CallerInfo returns the file and line positions where an error occurred
idx -- use idx=2 to get the caller of Panic
func CheckAndPrint ¶
CheckAndPrint returns a formatted error message
func Complex128 ¶
func Complex128(tst *testing.T, msg string, tolNorm float64, res, correct complex128)
Complex128 compares two complex128 numbers
func Deep2c ¶
func Deep2c(tst *testing.T, msg string, tol float64, res, correct [][]complex128)
Deep2c compares two nested (depth=2) slices
func DerivScaSca ¶
func DerivScaSca(tst *testing.T, msg string, tol, gAna, xAt, h float64, verb bool, fcn func(x float64) float64)
DerivScaSca checks the derivative of scalar w.r.t scalar by comparing with numerical solution obtained with central differences (5-point rule)
Checks: df │ g = —— │ with f:scalar, x:scalar dx │xAt g:scalar Input: tst -- testing.T structure msg -- message about this test tol -- tolerance to compare gAna with gNum gAna -- [scalar] analytical (or other kind) derivative dfdx xAt -- [scalar] position to compute dfdx h -- initial stepsize; e.g. 1e-1 verb -- verbose: show messages fcn -- [scalar] function f(x). x is scalar
func DerivScaVec ¶
func DerivScaVec(tst *testing.T, msg string, tol float64, gAna, xAt []float64, h float64, verb bool, fcn func(x []float64) float64)
DerivScaVec checks the derivative of scalar w.r.t vector by comparing with numerical solution obtained with central differences (5-point rule)
Check: df │ f:scalar {x}:vector {g} = ———— │ with {g}:vector d{x} │{xAt} len(g) == len(x) == len(xAt) Input: tst -- testing.T structure msg -- message about this test tol -- tolerance to compare gAna with gNum gAna -- [vector] analytical (or other kind) derivative dfdx. size=len(x)=len(xAt) xAt -- [vector] position to compute dfdx h -- initial stepsize; e.g. 1e-1 verb -- verbose: show messages fcn -- [scalar] function f(x). x is vector
func DerivVecSca ¶
func DerivVecSca(tst *testing.T, msg string, tol float64, gAna []float64, xAt, h float64, verb bool, fcn func(f []float64, x float64))
DerivVecSca checks the derivative of vector w.r.t scalar by comparing with numerical solution obtained with central differences (5-point rule)
Check: d{f} │ {f}:vector x:scalar {g} = ———— │ with {g}:vector dx │xAt len(g) == len(f) Input: tst -- testing.T structure msg -- message about this test tol -- tolerance to compare gAna with gNum gAna -- [vector] analytical (or other kind) derivative dfdx. size=len(f) xAt -- [scalar] position to compute dfdx h -- initial stepsize; e.g. 1e-1 verb -- verbose: show messages fcn -- [vector] function f(x). x is scalar
func DerivVecVec ¶
func DerivVecVec(tst *testing.T, msg string, tol float64, gAna [][]float64, xAt []float64, h float64, verb bool, fcn func(f, x []float64))
DerivVecVec checks the derivative of vector w.r.t vector by comparing with numerical solution obtained with central differences (5-point rule)
Checks: d{f} │ {f}:vector {x}:vector [g] = ———— │ with [g]:matrix d{x} │{xAt} rows(g)==len(f) cols(g)==len(x)==len(xAt) Input: tst -- testing.T structure msg -- message about this test tol -- tolerance to compare gAna with gNum gAna -- [matrix] analytical (or other kind) derivative dfdx. size=(len(f),len(x)) xAt -- [vector] position to compute dfdx h -- initial stepsize; e.g. 1e-1 verb -- verbose: show messages fcn -- [vector] function f(x). x is vector
func Float64assert ¶
func Float64assert(a, b float64)
Float64assert asserts that a is equal to b (floats)
func IntAssertLessThan ¶
func IntAssertLessThan(a, b int)
IntAssertLessThan asserts that a < b (ints)
func IntAssertLessThanOrEqualTo ¶
func IntAssertLessThanOrEqualTo(a, b int)
IntAssertLessThanOrEqualTo asserts that a ≤ b (ints)
func PanicSimple ¶
func PanicSimple(msg string, prm ...interface{})
PanicSimple panicks without calling CallerInfo
func PrintAnaNum ¶
PrintAnaNum formats the output of analytical versus numerical comparisons
func PrintAnaNumC ¶
func PrintAnaNumC(msg string, tol float64, ana, num complex128, verbose bool) (e error)
PrintAnaNumC formats the output of analytical versus numerical comparisons (complex version)
func PrintFail ¶
func PrintFail(msg string, prm ...interface{})
PrintFail prints "FAIL" in red (if ColorsOn==true)
func PrintOk ¶
func PrintOk(msg string, prm ...interface{})
PrintOk prints "OK" in green (if ColorsOn==true)
func RecoverTst ¶
RecoverTst catches panics in tests. Test will fail on 'panic'
func RecoverTstPanicIsOK ¶
RecoverTstPanicIsOK catches panics in tests. Test must 'panic' to be OK
Types ¶
This section is empty.