utils

package
v0.0.0-...-061a763 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2018 License: MIT Imports: 5 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(s []int, t []int) []int

func AnyTrue

func AnyTrue(values []bool) bool

Returns number of on bits

func Bool2Int

func Bool2Int(s []bool) []int

func BoolEq

func BoolEq(a, b []bool) bool

Compares 2 bool slices for equality

func CartProductInt

func CartProductInt(values [][]int) [][]int

Returns cartesian product of specified 2d arrayb

func Complement

func Complement(s []int, t []int) []int

Returns complement of s and t

func ContainsFloat64

func ContainsFloat64(q float64, vals []float64) bool

func ContainsInt

func ContainsInt(q int, vals []int) bool

Searches int slice for specified integer

func CountFloat64

func CountFloat64(values []float64, value float64) int

Returns number of on bits

func CountInt

func CountInt(values []int, value int) int

Returns number of on bits

func CountTrue

func CountTrue(values []bool) int

Returns number of on bits

func CumProdInt

func CumProdInt(vals []int) []int

Returns cumulative product

func DotInt

func DotInt(a, b []int) int

Dot product

func FillSliceBool

func FillSliceBool(values []bool, value bool)

Populates bool slice with specified value

func FillSliceFloat64

func FillSliceFloat64(values []float64, value float64)

Populates float64 slice with specified value

func FillSliceInt

func FillSliceInt(values []int, value int)

Populates float64 slice with specified value

func FillSliceRangeBool

func FillSliceRangeBool(values []bool, value bool, start, length int)

Populates bool slice with specified value

func FillSliceWithIdxInt

func FillSliceWithIdxInt(values []int)

Populates integer slice with index values

func Make1DBool

func Make1DBool(values []int) []bool

func Make2DBool

func Make2DBool(values [][]int) [][]bool

Helper for unit tests where int literals are easier to read

func MakeSliceFloat64

func MakeSliceFloat64(size int, initialValue float64) []float64

func MakeSliceInt

func MakeSliceInt(size, initialValue int) []int

Creates an integer slice with indices containing the specified initial value

func MaxInt

func MaxInt(a, b []int) []int

returns max index wise comparison

func MaxSliceFloat64

func MaxSliceFloat64(values []float64) float64

Returns max value from specified float slice

func MaxSliceInt

func MaxSliceInt(values []int) int

Returns max value from specified int slice

func Mod

func Mod(a, b int) int

Euclidean modulous

func OnIndices

func OnIndices(s []bool) []int

Returns "on" indices

func OrBool

func OrBool(a, b []bool) []bool

Or's 2 bool slices

func ProdInt

func ProdInt(vals []int) int

Returns product of set of integers

func RandFloatRange

func RandFloatRange(min, max float64) float64

func RandomSample

func RandomSample(length int) []float64

Returns random slice of floats of specified length

func RevCumProdInt

func RevCumProdInt(vals []int) []int

Returns cumulative product starting from end

func RoundPrec

func RoundPrec(x float64, prec int) float64

func SetIdxBool

func SetIdxBool(values []bool, indexes []int, value bool)

sets the specified indexes of a bool slice to specified value

func SubsetSliceBool

func SubsetSliceBool(values []bool, indices []int) []bool

returns a copy of specified indices

func SubsetSliceFloat64

func SubsetSliceFloat64(values []float64, indices []int) []float64

Returns the subset of values specified by indices

func SubsetSliceInt

func SubsetSliceInt(values, indices []int) []int

Returns the subset of values specified by indices

func SumSliceFloat64

func SumSliceFloat64(values []float64) float64

Types

type TupleFloat

type TupleFloat struct {
	A float64
	B float64
}

type TupleInt

type TupleInt struct {
	A int
	B int
}

Jump to

Keyboard shortcuts

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