utils

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2024 License: Apache-2.0, BSD-3-Clause, ISC, + 1 more Imports: 4 Imported by: 0

Documentation

Overview

Package utils implements various helper functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Alias1D

func Alias1D[V any](x, y []V) bool

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

func Alias2D[V any](x, y [][]V) bool

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

func BitReverse64[V uint64 | uint32 | int | int64](index V, bitLen int) uint64

BitReverse64 returns the bit-reverse value of the input value, within a context of 2^bitLen.

func BitReverseInPlaceSlice

func BitReverseInPlaceSlice[V any](slice []V, N int)

BitReverseInPlaceSlice applies an in-place bit-reverse permutation on the input slice.

func GCD

func GCD[V uint64 | uint32 | int | int64](a, b V) V

GCD computes the greatest common divisor between a and b.

func GetDistincts

func GetDistincts[V comparable](v []V) (vd []V)

GetDistincts returns the list of distinct elements in v.

func HammingWeight64

func HammingWeight64[V uint64 | uint32 | int | int64](x V) V

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

func PointyIntToPointUint64(x *int) *uint64

PointyIntToPointUint64 converts *int to *uint64.

func RotateSlice

func RotateSlice[V any](s []V, k int) []V

RotateSlice returns a new slice corresponding to s rotated by k positions to the left.

func RotateSliceAllocFree

func RotateSliceAllocFree[V any](s []V, k int, sout []V)

RotateSliceAllocFree rotates slice s by k positions to the left and writes the result in sout. without allocating new memory.

func RotateSliceInPlace

func RotateSliceInPlace[V any](s []V, k int)

RotateSliceInPlace rotates slice s in place by k positions to the left.

func RotateSlotsNew

func RotateSlotsNew[V any](s []V, k int) (r []V)

RotateSlotsNew returns a new slice where the two half of the original slice are rotated each by k positions independently.

Types

type Number

type Number interface {
	cs.Complex | cs.Float | cs.Integer | bool
}

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.

Jump to

Keyboard shortcuts

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