Documentation ¶
Overview ¶
Package Eisenstein provides Eisenstein integer arithmetic.
The Eisenstein integers form a commutative ring of algebraic integers in the algebraic number field Q(ω) – the third cyclotomic field. These are of the form z = a + bω, where a and b are integers and ω is a primitive third root of unity i.e. ω²+ω+1 = 0.
Index ¶
- type ComplexNumber
- func (z *ComplexNumber) Add(x, y *ComplexNumber) *ComplexNumber
- func (z *ComplexNumber) Conjugate(x *ComplexNumber) *ComplexNumber
- func (z *ComplexNumber) Equal(x *ComplexNumber) bool
- func (z *ComplexNumber) Mul(x, y *ComplexNumber) *ComplexNumber
- func (z *ComplexNumber) Neg(x *ComplexNumber) *ComplexNumber
- func (z *ComplexNumber) Norm() *big.Int
- func (z *ComplexNumber) QuoRem(x, y, r *ComplexNumber) (*ComplexNumber, *ComplexNumber)
- func (z *ComplexNumber) Set(x *ComplexNumber) *ComplexNumber
- func (z *ComplexNumber) SetOne() *ComplexNumber
- func (z *ComplexNumber) SetZero() *ComplexNumber
- func (z *ComplexNumber) String() string
- func (z *ComplexNumber) Sub(x, y *ComplexNumber) *ComplexNumber
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ComplexNumber ¶
A ComplexNumber represents an arbitrary-precision Eisenstein integer.
func HalfGCD ¶
func HalfGCD(a, b *ComplexNumber) [3]*ComplexNumber
HalfGCD returns the rational reconstruction of a, b. This outputs w, v, u s.t. w = a*u + b*v.
func (*ComplexNumber) Add ¶
func (z *ComplexNumber) Add(x, y *ComplexNumber) *ComplexNumber
Add sets z to the sum of x and y, and returns z.
func (*ComplexNumber) Conjugate ¶
func (z *ComplexNumber) Conjugate(x *ComplexNumber) *ComplexNumber
Conjugate sets z to the conjugate of x, and returns z.
func (*ComplexNumber) Equal ¶
func (z *ComplexNumber) Equal(x *ComplexNumber) bool
Equal returns true if z equals x, false otherwise
func (*ComplexNumber) Mul ¶
func (z *ComplexNumber) Mul(x, y *ComplexNumber) *ComplexNumber
Mul sets z to the product of x and y, and returns z.
Given that ω²+ω+1=0, the explicit formula is:
(x0+x1ω)(y0+y1ω) = (x0y0-x1y1) + (x0y1+x1y0-x1y1)ω
func (*ComplexNumber) Neg ¶
func (z *ComplexNumber) Neg(x *ComplexNumber) *ComplexNumber
Neg sets z to the negative of x, and returns z.
func (*ComplexNumber) Norm ¶
func (z *ComplexNumber) Norm() *big.Int
Norm returns the norm of z.
The explicit formula is:
N(x0+x1ω) = x0² + x1² - x0*x1
func (*ComplexNumber) QuoRem ¶
func (z *ComplexNumber) QuoRem(x, y, r *ComplexNumber) (*ComplexNumber, *ComplexNumber)
QuoRem sets z to the quotient of x and y, r to the remainder, and returns z and r.
func (*ComplexNumber) Set ¶
func (z *ComplexNumber) Set(x *ComplexNumber) *ComplexNumber
Set sets z to x, and returns z.
func (*ComplexNumber) SetOne ¶
func (z *ComplexNumber) SetOne() *ComplexNumber
SetOne sets z to 1, and returns z.
func (*ComplexNumber) SetZero ¶
func (z *ComplexNumber) SetZero() *ComplexNumber
SetZero sets z to 0, and returns z.
func (*ComplexNumber) String ¶
func (z *ComplexNumber) String() string
String implements Stringer interface for fancy printing
func (*ComplexNumber) Sub ¶
func (z *ComplexNumber) Sub(x, y *ComplexNumber) *ComplexNumber
Sub sets z to the difference of x and y, and returns z.