eisenstein

package
v0.0.0-...-4a97a7c Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ComplexNumber

type ComplexNumber struct {
	A0, A1 *big.Int
}

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

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

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.

Jump to

Keyboard shortcuts

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