int64number

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: 10 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 equals y.

func Cmp

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

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

Types

type Element

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

Element is an int64-valued element.

func Add

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

Add returns the sum x + y, or an error if out of range.

func CopySlice

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

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

func FromInt

func FromInt(n int) *Element

FromInt returns a new int64-valued element.

func FromInt32

func FromInt32(n int32) *Element

FromInt32 returns a new int64-valued element.

func FromInt64

func FromInt64(n int64) *Element

FromInt64 returns a new int64-valued element.

func FromInteger

func FromInteger(n *integer.Element) (*Element, error)

FromInteger returns a new int64-valued element, or an error if out of range.

func FromString

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

FromString returns the integer represented by the string s.

func FromUint64

func FromUint64(n uint64) (*Element, error)

FromUint64 returns a new int64-valued element, or an error if out of range.

func GobDecode

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

GobDecode reads the next value from the given gob.Decoder and decodes it as an int64-valued element.

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 int64-valued elements.

func Multiply

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

Multiply returns the product x * y, or an error if out of range.

func MultiplyThenAdd

func MultiplyThenAdd(x *Element, y *Element, z *Element) (*Element, error)

MultiplyThenAdd returns x * y + z, or an error if out of range

func MultiplyThenSubtract

func MultiplyThenSubtract(x *Element, y *Element, z *Element) (*Element, error)

MultiplyThenSubtract returns x * y - z, or an error if out of range

func Negate

func Negate(x *Element) (*Element, error)

Negate returns the negation -x, or an error if out of range.

func One

func One() *Element

One returns 1.

func Power

func Power(x *Element, k *integer.Element) (*Element, error)

Power returns x^k, or an error if the result is out of range.

func PowerInt64

func PowerInt64(x *Element, k int64) (*Element, error)

PowerInt64 returns x^k, or an error if the result is out of range.

func SliceFromInt64Slice

func SliceFromInt64Slice(S []int64) []*Element

SliceFromInt64Slice returns a slice of Elements corresponding to the integers in S.

func SliceFromIntSlice

func SliceFromIntSlice(S []int) []*Element

SliceFromIntSlice returns a slice of Elements corresponding to the integers in S.

func SliceFromIntegerSlice

func SliceFromIntegerSlice(S []*integer.Element) ([]*Element, error)

SliceFromIntegerSlice returns a slice of Elements corresponding to the integers in S.

func Subtract

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

Subtract returns the difference x - y, or an error if out of range.

func SubtractInt64

func SubtractInt64(x *Element, y int64) (*Element, error)

SubtractInt64 returns the difference x - y, or an error if out of range.

func ToElement

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

ToElement attempts to convert the given object.Element to an int64-valued element.

func Zero

func Zero() *Element

Zero returns 0.

func (*Element) Abs

func (x *Element) Abs() (*Element, error)

Abs returns the absolute value of x, or an error if out of range.

func (*Element) Decrement

func (x *Element) Decrement() (*Element, error)

Decrement returns x - 1, or an error if 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.

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 the element.

func (*Element) Increment

func (x *Element) Increment() (*Element, error)

Increment returns x + 1, or an error if out of range.

func (*Element) Int64

func (x *Element) Int64() int64

Int64 returns the value as an int64.

func (*Element) IsEqualTo

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

IsEqualTo returns true iff x is equal to y.

func (*Element) IsEqualToInt64

func (x *Element) IsEqualToInt64(y int64) bool

IsEqualToInt64 returns true iff x is equal to y.

func (*Element) IsGreaterThan

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

IsGreaterThan returns true iff x > y.

func (*Element) IsGreaterThanInt64

func (x *Element) IsGreaterThanInt64(y int64) bool

IsGreaterThanInt64 returns true iff x > y.

func (*Element) IsGreaterThanOrEqualTo

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

IsGreaterThanOrEqualTo returns true iff x >= y.

func (*Element) IsGreaterThanOrEqualToInt64

func (x *Element) IsGreaterThanOrEqualToInt64(y int64) bool

IsGreaterThanOrEqualToInt64 returns true iff x >= y.

func (*Element) IsLessThan

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

IsLessThan returns true iff x < y.

func (*Element) IsLessThanInt64

func (x *Element) IsLessThanInt64(y int64) bool

IsLessThanInt64 returns true iff x < y.

func (*Element) IsLessThanOrEqualTo

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

IsLessThanOrEqualTo returns true iff x <= y.

func (*Element) IsLessThanOrEqualToInt64

func (x *Element) IsLessThanOrEqualToInt64(y int64) bool

IsLessThanOrEqualToInt64 returns true iff x <= y.

func (*Element) IsNegative

func (x *Element) IsNegative() bool

IsNegative returns true iff x < 0.

func (*Element) IsOne

func (x *Element) IsOne() bool

IsOne returns true iff x is 1.

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 0.

func (*Element) Parent

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

Parent returns the parent of the element.

func (*Element) ScalarMultiplyByInt64

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

ScalarMultiplyByInt64 returns n * x, or an error if out of range.

func (*Element) ScalarMultiplyByInteger

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

ScalarMultiplyByInteger returns n * x, or an error if out of range.

func (*Element) Sign

func (x *Element) Sign() int

Sign returns the sign of x, i.e. -1 if x < 0; 0 if x == 0; +1 if x > 0.

func (*Element) String

func (x *Element) String() string

String returns a string representation of the element.

func (*Element) ToInteger

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

ToInteger returns the value as an integer.

func (*Element) Uint64

func (x *Element) Uint64() (uint64, error)

Uint64 returns the value as a uint64, or an error if out of range.

type Parent

type Parent struct{}

Parent is the (unique) set of int64-valued elements.

func Set

func Set() Parent

Set returns the (unique) set of int64-valued elements. Note that this isn't really a ring since, for example, the range of the values is bounded and hence isn't closed under addition.

func (Parent) Add

Add returns x + y, or an error if the result is out of range.

func (Parent) AreEqual

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

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

func (Parent) Cmp

func (R 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 (R Parent) Contains(x object.Element) bool

Contains returns true iff x is an element of this parent, or can naturally be regarded as an element of this parent.

func (Parent) IsOne

func (R Parent) IsOne(x object.Element) (bool, error)

IsOne returns true iff x is the multiplicative identity element.

func (Parent) IsZero

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

IsZero returns true iff x is the additive identity element.

func (Parent) Multiply

func (R Parent) Multiply(x object.Element, y object.Element) (object.Element, error)

Multiply returns the product x * y, or an error if the result is out of range.

func (Parent) Negate

func (R Parent) Negate(x object.Element) (object.Element, error)

Negate returns -x, or an error if the result is out of range.

func (Parent) One

func (R Parent) One() object.Element

One returns the multiplicative identity element.

func (Parent) Power

func (R Parent) Power(x object.Element, k *integer.Element) (object.Element, error)

Power returns x^k, or an error if the result is out of range.

func (Parent) ScalarMultiplyByInteger

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

ScalarMultiplyByInteger returns the product n * x, or an error if the result is out of range.

func (Parent) String

func (R Parent) String() string

String returns a string representation of the parent.

func (Parent) Subtract

func (R Parent) Subtract(x object.Element, y object.Element) (object.Element, error)

Subtract returns x - y, or an error if the result is out of range.

func (Parent) ToElement

func (R 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 (R Parent) Zero() object.Element

Zero returns the additive identity element.

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