recursive

package
v0.0.2-0...-db6250e Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2020 License: CC0-1.0, CC0-1.0, CC0-1.0, + 1 more Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

Run performs a recursive binary split on the range 0..length. When the resulting sub-range is of length at most minsize the function f will be called. The results from f are merged into the returned parallel slices of exponents and coefficients. The resulting slices are sorted in strictly-increasing exponent order (so all monomials appearing amongst the terms are distinct) and with all coefficients non-zero.

Types

type Func

type Func func(start int, finish int, newEs exponents.NewFunc, newCs coefficients.NewFunc) (exponents.Interface, coefficients.Interface, error)

Func is the base function of the recursion. It should iterate over the range start <= i < finish, and return parallel slices of exponents and coefficients.

type Iterator

type Iterator struct {
	// contains filtered or unexported fields
}

Iterator provides a way of iterating over multiple slices of exponents and coefficients, sorted in exponent order.

func NewIterator

func NewIterator(Es []exponents.Interface, Cs []coefficients.Interface, cmp compare.CmpFunc) (*Iterator, error)

NewIterator returns a new iterator for the given parallel slices of exponents and coefficients, using the given exponent comparator cmp. The pairs of exponents and coefficients will be iterated over in increasing exponent order. Be sure to call Close on the iterator when finished to ensure that there are no memory leaks. Note that no attempt is made to exclude zero coefficients, or to sum repeated instances of the same exponent. Assumes that the input slices are sorted in increasing exponent order.

func (*Iterator) Close

func (k *Iterator) Close() error

Close closes the iterator and returns the last error encountered during iteration (if any).

func (*Iterator) HasNext

func (k *Iterator) HasNext() bool

HasNext returns true iff there is a next element in the iterator.

func (*Iterator) Next

func (k *Iterator) Next() (e object.Element, c object.Element)

Next returns the next pair of exponent e and coefficient c in the iterator. You must call HasNext before calling Next.

type MergeAndSumIterator

type MergeAndSumIterator struct {
	// contains filtered or unexported fields
}

func NewMergeAndSumIterator

NewMergeAndSumIterator returns a new iterator for the given parallel slices of exponents and coefficients. The pairs of exponents and coefficients will be iterated over in increasing exponent order. Duplicate exponents will have their coefficients summed, and any exponent with zero coefficient will be skipped. Be sure to call Close on the iterator when finished to ensure that there are no memory leaks. Assumes that the input slices are sorted in increasing exponent order. Here L is the parent of the exponents in Es, and K is the parent of the coefficients in Cs.

func (*MergeAndSumIterator) Close

func (m *MergeAndSumIterator) Close() error

Close closes the iterator and returns the last error encountered during iteration (if any).

func (*MergeAndSumIterator) HasNext

func (m *MergeAndSumIterator) HasNext() bool

HasNext returns true iff there is a next element in the iterator.

func (*MergeAndSumIterator) Next

func (m *MergeAndSumIterator) Next() (e object.Element, c object.Element)

Next returns the next pair of exponent e and coefficient c in the iterator. You must call HasNext before calling Next.

Jump to

Keyboard shortcuts

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