utils

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ByteLen

func ByteLen(q *big.Int) int

ByteLen returns the number of bytes needed to encode 0 <= n < q

func FieldToCurve

func FieldToCurve(q *big.Int) ecc.ID

func FindInSlice

func FindInSlice(x []int, target int) (int, bool)

FindInSlice attempts to find the target in increasing slice x. If not found, returns false and the index where the target would be inserted.

func FromInterface

func FromInterface(input interface{}) big.Int

FromInterface converts an interface to a big.Int element

input must be primitive (uintXX, intXX, []byte, string) or implement BigInt(res *big.Int) (which is the case for gnark-crypto field elements)

if the input is a string, it calls (big.Int).SetString(input, 0). In particular: The number prefix determines the actual base: A prefix of ”0b” or ”0B” selects base 2, ”0”, ”0o” or ”0O” selects base 8, and ”0x” or ”0X” selects base 16. Otherwise, the selected base is 10 and no prefix is accepted.

panics if the input is invalid

func IntSliceSliceToUint64SliceSlice

func IntSliceSliceToUint64SliceSlice(in [][]int) [][]uint64

func Parallelize

func Parallelize(nbIterations int, work func(int, int), maxCpus ...int)

Parallelize process in parallel the work function

func Uint64SliceSliceToIntSliceSlice

func Uint64SliceSliceToIntSliceSlice(in [][]uint64) [][]int

Types

type IntHeap

type IntHeap []int

An IntHeap is a min-heap of linear expressions. It facilitates merging k-linear expressions.

The code is identical to https://pkg.go.dev/container/heap but replaces interfaces with concrete type to avoid memory overhead.

func (*IntHeap) Heapify

func (h *IntHeap) Heapify()

Heapify establishes the heap invariants required by the other routines in this package. Heapify is idempotent with respect to the heap invariants and may be called whenever the heap invariants may have been invalidated. The complexity is O(n) where n = len(*h).

func (*IntHeap) Pop

func (h *IntHeap) Pop()

Pop removes and returns the minimum element (according to Less) from the heap. The complexity is O(log n) where n = len(*h). Pop is equivalent to Remove(h, 0).

type MultiListSeeker

type MultiListSeeker [][]int

MultiListSeeker looks up increasing integers in a list of increasing lists of integers.

func (MultiListSeeker) Seek

func (s MultiListSeeker) Seek(n int) int

Seek returns the index of the earliest list where n is found, or -1 if not found.

Jump to

Keyboard shortcuts

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