Documentation ¶
Overview ¶
Package utils implements various helper functions.
Index ¶
- func Alias1D[V any](x, y []V) bool
- func Alias2D[V any](x, y [][]V) bool
- func AllDistinct[V comparable](s []V) bool
- func BitReverse64[V uint64 | uint32 | int | int64](index V, bitLen int) uint64
- func BitReverseInPlaceSlice[V any](slice []V, N int)
- func GCD[V uint64 | uint32 | int | int64](a, b V) V
- func GetDistincts[V comparable](v []V) (vd []V)
- func HammingWeight64[V uint64 | uint32 | int | int64](x V) V
- func IsNil(i interface{}) bool
- func Pointy[T Number](x T) *T
- func PointyIntToPointUint64(x *int) *uint64
- func RotateSlice[V any](s []V, k int) []V
- func RotateSliceAllocFree[V any](s []V, k int, sout []V)
- func RotateSliceInPlace[V any](s []V, k int)
- func RotateSlotsNew[V any](s []V, k int) (r []V)
- type Number
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Alias1D ¶
Alias1D returns true if x and y share the same base array. Taken from http://golang.org/src/pkg/math/big/nat.go#L340 .
func Alias2D ¶
Alias2D returns true if x and y share the same base array. Taken from http://golang.org/src/pkg/math/big/nat.go#L340 .
func AllDistinct ¶
func AllDistinct[V comparable](s []V) bool
AllDistinct returns true if all elements in s are distinct, and false otherwise.
func BitReverse64 ¶
BitReverse64 returns the bit-reverse value of the input value, within a context of 2^bitLen.
func BitReverseInPlaceSlice ¶
BitReverseInPlaceSlice applies an in-place bit-reverse permutation on the input slice.
func GetDistincts ¶
func GetDistincts[V comparable](v []V) (vd []V)
GetDistincts returns the list of distinct elements in v.
func HammingWeight64 ¶
HammingWeight64 returns the Hamming weight if the input value.
func IsNil ¶
func IsNil(i interface{}) bool
IsNil returns true either type or value are nil. Only interfaces or pointers to objects should be passed as argument.
func Pointy ¶
func Pointy[T Number](x T) *T
Pointy creates a new T variable and returns its pointer.
func PointyIntToPointUint64 ¶
PointyIntToPointUint64 converts *int to *uint64.
func RotateSlice ¶
RotateSlice returns a new slice corresponding to s rotated by k positions to the left.
func RotateSliceAllocFree ¶
RotateSliceAllocFree rotates slice s by k positions to the left and writes the result in sout. without allocating new memory.
func RotateSliceInPlace ¶
RotateSliceInPlace rotates slice s in place by k positions to the left.
func RotateSlotsNew ¶
RotateSlotsNew returns a new slice where the two half of the original slice are rotated each by k positions independently.
Types ¶
Directories ¶
Path | Synopsis |
---|---|
Package bignum implements arbitrary precision arithmetic for integers, reals and complex numbers.
|
Package bignum implements arbitrary precision arithmetic for integers, reals and complex numbers. |
Package buffer implement methods for efficiently writing and reading values to and from io.Writer and io.Reader that also expose their internal buffers.
|
Package buffer implement methods for efficiently writing and reading values to and from io.Writer and io.Reader that also expose their internal buffers. |
Package concurrency implements a simple channel based ressource manager for concurrent operations.
|
Package concurrency implements a simple channel based ressource manager for concurrent operations. |
Package factorization implements various algorithms for efficient factoring integers of small to medium size.
|
Package factorization implements various algorithms for efficient factoring integers of small to medium size. |
Package sampling implements secure sampling.
|
Package sampling implements secure sampling. |
Package structs implements helpers to generalize vectors and matrices of structs, as well as their serialization.
|
Package structs implements helpers to generalize vectors and matrices of structs, as well as their serialization. |