uint64vector

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AreEqual

func AreEqual(x *Element, y *Element) bool

AreEqual returns true iff x and y have the same parent, and x = y.

func Cmp

func Cmp(x *Element, y *Element) (int, error)

Cmp returns -1 if x < y, 0 if x == y, and +1 if x > y. This will return an error if x and y do not have the same parent.

func DotProduct

func DotProduct(x *Element, y *Element) (*integer.Element, error)

DotProduct returns the dot-product of the vectors x and y. Here there is no condition on the parents of x and y. This will return an error if the dimensions differ.

Types

type Element

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

Element describes an uint64-valued vector.

func Add

func Add(x *Element, y *Element) (*Element, error)

Add returns the vector sum x + y. This will return an error if x and y do not have the same parent, or if the result is out of range.

func Basis

func Basis(M *Parent) []*Element

Basis returns the n-dimensional standard basis of M.

func ChangeParent

func ChangeParent(M *Parent, x object.Element) (*Element, error)

ChangeParent returns a copy of x with the parent set to the space M of n-dimensional uint64-valued vectors. If x has a ToIntegerSlice method, this will be called to allow conversion. If x cannot be cast into M -- either because the dimensions or length of the slices disagree, or because there is no known way of automatically performing the conversion -- then an error will be returned.

func ConstantVector

func ConstantVector(M *Parent, c *integer.Element) (*Element, error)

ConstantVector returns an n-dimensional vector in M all of whose entries are c.

func CopySlice

func CopySlice(S []*Element) []*Element

CopySlice returns a copy of the slice S. The capacity will be preserved.

func FromInt32Slice

func FromInt32Slice(M *Parent, S []int32) (*Element, error)

FromInt32Slice returns an n-dimensional vector in M with value S. This will return an error if the length of the slice does not agree with the dimension of M, or if any of the entries are negative.

func FromInt64Slice

func FromInt64Slice(M *Parent, S []int64) (*Element, error)

FromInt64Slice returns an n-dimensional vector in M with value S. This will return an error if the length of the slice does not agree with the dimension of M, or if any of the entries are negative.

func FromIntSlice

func FromIntSlice(M *Parent, S []int) (*Element, error)

FromIntSlice returns an n-dimensional vector in M with value S. This will return an error if the length of the slice does not agree with the dimension of M, or if any of the entries are negative.

func FromIntegerSlice

func FromIntegerSlice(M *Parent, S []*integer.Element) (*Element, error)

FromIntegerSlice returns an n-dimensional vector in M with value S. This will return an error if the length of the slice does not agree with the dimension of M, or if the entries do not fit in an uint64.

func FromString

func FromString(M *Parent, s string) (*Element, error)

FromString returns the n-dimensional vector in M represented by the string s. It returns an error if s is malformed, or if any of the entries of the vector represented by s are negative.

func FromUint64Slice

func FromUint64Slice(M *Parent, S []uint64) (*Element, error)

FromUint64Slice returns an n-dimensional vector in M with value S. This will return an error if the length of the slice does not agree with the dimension of M.

func GobDecode

func GobDecode(dec *gob.Decoder) (*Element, error)

GobDecode reads the next value from the given gob.Decoder and decodes it as an uint64-valued vector. The decoded vector will lie in the default lattice of appropriate dimension.

func GobDecodeSlice

func GobDecodeSlice(dec *gob.Decoder) ([]*Element, error)

GobDecodeSlice reads the next value from the given gob.Decoder and decodes it as a slice of uint64-valued vectors. The decoded vectors will lie in the default lattice of appropriate dimension.

func NthBasisElement

func NthBasisElement(M *Parent, n int) (*Element, error)

NthBasisElement returns the n-th standard basis element of M. Here the basis elements are indexed from 0 to d-1 (inclusive), where d is the dimension of M.

func ScalarMultiplyByIntegerThenAdd

func ScalarMultiplyByIntegerThenAdd(a *integer.Element, x *Element, y *Element) (*Element, error)

ScalarMultiplyByIntegerThenAdd returns a * x + y, where a is an integer, and x and y are vectors. This will return an error if x and y do not have the same parent, or if the result is out of range.

func ScalarMultiplyByIntegerThenSubtract

func ScalarMultiplyByIntegerThenSubtract(a *integer.Element, x *Element, y *Element) (*Element, error)

ScalarMultiplyByIntegerThenSubtract returns a * x - y, where a is an integer, and x and y are vectors. This will return an error if x and y do not have the same parent, or if the result is out of range.

func Subtract

func Subtract(x *Element, y *Element) (*Element, error)

Subtract returns the vector different x - y. This will return an error if x and y do not have the same parent, or if the result is out of range.

func Sum

func Sum(M *Parent, S ...*Element) (*Element, error)

Sum returns the sum of the elements in the slice S. The sum of the empty slice is the zero element of M. This will return an error if the elements of S do not all have M as their parent.

func ToElement

func ToElement(M *Parent, x object.Element) (*Element, error)

ToElement returns the argument as an n-dimensional integer-valued vector in the given parent, if that's where it belongs.

func Zero

func Zero(M *Parent) *Element

Zero returns the n-dimensional zero vector in M.

func (*Element) DecrementEntry

func (x *Element) DecrementEntry(i int) (*Element, error)

DecrementEntry returns a new n-dimensional vector equal to x, but with the i-th entry decremented by one. Entries are indexed from 0 up to one less than the dimension of the parent of x (inclusive). This will return an error if i is out of range, or if the result is out of range.

func (*Element) Dimension

func (x *Element) Dimension() int

Dimension returns the dimension of the parent of the vector x.

func (*Element) Entry

func (x *Element) Entry(i int) (*integer.Element, error)

Entry returns the i-th entry in the vector x, where the entries are indexed from 0 up to one less than the dimension of the parent of x (inclusive). This will return an error if i is out of range.

func (*Element) EntryAsUint64

func (x *Element) EntryAsUint64(i int) (uint64, error)

EntryAsUint64 returns the i-th entry in the vector x, where the entries are indexed from 0 up to one less than the dimension of the parent of x (inclusive). This will return an error if i is out of range.

func (*Element) EntryAsUint64OrPanic

func (x *Element) EntryAsUint64OrPanic(i int) uint64

EntryAsUint64OrPanic returns the i-th entry in the vector x, where the entries are indexed from 0 up to one less than the dimension of the parent of x (inclusive). This will panic if i is out of range.

func (*Element) EntryOrPanic

func (x *Element) EntryOrPanic(i int) *integer.Element

EntryOrPanic returns the i-th entry in the vector x, where the entries are indexed from 0 up to one less than the dimension of the parent of x (inclusive). This will panic if i is out of range.

func (*Element) GobDecode

func (x *Element) GobDecode(buf []byte) error

GobDecode implements the gob.GobDecoder interface. Important: Take great care that you are decoding into a new *Element; the safe way to do this is to use the GobDecode(dec *gob.Decode) function. The decoded vector will lie in the default lattice of appropriate dimension.

func (*Element) GobEncode

func (x *Element) GobEncode() ([]byte, error)

GobEncode implements the gob.GobEncoder interface.

func (*Element) Hash

func (x *Element) Hash() hash.Value

Hash returns a hash value for this vector.

func (*Element) IncrementEntry

func (x *Element) IncrementEntry(i int) (*Element, error)

IncrementEntry returns a new n-dimensional vector equal to x, but with the i-th entry incremented by one. Entries are indexed from 0 up to one less than the dimension of the parent of x (inclusive). This will return an error if i is out of range, or if the result is out of range.

func (*Element) IsEqualTo

func (x *Element) IsEqualTo(y *Element) bool

IsEqualTo returns true iff x and y have the same parent, and x = y.

func (*Element) IsGreaterThan

func (x *Element) IsGreaterThan(y *Element) bool

IsGreaterThan returns true iff x and y have the same parent, and x > y.

func (*Element) IsGreaterThanOrEqualTo

func (x *Element) IsGreaterThanOrEqualTo(y *Element) bool

IsGreaterThanOrEqualTo returns true iff x and y have the same parent, and x >= y.

func (*Element) IsLessThan

func (x *Element) IsLessThan(y *Element) bool

IsLessThan returns true iff x and y have the same parent, and x < y.

func (*Element) IsLessThanOrEqualTo

func (x *Element) IsLessThanOrEqualTo(y *Element) bool

IsLessThanOrEqualTo returns true iff x and y have the same parent, and x <= y.

func (*Element) IsPositive

func (x *Element) IsPositive() bool

IsPositive returns true iff x > 0.

func (*Element) IsZero

func (x *Element) IsZero() bool

IsZero returns true iff x is the zero vector (0,0,...,0).

func (*Element) Parent

func (x *Element) Parent() object.Parent

Parent returns the parent of this vector.

func (*Element) ScalarMultiplyByInt64

func (x *Element) ScalarMultiplyByInt64(a int64) (*Element, error)

ScalarMultiplyByInt64 returns the scalar product a * x, where a is an integer. This will return an error if the result is out of range.

func (*Element) ScalarMultiplyByInteger

func (x *Element) ScalarMultiplyByInteger(a *integer.Element) (*Element, error)

ScalarMultiplyByInteger returns the scalar product a * x, where a is an integer. This will return an error if the result is out of range.

func (*Element) ScalarMultiplyByUint64

func (x *Element) ScalarMultiplyByUint64(a uint64) (*Element, error)

ScalarMultiplyByUint64 returns the scalar product a * x, where a is an integer. This will return an error if the result is out of range.

func (*Element) String

func (x *Element) String() string

String returns a string representation of the vector.

func (*Element) ToInt64Slice

func (x *Element) ToInt64Slice() ([]int64, error)

ToInt64Slice returns the vector as a slice of int64s, or an error if any entry in the vector overflows an int64.

func (*Element) ToIntegerSlice

func (x *Element) ToIntegerSlice() []*integer.Element

ToIntegerSlice returns the vector as a slice of integers. Note that you can modify the returned slice without affecting the vector.

func (*Element) ToUint64Slice

func (x *Element) ToUint64Slice() []uint64

ToUint64Slice returns the vector as a slice of uint64s.

func (*Element) TotalDegree

func (x *Element) TotalDegree() *integer.Element

TotalDegree returns the total degree of the vector x. That is, it returns the sum of the entries in x.

type Parent

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

Parent is an n-dimensional uint64-module.

func DefaultLattice

func DefaultLattice(n int) (*Parent, error)

DefaultLattice returns the default space of n-dimensional uint64-valued vectors with lex ordering. This is provided for use when the particular space the vector lives in is either currently undetermined, or doesn't matter. Calls to DefaultLattice (with the same value of n) always return the same n-dimensional space. This will return an error if n is negative.

func DefaultLatticeWithOrder

func DefaultLatticeWithOrder(n int, c monomialorder.Type) (*Parent, error)

DefaultLatticeWithOrder returns the default space of n-dimensional uint64-valued vectors with given ordering. This is provided for use when the particular space the vector lives in is either currently undetermined, or doesn't matter. Calls to DefaultLattice (with the same value of n) always return the same n-dimensional space. This will return an error if n is negative.

func NewLattice

func NewLattice(n int) (*Parent, error)

NewLattice returns a new space of n-dimensional uint64-valued vectors with lex ordering. That is, it returns a copy of uint64^n. Note that two different copies of uint64^n will be regarded as being distinct. This will return an error if n is negative.

func NewLatticeWithOrder

func NewLatticeWithOrder(n int, c monomialorder.Type) (M *Parent, err error)

NewLatticeWithOrder returns a new space of n-dimensional integer-valued vectors with given ordering. That is, it returns a copy of ZZ^n. Note that two different copies of ZZ^n will be regarded as being distinct. This will return an error if n is negative.

func (*Parent) Add

Add returns the sum x + y of the n-dimensional vectors x and y in M.

func (*Parent) AreEqual

func (M *Parent) AreEqual(x object.Element, y object.Element) (bool, error)

AreEqual returns true iff x and y are both contained in M, and x = y.

func (*Parent) AssignName

func (M *Parent) AssignName(name string)

AssignName assigns a name to M to be used by String.

func (*Parent) Basis

func (M *Parent) Basis() []object.Element

Basis returns the standard basis of M.

func (*Parent) Cmp

func (M *Parent) Cmp(x object.Element, y object.Element) (int, error)

Cmp returns -1 if x < y, 0 if x == y, and +1 if x > y.

func (*Parent) Contains

func (M *Parent) Contains(x object.Element) bool

Contains returns true iff x is a vector in M. Note that we do not allow a natural isomorphism between two different parents, hence it is not sufficient that the dimensions agree.

func (*Parent) Dimension

func (M *Parent) Dimension() int

Dimension returns the dimension of M.

func (*Parent) InclusionMap

func (M *Parent) InclusionMap(i int) (objectmap.Interface, error)

InclusionMap returns the inclusion ZZ -> M into the (i+1)-th factor of the of M. This is, the inclusion maps are indexed from 0.

func (*Parent) IsZero

func (M *Parent) IsZero(x object.Element) (bool, error)

IsZero returns true iff x is the n-dimensional zero vector in M.

func (*Parent) MonomialOrder

func (M *Parent) MonomialOrder() monomialorder.Type

MonomialOrder returns the monomial order being used to order the elements of M.

func (*Parent) NthBasisElement

func (M *Parent) NthBasisElement(n int) (object.Element, error)

NthBasisElement returns the n-th standard basis element of M. Here the basis elements are indexed from 0 to d-1 (inclusive), where d is the dimension of M.

func (*Parent) ProjectionMap

func (M *Parent) ProjectionMap(i int) (objectmap.Interface, error)

ProjectionMap returns the projection M -> ZZ onto the (i+1)-th factor of M. That is, projection maps are indexed from 0.

func (*Parent) Rank

func (M *Parent) Rank() int

Rank returns the dimension of M.

func (*Parent) ScalarMultiplyByInteger

func (M *Parent) ScalarMultiplyByInteger(n *integer.Element, x object.Element) (object.Element, error)

ScalarMultiplyByInteger returns nx, where this is defined to be x + ... + x (n times) if n is positive, and -x - ... - x (|n| times) if n is negative. This returns an error if the result is out of range.

func (*Parent) String

func (M *Parent) String() string

String returns a string representation of M.

func (*Parent) Sum

func (M *Parent) Sum(S ...object.Element) (object.Element, error)

Sum returns the sum of the elements in the slice S. The sum of the empty slice is the zero element of M.

func (*Parent) ToElement

func (M *Parent) ToElement(x object.Element) (object.Element, error)

ToElement returns x as an element of this parent, or an error if x cannot naturally be regarded as an element of this parent.

func (*Parent) Zero

func (M *Parent) Zero() object.Element

Zero returns the n-dimensional zero vector in M.

type Slice

type Slice []*Element

Slice wraps an []*Element, implementing slice.Interface.

func (Slice) Entry

func (S Slice) Entry(i int) object.Element

Entry returns the i-th element in the slice. This will panic if i is out of range.

func (Slice) Hash

func (S Slice) Hash() hash.Value

Hash returns a hash value for this slice.

func (Slice) Len

func (S Slice) Len() int

Len returns the length of the slice.

func (Slice) Slice

func (S Slice) Slice(k int, m int) slice.Interface

Slice returns a subslice starting at index k and of length m - k. The returned subslice will be of the same underlying type. This will panic if the arguments are out of range.

Jump to

Keyboard shortcuts

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