exponents

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 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Index

func Index(h Helper, S Interface, x object.Element) (int, error)

Index searches for x in a sorted slice S and returns the index, or -1 if not present. Assumes that the slice is sorted in increasing order.

func IndexOfZero

func IndexOfZero(S Interface) int

IndexOfZero returns the index of 0 in the slice, or -1 if not present. Assumes that the slice is sorted in increasing order.

func IsSorted

func IsSorted(S Interface) bool

IsSorted returns true iff the entries in the slice S are in strictly increasing order.

func SliceToUnwrappedSlice

func SliceToUnwrappedSlice(h Helper, S slice.Interface) (T unwrappedexponents.Interface, err error)

SliceToUnwrappedSlice attempts to convert the entries in the slice S to a slice of unwrapped exponents using the given helper. If S satisfies the interface:

type SliceToUnwrappedSlicer interface {
	SliceToUnwrappedSlice(S slice.Interface)
		(unwrappedexponents.Interface, error) // SliceToUnwrappedSlice
		  attempts to convert the entries in the slice S to a slice of
		  unwrapped exponents.
}

then S's SliceToUnwrappedSlice method will be used.

Types

type Helper

type Helper interface {
	Universe() polynomial.ExponentMonoid                         // Universe returns the user-facing parent of the exponents.
	New(capacity int) unwrappedexponents.Interface               // New returns a new slice of unwrapped exponents with given capacity.
	Wrap(S unwrappedexponents.Interface) (Interface, error)      // Wrap wraps the given slice of unwrapped exponents.
	ToUnwrappedElement(x object.Element) (object.Element, error) // ToUnwrappedElement attempts to map the element x from the user-facing universe to the universe of the unwrapped exponents.
}

Helper defines the common interface for an exponent slice helper.

type Interface

type Interface interface {
	slice.Interface
	Universe() polynomial.ExponentMonoid  // Universe returns the user-facing parent of the exponents.
	Unwrap() unwrappedexponents.Interface // Unwrap returns the underlying internal slice of exponents.
}

Interface is the interface satisfied by a slice of exponents.

func EmptySlice

func EmptySlice(h Helper) Interface

EmptySlice returns an empty slice.

func SliceContainingZero

func SliceContainingZero(h Helper) Interface

SliceContainingZero returns a slice with the single entry 0.

type PrettyPrintFunc

type PrettyPrintFunc func(i int) string

PrettyPrintFunc returns a string str for the i-th exponent in the slice. This will panic if i is out of range.

func PrettyPrint

func PrettyPrint(S Interface, names []string) (PrettyPrintFunc, error)

PrettyPrint returns a PrettyPrintFunc for the given exponents slice S and variable print names. If S satisfies the interface:

type PrettyPrinter interface {
	PrettyPrint(i int, names []string) string // PrettyPrint returns a
	   string representation of the i-th exponent using the given slice
	   of names. This will panic if the index is out of range, or if
	   there are not enough names for the dimension.
}

then S's PrettyPrint method will be used by the returned PrettyPrintFunc. Otherwise, if the underlying slice of wrapped exponents satisfies the PrettyPrinter interface, then its PrettyPrint method will be used by the returned PrettyPrintFunc. Failing that, a generic PrettyPrintFunc will be returned.

Jump to

Keyboard shortcuts

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