goflint

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 9, 2024 License: Apache-2.0 Imports: 8 Imported by: 41

README

goflint

Golang wrapper for FLINT2 functions that I find useful.

This project is heavily influenced by and in the same pattern as Golang's GMP wrapper, which seemed appropriate since FLINT uses a similar API to GMP.

Features

Assignments

  • (z *Fmpz) Set(x *Fmpz) *Fmpz Set z to the Fmpz x and return z
  • (z *Fmpz) SetUint64(x uint64) *Fmpz Sets Fpmz z to ulong x and returns z
  • (z *Fmpz) SetInt64(x int64) *Fmpz Sets Fpmz z to slong x and returns z
  • (z *Mpz) SetMpzInt64(x int64) *Mpz Sets Mpz z to slong x and returns z
  • NewFmpz(x int64) *Fmpz allocates a new Fpmz and sets it to x
  • NewMpz(x int64) *Mpz allocates a new GMP Mpz and sets it to x
  • NewFmpq(p, q int64) *Fmpq allocates and returns a new Fmpq set to p / q
  • (q *Fmpq) SetFmpqFraction(num, den *Fmpz) *Fmpq sets the value of q to the fraction num / den and returns q.

Comparisons

  • (z *Fmpz) Cmp(y *Fmpz) (r int) Compares z to y and returns -1, 0, or 1
  • (z *Mpz) Cmp(y *Mpz) (r int) Compares z to y and returns -1, 0, or 1 where z is an Mpz type.
  • (z *Fmpq) CmpRational(y *Fmpq) (r int) Compares rational z to y and returns -1, 0, or 1

Formatters

  • (z *Fmpz) String() string Returns a base 10 string representaiton of z
  • (q *Fmpq) String() string Returns a base 10 string representation of rational q

Helpers

  • (z *Fmpz) BitLen() int Returns the length of z in bits
  • (z *Fmpz) Bits() int Returns the number of bits required to store z
  • (z *Fmpz) TstBit(i int) int Returns the value of the bit stored at index i where 0 is the least significant bit.
  • (z *Fmpz) Sign() (r int) Returns the sign of z returns -1, 0, or 1

Primality Testing and Factorization

  • (z *Fmpz) IsStrongProbabPrime(a *Fmpz) returns 1 if z is a strong probable prime to base a, otherwise it returns 0
  • (z *Fmpz) IsProbabPrimeLucas() int performs a Lucas probable prime test returns 1 if z is a Lucas probable prime, otherwise return 0
  • (z *Fmpz) IsProbabPrimeBPSW() int performs a Baillie-PSW probable prime test returns 1 if z is a probable prime, otherwise return 0
  • (z *Fmpz) IsProbabPrime() int returns 1 if z is a probable prime, otherwise return 0
  • (z *Fmpz) WilliamsPP1(n *Fmpz, b1, b2, c int) int WilliamsPP1 uses Use Williams' p+1 method to factor n, using a prime bound in stage 1 of B1 and a prime limit in stage 2 of at least the square of B2_sqrt. If a factor is found, the function returns 1 and factor is set to the factor that is found. Otherwise, the function returns 0. c should be a random value greater than 2.

Random Number Generation

  • (z *Fmpz) Randm(state *FlintRandT, m *Fmpz) *Fmpz Sets z to a random number between 0 and m-1 inclusive

Conversions

  • (f *Fmpz) GetInt() int Lowers f to type int
  • (f *Fmpz) GetUInt() uint Lowers f to type uint
  • (z *Fmpz) Int64() (y int64) Lowers z to type int64
  • (z *Fmpz) Uint64() (y uint64) Lower z to type uint64
  • (q *Fmpq) GetFmpqFraction() (int, int) gets the numerator and denomenator of the rational q returning them as ints.
  • (z *Fmpz) SetString(s string, base int) (*Fmpz, bool) Sets z to the value in string s using given base
  • (z *Fmpz) SetMpz(x *Mpz) Set z to the value in Mpz x
  • (z *Mpz) GetMpz(x *Fmpz) Set Mpz z to the value of the Fmpz x
  • (z *Fmpz) SetBytes(buf []byte) *Fmpz Set z to the value stored in byte array buf and return z
  • (z *Fmpz) Bytes() []byte Return the bytes of Fmpz z

Arithmetic

  • (z *Fmpz) Abs(x *Fmpz) *Fmpz Set z to the absolute value of x and return z
  • (z *Fmpz) Neg(x *Fmpz) *Fmpz Set z to the negated value of x and return z
  • (z *Fmpz) Add(x, y *Fmpz) *Fmpz Set z to x + y and return z
  • (z *Fmpz) AddZ(x *Fmpz) *Fmpz Set z to z + x and return z
  • (z *Fmpz) AddI(i int) *Fmpz Set z to z + i where i is an int type and return z
  • (z *Fmpz) Sub(x, y *Fmpz) *Fmpz Set z to x - y and return z
  • (z *Fmpz) SubZ(x *Fmpz) *Fmpz Set z to z - x and return z
  • (z *Fmpz) SubI(i int) *Fmpz Set z to z - i where i is an int type and return z
  • (z *Mpz) SubRMpz(y, n *Mpz) Sets z to z - y in the ring of integers modulo n using Mpz types.
  • (z *Fmpz) Mul(x, y *Fmpz) *Fmpz Set z to x * y and return z
  • (z *Fmpz) MulZ(x *Fmpz) *Fmpz Set z to z * x and return z
  • (z *Fmpz) MulI(i int) *Fmpz Set z to z * i where i is an int type and return z
  • (z *Mpz) MulRMpz(y, n *Mpz) *Mpz Sets z to z * y in the integer ring modulo n using Mpz types.
  • (q *Fmpq) MulRational(o *Fmpq, x *Fmpz) *Fmpq Sets q to the product of rational o and Fmpz x and returns q.
  • (z *Fmpz) DivR(y, n *Fmpz) *Fmpz Sets z to the result of z/y in the ring of integers modulo n. Only works if y fits into the int type
  • (z *Fmpz) Div(x, y *Fmpz) *Fmpz Set z to x / y and return z
  • (z *Fmpz) Quo(x, y *Fmpz) *Fmpz
  • (z *Fmpz) QuoRem(x, y, r *Fmpz) (*Fmpz, *Fmpz)
  • (z *Fmpz) Mod(x, y *Fmpz) *Fmpz Set z to the value of x % y and return z
  • (z *Fmpz) ModZ(y *Fmpz) *Fmpz Set z to the value of z % y and return z
  • (z *Fmpz) ModRational(x *Fmpq, n *Fmpz) int Sets z to the residue of x = n/d (num, den) modulo n and returns 1 if such a modulo exists or 0 if it does not
  • (z *Fmpz) DivMod(x, y, m *Fmpz) (*Fmpz, *Fmpz)
  • (z *Fmpz) ModInverse(x, y *Fmpz) *Fmpz
  • (z *Fmpz) NegMod(x, y *Fmpz) *Fmpz
  • (a *Fmpz) Jacobi(p *Fmpz) int
  • (z *Fmpz) Exp(x, y, m *Fmpz) *Fmpz Set z to the value of (x^y)%m and return z
  • (z *Fmpz) ExpZ(x *Fmpz) *Fmpz Set z to the value of (z^x) and return z
  • (z *Fmpz) ExpI(x int) *Fmpz Set z to the value of (z^i) where i is an int type and return z
  • (z *Fmpz) ExpXY(x, y *Fmpz) *Fmpz Set z to the value of (x^y) and return z
  • (z *Fmpz) ExpXI(x *Fmpz, y int) *Fmpz Set z to the value of (x^y) where y is an int type and return z
  • (z *Fmpz) ExpXIM(x *Fmpz, i int, m *Fmpz) *Fmpz Set z to the value of (x^y)%m where y is an int type and return z
  • (z *Fmpz) Pow(x, y, m *Fmpz) *Fmpz Set z to the value of (x^y)%m and return z
  • (f *Fmpz) GCD(g, h *Fmpz) *Fmpz Set z to the value of the greatest common divisor of g and h and return z
  • (f *Fmpz) Lcm(g, h *Fmpz) *Fmpz Set z to the value of the lowest common multiple of g and h and return z
  • (f *Fmpz) GCDInv(g *Fmpz) (*Fmpz, *Fmpz)
  • (z *Fmpz) And(x, y *Fmpz) *Fmpz Set z to the value of x & y and return z
  • (z *Fmpz) Sqrt(x *Fmpz) *Fmpz Set z to the value of the square root of x and return z
  • (z *Fmpz) Root(x *Fmpz, y int32) *Fmpz Set z to the value of then yth root of x and return z

Matrices

  • NewFmpzMat(rows, cols int) *FmpzMat Creates and allocates a new FmpzMat matrix type of size rows * cols.
  • (m *FmpzMat) String() string Returns a pretty printed string version of the matrix as a string.
  • (m *FmpzMat) Zero() *FmpzMat Sets all of the values of the matrix to zero and returns the matrix.
  • (m *FmpzMat) One() *FmpzMat Sets the diagonal values of the matrix to 1 and returns the matrix.
  • (m *FmpzMat) NumRows() int Returns the number of rows in the matrix as an integer.
  • (m *FmpzMat) NumCols() int Returns the number of columns in the matrix.
  • (m *FmpzMat) Entry(x, y int) *Fmpz Returns the value at coordinates x, y in the matrix m.
  • (m *FmpzMat) SetPosVal(val *Fmpz, pos int) *FmpzMat Sets the value at offset pos in the matrix m and returns m.
  • (m *FmpzMat) SetVal(val *Fmpz, x, y int) *FmpzMat Sets the value at coordinates x,y in the matrix and returns m.

Univariate Polynomials over the integers.

  • NewFmpzPoly() *FmpzPoly NewFmpzPoly allocates a new FmpzPoly and returns it.
  • NewFmpzPoly2(a int) *FmpzPoly NewFmpzPoly2 allocates a new FmpzPoly with at least a coefficients and returns it.
  • FmpzPolySetString(poly string) (*FmpzPoly, error) FmpzPolySetString returns a polynomial using the string representation as the definition.
  • (z *FmpzPoly) Set(poly *FmpzPoly) *FmpzPoly Set sets z to poly and returns z
  • (z *FmpzPoly) String() string String returns a string representation of the polynomial.
  • (z *FmpzPoly) StringSimple() string StringSimple returns a simple string representation of the polynomials length and coefficients.
  • (z *FmpzPoly) Zero() *FmpzPoly Zero sets z to the zero polynomial and returns z.
  • (z *FmpzPoly) FitLength(l int) FitLength sets the number of coefficiets in z to l.
  • (z *FmpzPoly) SetCoeff(c int, x *Fmpz) *FmpzPoly SetCoeff sets the c'th coefficient of z to x where x is an Fmpz and returns z.
  • (z *FmpzPoly) SetCoeffUI(c int, x uint) *FmpzPoly SetCoeffUI sets the c'th coefficient of z to x where x is an uint and returns z.
  • (z *FmpzPoly) GetCoeff(c int) *Fmpz GetCoeff gets the c'th coefficient of z and returns an Fmpz.
  • (z *FmpzPoly) GetCoeffs() []*Fmpz GetCoeffs gets all of the coefficient of z and returns a slice of Fmpz.
  • (z *FmpzPoly) Len() int Len returns the length of the poly z.
  • (z *FmpzPoly) Neg(p *FmpzPoly) *FmpzPoly Neg sets z to the negative of p and returns z.
  • (z *FmpzPoly) GCD(a, b *FmpzPoly) *FmpzPoly GCD sets z = gcd(a, b) and returns z.
  • (z *FmpzPoly) Equal(p *FmpzPoly) bool Equal returns true if z is equal to p otherwise false.
  • (z *FmpzPoly) Add(a, b *FmpzPoly) *FmpzPoly Add sets z = a + b and returns z.
  • (z *FmpzPoly) Sub(a, b *FmpzPoly) *FmpzPoly Sub sets z = a - b and returns z.
  • (z *FmpzPoly) Mul(a, b *FmpzPoly) *FmpzPoly Mul sets z = a * b and returns z.
  • (z *FmpzPoly) MulScalar(a *FmpzPoly, x *Fmpz) *FmpzPoly MulScalar sets z = a * x where x is an Fmpz.
  • (z *FmpzPoly) DivScalar(a *FmpzPoly, x *Fmpz) *FmpzPoly DivScalar sets z = a / x where x is an Fmpz. Rounding coefficients down toward -infinity.
  • (z *FmpzPoly) Pow(m *FmpzPoly, e int) *FmpzPoly Pow sets z to m^e and returns z.
  • (z *FmpzPoly) DivRem(m *FmpzPoly) (*FmpzPoly, *FmpzPoly) DivRem computes q, r such that z=mq+r and 0 ≤ len(r) < len(m).

Univariate Polynomials over the integers modulo n.

  • NewFmpzModPoly(n *Fmpz) *FmpzModPoly NewFmpzModPoly allocates a new FmpzModPoly mod n and returns it.
  • NewFmpzModPoly2(n *Fmpz, a int) *FmpzModPoly NewFmpzModPoly2 allocates a new FmpzModPoly mod n with at least a coefficients and returns it.
  • SetString(poly string) (*FmpzModPoly, error) SetString returns a polynomial mod n using the string representation as the definition.
  • (z *FmpzModPoly) Set(poly *FmpzModPoly) *FmpzModPoly Set sets z to poly and returns z
  • (z *FmpzModPoly) String() string String returns a string representation of the polynomial.
  • (z *FmpzModPoly) StringSimple() string StringSimple returns a simple string representation of the polynomials length, modulus and coefficients.
  • (z *FmpzModPoly) Zero() *FmpzModPoly Zero sets z to the zero polynomial and returns z.
  • (z *FmpzModPoly) FitLength(l int) FitLength sets the number of coefficiets in z to l.
  • (z *FmpzModPoly) SetCoeff(c int, x *Fmpz) *FmpzModPoly SetCoeff sets the c'th coefficient of z to x where x is an Fmpz and returns z.
  • (z *FmpzModPoly) SetCoeffUI(c int, x uint) *FmpzModPoly SetCoeffUI sets the c'th coefficient of z to x where x is an uint and returns z.
  • (z *FmpzModPoly) GetCoeff(c int) *Fmpz GetCoeff gets the c'th coefficient of z and returns an Fmpz.
  • (z *FmpzModPoly) GetCoeffs() []*Fmpz GetCoeffs gets all of the coefficient of z and returns a slice of Fmpz.
  • (z *FmpzModPoly) GetMod() *Fmpz GetMod gets the modulus of z and returns an Fmpz.
  • (z *FmpzModPoly) Len() int Len returns the length of the poly z.
  • (z *FmpzModPoly) Neg(p *FmpzModPoly) *FmpzModPoly Neg sets z to the negative of p and returns z.
  • (z *FmpzModPoly) GCD(a, b *FmpzModPoly) *FmpzModPoly GCD sets z = gcd(a, b) and returns z.
  • (z *FmpzModPoly) Equal(p *FmpzModPoly) bool Equal returns true if z is equal to p otherwise false.
  • (z *FmpzModPoly) Add(a, b *FmpzModPoly) *FmpzModPoly Add sets z = a + b and returns z.
  • (z *FmpzModPoly) Sub(a, b *FmpzModPoly) *FmpzModPoly Sub sets z = a - b and returns z.
  • (z *FmpzModPoly) Mul(a, b *FmpzModPoly) *FmpzModPoly Mul sets z = a * b and returns z.
  • (z *FmpzModPoly) MulScalar(a *FmpzModPoly, x *Fmpz) *FmpzModPoly MulScalar sets z = a * x where x is an Fmpz.
  • (z *FmpzModPoly) DivScalar(a *FmpzModPoly, x *Fmpz) *FmpzModPoly DivScalar sets z = a / x where x is an Fmpz.
  • (z *FmpzModPoly) Pow(m *FmpzModPoly, e int) *FmpzModPoly Pow sets z to m^e and returns z.
  • (z *FmpzModPoly) DivRem(m *FmpzModPoly) (*FmpzModPoly, *FmpzModPoly) DivRem computes q, r such that z=mq+r and 0 ≤ len(r) < len(m).

Types

// Fmpz is a arbitrary size integer type.
type Fmpz struct {
  i    C.fmpz_t
  init bool
}

// Mpz is an abitrary size integer type from the Gnu Multiprecision Library.
type Mpz struct {
  i    C.mpz_t
  init bool
}

// Fmpq is an arbitrary precision rational type.
type Fmpq struct {
  i    C.fmpq_t
  init bool
}

// FmpzPoly type represents a univatiate polynomial over the integers.
type FmpzPoly struct {
	i    C.fmpz_poly_t
	init bool
}

// FmpzModPoly type represents elements of Z/nZ[x] for a fixed modulus n.
type FmpzModPoly struct {
	i    C.fmpz_mod_poly_t
	init bool
}

// NmodPoly type represents elements of Z/nZ[x] for a fixed modulus n.
type NmodPoly struct {
  i    C.nmod_poly_t
  init bool
}

// MpLimb type is a uint64.
type MpLimb struct {
  i    C.mp_limb_t
}

// FlintRandT keeps state for Fmpz random number generation.
type FlintRandT struct {
	i    C.flint_rand_t
	init bool
}

// FmpzMat is a matrix of Fmpz.
type FmpzMat struct {
	i    C.fmpz_mat_t
	rows int
	cols int
	init bool
}

Examples

a := NewFmpz(1)

fmt.Println(a.String())

Install

Install the golang and the FLINT library.

  • On Ubuntu (tested on 20.04LTS):
    $ apt install golang libflint-dev`
    
  • On MacOS (tested on Monterey 12.1 M1)
    $ brew install flint
    

Use go to install the library:

  • go get github.com/sourcekris/goflint

License

As this contains a great deal of code copied from the Go source it is licenced identically to the Go source itself - see the LICENSE file for details.

Note About Prior Art

I found this on the internet, it might help me get going quicker but seems written to do a few tasks only:

I am also heavily influenced to do this by nick [at] craig-wood.com due to this repo:

Authors

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Zero is an Fmpz of value 0.
	Zero = NewFmpz(0)
)

Functions

This section is empty.

Types

type FlintRandT

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

FlintRandT keeps state for Fmpz random number generation.

type Fmpq

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

Fmpq is an arbitrary precision rational type.

func NewFmpq

func NewFmpq(p, q int64) *Fmpq

NewFmpq allocates and returns a new Fmpq set to p / q.

func NewFmpqFmpz

func NewFmpqFmpz(p, q *Fmpz) *Fmpq

NewFmpqFmpz allocates and returns a new Fmpq set to p / q where p and q are Fmpz types.

func (*Fmpq) Cmp

func (q *Fmpq) Cmp(y *Fmpq) int

Cmp wraps CmpRational.

func (*Fmpq) CmpRational

func (q *Fmpq) CmpRational(y *Fmpq) (r int)

CmpRational compares rationals z and y and returns:

-1 if z <  y
 0 if z == y
+1 if z >  y

func (*Fmpq) DenRef

func (q *Fmpq) DenRef() int

DenRef returns the denominator of an Fmpq as an integer.

func (*Fmpq) GetFmpqFraction

func (q *Fmpq) GetFmpqFraction() (int, int)

GetFmpqFraction gets the integer numerator and denomenator of the rational Fmpq q.

func (*Fmpq) MulRational

func (q *Fmpq) MulRational(o *Fmpq, x *Fmpz) *Fmpq

MulRational sets q to the product of rational x and integer y and returns q.

func (*Fmpq) NumRef

func (q *Fmpq) NumRef() int

NumRef returns the numerator of an Fmpq as an integer.

func (*Fmpq) SetFmpqFraction

func (q *Fmpq) SetFmpqFraction(num, den *Fmpz) *Fmpq

SetFmpqFraction sets the value of q to the canonical form of the fraction num / den and returns q.

func (*Fmpq) String

func (q *Fmpq) String() string

String returns the decimal representation of z.

type Fmpz

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

Fmpz is a arbitrary size integer type.

func NewFmpz

func NewFmpz(x int64) *Fmpz

NewFmpz allocates and returns a new Fmpz set to x.

func NewFmpzNF

func NewFmpzNF(x int64) *Fmpz

NewFmpzNF allocates and returns a new Fmpz set to x without setting a finalizer.

func (*Fmpz) Abs

func (z *Fmpz) Abs(x *Fmpz) *Fmpz

Abs sets z to |x| (the absolute value of x) and returns z.

func (*Fmpz) Add

func (z *Fmpz) Add(x, y *Fmpz) *Fmpz

Add sets z to the sum x+y and returns z.

func (*Fmpz) AddI

func (z *Fmpz) AddI(x int) *Fmpz

AddI sets z to the sum x+z where x is an int type and returns z.

func (*Fmpz) AddZ

func (z *Fmpz) AddZ(x *Fmpz) *Fmpz

AddZ sets z to the sum x+z and returns z.

func (*Fmpz) And

func (z *Fmpz) And(x, y *Fmpz) *Fmpz

And sets z = x & y and returns z.

func (*Fmpz) BitLen

func (z *Fmpz) BitLen() int

BitLen returns the length of the absolute value of z in bits. The bit length of 0 is 0.

func (*Fmpz) Bits

func (z *Fmpz) Bits() int

Bits returns the number of bits required to store the absolute value of z. If z is 0 then 0 is returned.

func (*Fmpz) Bytes

func (z *Fmpz) Bytes() []byte

Bytes returns the absolute value of z as a big-endian byte slice.

func (*Fmpz) CRT

func (z *Fmpz) CRT(r1, m1, r2, m2 *Fmpz, sign int) *Fmpz

CRT uses the Chinese Remainder Theorem to set out to the unique value 0≤x<M (if sign = 0) or −M/2<x≤M/2 (if sign = 1) congruent to r1 modulo m1 and r2 modulo m2, where where M=m1×m2. It is assumed that m1 and m2 are positive integers greater than 1 and coprime. If sign = 0, it is assumed that 0≤r1<m1 and 0≤r2<m2. Otherwise, it is assumed that −m1≤r1<m1 and 0≤r2<m2.

func (*Fmpz) Cmp

func (z *Fmpz) Cmp(y *Fmpz) (r int)

Cmp compares z and y and returns:

-1 if z <  y
 0 if z == y
+1 if z >  y

func (*Fmpz) Cube

func (z *Fmpz) Cube() *Fmpz

Cube raises z to the power of 3 and returns z.

func (*Fmpz) DLog

func (z *Fmpz) DLog() float64

DLog returns log(z) as a float64.

func (*Fmpz) Div

func (z *Fmpz) Div(x, y *Fmpz) *Fmpz

Div sets z to the quotient x/y for y != 0 and returns z. If y == 0, a division-by-zero run-time panic occurs. Div implements Euclidean division (unlike Go); see DivMod for more details.

func (*Fmpz) DivMod

func (z *Fmpz) DivMod(x, y, m *Fmpz) (*Fmpz, *Fmpz)

DivMod sets z to the quotient x div y and m to the modulus x mod y and returns the pair (z, m) for y != 0. If y == 0, a division-by-zero run-time panic occurs.

DivMod implements Euclidean division and modulus (unlike Go):

q = x div y  such that
m = x - y*q  with 0 <= m < |q|

(See Raymond T. Boute, “The Euclidean definition of the functions div and mod”. ACM Transactions on Programming Languages and Systems (TOPLAS), 14(2):127-144, New York, NY, USA, 4/1992. ACM press.) See QuoRem for T-division and modulus (like Go).

func (*Fmpz) DivR

func (z *Fmpz) DivR(y, n *Fmpz) *Fmpz

DivR sets z to the result of z/y in the ring of integers(n). Currently this only works if y fits into the int type supported by the Fmpq type.

func (*Fmpz) Equals

func (z *Fmpz) Equals(y *Fmpz) bool

Equals compares z and y and returns true if they are equal.

func (*Fmpz) Exp

func (z *Fmpz) Exp(x, y, m *Fmpz) *Fmpz

Exp sets z = x**y mod |m| (i.e. the sign of m is ignored), and returns z. If y <= 0, the result is 1; if m == nil or m == 0, z = x**y. See Knuth, volume 2, section 4.6.3.

func (*Fmpz) ExpI

func (z *Fmpz) ExpI(x int) *Fmpz

ExpI sets z = z**x where i is an int type and returns z.

func (*Fmpz) ExpXI

func (z *Fmpz) ExpXI(x *Fmpz, y int) *Fmpz

ExpXI sets z = x**y where u is an int type and returns z.

func (*Fmpz) ExpXIM

func (z *Fmpz) ExpXIM(x *Fmpz, i int, m *Fmpz) *Fmpz

ExpXIM sets z = x**i mod m where u is an int type and returns z.

func (*Fmpz) ExpXY

func (z *Fmpz) ExpXY(x, y *Fmpz) *Fmpz

ExpXY sets z = x**y and returns z.

func (*Fmpz) ExpZ

func (z *Fmpz) ExpZ(x *Fmpz) *Fmpz

ExpZ sets z = z**x and returns z.

func (*Fmpz) GCD

func (z *Fmpz) GCD(g, h *Fmpz) *Fmpz

GCD sets f to the greatest common divisor of g and h. The result is always positive, even if one of g and h is negative

func (*Fmpz) GCDInv

func (z *Fmpz) GCDInv(g *Fmpz) (*Fmpz, *Fmpz)

GCDInv given integers f, g with 0 ≤ f < g, computes the greatest common divisor d = gcd(f, g) and the modular inverse a = f^-1 (mod g), whenever f != 0 void fmpz_gcdinv (fmpz_t d , fmpz_t a , const fmpz_t f , const fmpz_t g )

func (*Fmpz) GetInt

func (z *Fmpz) GetInt() int

GetInt returns the value of the Fmpz type as an int type if possible.

func (*Fmpz) GetUInt

func (z *Fmpz) GetUInt() uint

GetUInt returns the value of the Fmpz type as a uint type if possible.

func (*Fmpz) Int64

func (z *Fmpz) Int64() (y int64)

Int64 returns the int64 representation of z. If z cannot be represented in an int64, the result is undefined.

func (*Fmpz) IsProbabPrime

func (z *Fmpz) IsProbabPrime() int

IsProbabPrime performs some trial division and then some probabilistic primality tests. If z is definitely composite, the function returns 0, otherwise it is declared probably prime, i.e. prime for most practical purposes, and the function returns 1. The chance of declaring a composite prime is very small.

func (*Fmpz) IsProbabPrimeBPSW

func (z *Fmpz) IsProbabPrimeBPSW() int

IsProbabPrimeBPSW performs a Baillie-PSW probable prime test with parameters chosen by Selfridge's method A as per [4]. Return 1 if z is a Lucas probable prime, otherwise return 0. There are no known composites passed as prime by this test, though infinitely many probably exist. The test will declare no primes composite.

func (*Fmpz) IsProbabPrimeLucas

func (z *Fmpz) IsProbabPrimeLucas() int

IsProbabPrimeLucas performs a Lucas probable prime test with parameters chosen by Selfridge's method A as per [4]. Return 1 if z is a Lucas probable prime, otherwise return 0. This function declares some composites probably prime, but no primes composite.

func (*Fmpz) IsProbabPrimePseudosquare

func (z *Fmpz) IsProbabPrimePseudosquare() int

IsProbabPrimePseudosquare returns 0 is z is composite. If z is too large (greater than about 94 bits) the function fails silently and returns −1, otherwise, if z is proven prime by the pseudosquares method, return 1. Tests if z is a prime according to [28, Theorem 2.7]. We first factor N using trial division up to some limit B. In fact, the number of primes used in the trial factoring is at most FLINT_PSEUDOSQUARES_CUTOFF. Next we compute N/B and find the next pseudosquare Lp above this value, using a static table as per http://research.att.com/~njas/sequences/b002189.txt. As noted in the text, if p is prime then Step 3 will pass. This test rejects many composites, and so by this time we suspect that p is prime. If N is 3 or 7 modulo 8, we are done, and N is prime. We now run a probable prime test, for which no known counterexamples are known, to reject any composites. We then proceed to prove N prime by executing Step 4. In the case that N is 1 modulo 8, if Step 4 fails, we extend the number of primes pi at Step 3 and hope to find one which passes Step 4. We take the test one past the largest p for which we have pseudosquares Lp tabulated, as this already corresponds to the next Lp which is bigger than 264 and hence larger than any prime we might be testing. As explained in the text, Condition 4 cannot fail if N is prime. The possibility exists that the probable prime test declares a composite prime. However in that case an error is printed, as that would be of independent interest.

func (*Fmpz) IsStrongProbabPrime

func (z *Fmpz) IsStrongProbabPrime(a *Fmpz) int

IsStrongProbabPrime returns 1 if z is a strong probable prime to base a, otherwise it returns 0

func (*Fmpz) IsZero

func (z *Fmpz) IsZero() bool

IsZero returns true if z == 0.

func (*Fmpz) Jacobi

func (z *Fmpz) Jacobi(p *Fmpz) int

Jacobi computes the Jacobi symbol of a modulo p, where p is a prime and a is reduced modulo p

func (*Fmpz) Lcm

func (z *Fmpz) Lcm(g, h *Fmpz) *Fmpz

Lcm sets f to the least common multiple of g and h. The result is always nonnegative, even if one of g and h is negative.

func (*Fmpz) Lsh

func (z *Fmpz) Lsh(bits int) *Fmpz

Lsh left shifts an Fmpz z by an arbitrary number of bits and returns it.

func (*Fmpz) LucasChain

func (z *Fmpz) LucasChain(v2, a, m, n *Fmpz)

LucasChain Given V0 = 2, V1 = A compute Vm, Vm+1 (mod n) from the recurrences Vj = AVj−1 − Vj−2 (mod n).

func (*Fmpz) Max

func (z *Fmpz) Max(a, b *Fmpz) *Fmpz

Max finds the max(a, b) sets z to it and returns it.

func (*Fmpz) Min

func (z *Fmpz) Min(a, b *Fmpz) *Fmpz

Min finds the min(a, b) sets z to it and returns it.

func (*Fmpz) Mod

func (z *Fmpz) Mod(x, y *Fmpz) *Fmpz

Mod sets z to the modulus x%y for y != 0 and returns z.

func (*Fmpz) ModInverse

func (z *Fmpz) ModInverse(x, y *Fmpz) *Fmpz

ModInverse sets z to the inverse of x modulo y and returns z. The value of y may not be 0 otherwise an exception results. If the inverse exists the return value will be non-zero, otherwise the return value will be 0 and the value of f undefined.

func (*Fmpz) ModRational

func (z *Fmpz) ModRational(x *Fmpq, n *Fmpz) int

ModRational sets z to the residue of x = n/d (num, den) modulo n and returns 1 if such a residue exists otherwise 0.

func (*Fmpz) ModZ

func (z *Fmpz) ModZ(y *Fmpz) *Fmpz

ModZ sets z to the modulus z%y for y != 0 and returns z.

func (*Fmpz) Mul

func (z *Fmpz) Mul(x, y *Fmpz) *Fmpz

Mul sets z to the product x*y and returns z.

func (*Fmpz) MulI

func (z *Fmpz) MulI(x int) *Fmpz

MulI sets z to the product of z * x where x is an int type and returns z.

func (*Fmpz) MulZ

func (z *Fmpz) MulZ(x *Fmpz) *Fmpz

MulZ sets z to the product of z * x and returns z.

func (*Fmpz) Neg

func (z *Fmpz) Neg(x *Fmpz) *Fmpz

Neg sets z to -x and returns z.

func (*Fmpz) NegMod

func (z *Fmpz) NegMod(x, y *Fmpz) *Fmpz

NegMod Sets z to −x (mod y), assuming x is reduced modulo y.

func (*Fmpz) Pow

func (z *Fmpz) Pow(x, y, m *Fmpz) *Fmpz

Pow is a wrapper for Exp.

func (*Fmpz) Quo

func (z *Fmpz) Quo(x, y *Fmpz) *Fmpz

Quo sets z to the quotient x/y for y != 0 and returns z. If y == 0, a division-by-zero run-time panic occurs. Quo implements truncated division (like Go); see QuoRem for more details.

func (*Fmpz) QuoRem

func (z *Fmpz) QuoRem(x, y, r *Fmpz) (*Fmpz, *Fmpz)

QuoRem sets z to the quotient x/y and r to the remainder x%y and returns the pair (z, r) for y != 0. If y == 0, a division-by-zero run-time panic occurs.

QuoRem implements T-division and modulus (like Go):

q = x/y      with the result truncated to zero
r = x - y*q

(See Daan Leijen, “Division and Modulus for Computer Scientists”.) See DivMod for Euclidean division and modulus (unlike Go).

func (*Fmpz) Randm

func (z *Fmpz) Randm(state *FlintRandT, m *Fmpz) *Fmpz

Randm sets z to a random integer between 0 and m-1 inclusive.

func (*Fmpz) Root

func (z *Fmpz) Root(x *Fmpz, y int32) *Fmpz

Root sets x to the truncated integer part of the yth root of x

func (*Fmpz) Rsh

func (z *Fmpz) Rsh(bits int) *Fmpz

Rsh right shifts an Fmpz z by an arbitrary number of bits and returns it.

func (*Fmpz) Set

func (z *Fmpz) Set(x *Fmpz) *Fmpz

Set sets z to x and returns z.

func (*Fmpz) SetBytes

func (z *Fmpz) SetBytes(buf []byte) *Fmpz

SetBytes interprets buf as the bytes of a big-endian unsigned integer, sets z to that value, and returns z.

func (*Fmpz) SetInt64

func (z *Fmpz) SetInt64(x int64) *Fmpz

SetInt64 sets z to x and returns z.

func (*Fmpz) SetInt64NF

func (z *Fmpz) SetInt64NF(x int64) *Fmpz

SetInt64NF sets z to x and returns z without setting a Finalizer. This is a hack to help debug double frees in Flint.

func (*Fmpz) SetMpz

func (z *Fmpz) SetMpz(x *Mpz)

SetMpz transform x into an Fmpz z.

func (*Fmpz) SetString

func (z *Fmpz) SetString(s string, base int) (*Fmpz, bool)

SetString sets z to the value of s, interpreted in the given base, and returns z and a boolean indicating success. If SetString fails, the value of z is undefined but the returned value is nil.

The base argument must be 0 or a value from 2 through MaxBase. If the base is 0, the string prefix determines the actual conversion base. A prefix of “0x” or “0X” selects base 16; the “0” prefix selects base 8, and a “0b” or “0B” prefix selects base 2. Otherwise the selected base is 10.

func (*Fmpz) SetUint64

func (z *Fmpz) SetUint64(x uint64) *Fmpz

SetUint64 sets z to x and returns z.

func (*Fmpz) Sign

func (z *Fmpz) Sign() int

Sign returns:

-1 if x <  0
 0 if x == 0
+1 if x >  0

func (*Fmpz) Sqrt

func (z *Fmpz) Sqrt(x *Fmpz) *Fmpz

Sqrt sets x to the truncated integer part of the square root of x

func (*Fmpz) Square

func (z *Fmpz) Square() *Fmpz

Square raises z to the power of 2 and returns z.

func (*Fmpz) String

func (z *Fmpz) String() string

String returns the decimal representation of z.

func (*Fmpz) Sub

func (z *Fmpz) Sub(x, y *Fmpz) *Fmpz

Sub sets z to the difference x-y and returns z.

func (*Fmpz) SubI

func (z *Fmpz) SubI(x int) *Fmpz

SubI sets z to the difference z-x where x is an int type and returns z.

func (*Fmpz) SubZ

func (z *Fmpz) SubZ(x *Fmpz) *Fmpz

SubZ sets z to the difference z-x and returns z.

func (*Fmpz) TstBit

func (z *Fmpz) TstBit(i int) int

TstBit tests bit index i of z and return 0 or 1, accordingly.

func (*Fmpz) Uint64

func (z *Fmpz) Uint64() (y uint64)

Uint64 returns the uint64 representation of z. If z cannot be represented in a uint64, the result is undefined.

func (*Fmpz) Xor

func (z *Fmpz) Xor(a, b *Fmpz) *Fmpz

Xor sets z to the bitwise exclusive or of a and b and returns z.

type FmpzLLL

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

FmpzLLL stores a LLL matrix reduction context including delta, eta, rt and gt values.

func NewFmpzLLL

func NewFmpzLLL() *FmpzLLL

type FmpzMat

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

FmpzMat is a matrix of Fmpz.

func NewFmpzMat

func NewFmpzMat(rows, cols int) *FmpzMat

NewFmpzMat allocates a rows * cols matrix and returns a new FmpzMat.

func NewFmpzMatNF

func NewFmpzMatNF(rows, cols int) *FmpzMat

NewFmpzMatNF allocates a rows * cols matrix and returns a new FmpzMat.

func (*FmpzMat) Entry

func (m *FmpzMat) Entry(x, y int) *Fmpz

Entry returns the value at x, y in the matrix m.

func (*FmpzMat) LLL

func (m *FmpzMat) LLL() *FmpzMat

LLL reduces m in place according to the parameters specified by the default LLL context of fl->delta, fl->eta, fl->rt and fl->gt set to 0.99, 0.51, ZBASIS and APPROX respectively. u is the matrix used to capture the unimodular transformations if it is not NULL.

func (*FmpzMat) NumCols

func (m *FmpzMat) NumCols() int

NumCols returns the number of cols in a FmpzMat matrix.

func (*FmpzMat) NumRows

func (m *FmpzMat) NumRows() int

NumRows returns the number of rows in a FmpzMat matrix.

func (*FmpzMat) One

func (m *FmpzMat) One() *FmpzMat

One sets diagonal values of matrix m to 1 and returns m.

func (*FmpzMat) SetPosVal

func (m *FmpzMat) SetPosVal(val *Fmpz, pos int) *FmpzMat

SetPosVal sets position pos in matrix m to val and returns m.

func (*FmpzMat) SetVal

func (m *FmpzMat) SetVal(val *Fmpz, x, y int) *FmpzMat

SetVal sets position x, y in matrix m to val and returns m.

func (*FmpzMat) String

func (m *FmpzMat) String() string

func (*FmpzMat) Zero

func (m *FmpzMat) Zero() *FmpzMat

Zero sets all values of matrix m to zero and returns m.

type FmpzModCtx

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

func NewFmpzModCtx

func NewFmpzModCtx(n *Fmpz) *FmpzModCtx

NewFmpzModCtx allocates a new FmpzModCtx with modulus n and returns it.

func NewFmpzModCtxNF

func NewFmpzModCtxNF(n *Fmpz) *FmpzModCtx

NewFmpzModCtxNF allocates a new FmpzModCtx with modulus n and returns it.

type FmpzModPoly

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

FmpzModPoly type represents elements of Z/nZ[x] for a fixed modulus n.

func NewFmpzModPoly

func NewFmpzModPoly(n *FmpzModCtx) *FmpzModPoly

NewFmpzModPoly allocates a new FmpzModPoly mod n and returns it.

func NewFmpzModPoly2

func NewFmpzModPoly2(n *FmpzModCtx, a int) *FmpzModPoly

NewFmpzModPoly2 allocates a new FmpzModPoly mod n with at least a coefficients and returns it.

func NewFmpzModPolyNF

func NewFmpzModPolyNF(n *FmpzModCtx) *FmpzModPoly

NewFmpzModPolyNF allocates a new FmpzModPoly mod n and returns it.

func SetString

func SetString(poly string) (*FmpzModPoly, error)

SetString returns a polynomial in mod n using the string representation as the definition. e.g. "4 6 1 2 0 5" produces 5x3+2x+1 in (Z/6Z)[x].

func (*FmpzModPoly) Add

func (z *FmpzModPoly) Add(a, b *FmpzModPoly) *FmpzModPoly

Add sets z = a + b and returns z.

func (*FmpzModPoly) DivRem

func (z *FmpzModPoly) DivRem(m *FmpzModPoly) (*FmpzModPoly, *FmpzModPoly)

DivRem computes q, r such that z=mq+r and 0 ≤ len(r) < len(m).

func (*FmpzModPoly) DivScalar

func (z *FmpzModPoly) DivScalar(a *FmpzModPoly, x *Fmpz) *FmpzModPoly

DivScalar sets z = a / x where x is an Fmpz.

func (*FmpzModPoly) Equal

func (z *FmpzModPoly) Equal(p *FmpzModPoly) bool

Equal returns true if z is equal to p otherwise false.

func (*FmpzModPoly) FitLength

func (z *FmpzModPoly) FitLength(l int)

FitLength sets the number of coefficiets in z to l.

func (*FmpzModPoly) GCD

func (z *FmpzModPoly) GCD(a, b *FmpzModPoly) *FmpzModPoly

GCD sets z = gcd(a, b) and returns

func (*FmpzModPoly) GetCoeff

func (z *FmpzModPoly) GetCoeff(c int) *Fmpz

GetCoeff gets the c'th coefficient of z and returns an Fmpz.

func (*FmpzModPoly) GetCoeffs

func (z *FmpzModPoly) GetCoeffs() []*Fmpz

GetCoeffs gets all of the coefficient of z and returns a slice of Fmpz.

func (*FmpzModPoly) GetMod

func (z *FmpzModPoly) GetMod() *Fmpz

GetMod gets the modulus of z and returns an Fmpz.

func (*FmpzModPoly) Len

func (z *FmpzModPoly) Len() int

Len returns the length of the poly z.

func (*FmpzModPoly) Mul

func (z *FmpzModPoly) Mul(a, b *FmpzModPoly) *FmpzModPoly

Mul sets z = a * b and returns z.

func (*FmpzModPoly) MulScalar

func (z *FmpzModPoly) MulScalar(a *FmpzModPoly, x *Fmpz) *FmpzModPoly

MulScalar sets z = a * x where x is an Fmpz.

func (*FmpzModPoly) Neg

func (z *FmpzModPoly) Neg(p *FmpzModPoly) *FmpzModPoly

Neg sets z to the negative of p and returns z.

func (*FmpzModPoly) Pow

func (z *FmpzModPoly) Pow(m *FmpzModPoly, e int) *FmpzModPoly

Pow sets z to m^e and returns z.

func (*FmpzModPoly) Set

func (z *FmpzModPoly) Set(poly *FmpzModPoly) *FmpzModPoly

Set sets z to poly and returns z.

func (*FmpzModPoly) SetCoeff

func (z *FmpzModPoly) SetCoeff(c int, x *Fmpz) *FmpzModPoly

SetCoeff sets the c'th coefficient of z to x where x is an Fmpz and returns z.

func (*FmpzModPoly) SetCoeffUI

func (z *FmpzModPoly) SetCoeffUI(c int, x uint) *FmpzModPoly

SetCoeffUI sets the c'th coefficient of z to x where x is an uint and returns z.

func (*FmpzModPoly) String

func (z *FmpzModPoly) String() string

String returns a string representation of the polynomial.

func (*FmpzModPoly) StringSimple

func (z *FmpzModPoly) StringSimple() string

StringSimple returns a simple string representation of the polynomials length, modulus and coefficients. e.g. f(x)=5x^3+2x+1 in (Z/6Z)[x] is "4 6 1 2 0 5"

func (*FmpzModPoly) Sub

func (z *FmpzModPoly) Sub(a, b *FmpzModPoly) *FmpzModPoly

Sub sets z = a - b and returns z.

func (*FmpzModPoly) Zero

func (z *FmpzModPoly) Zero() *FmpzModPoly

Zero sets z to the zero polynomial and returns z.

type FmpzPoly

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

FmpzPoly type represents a univariate polynomial over the integers.

func FmpzPolySetString

func FmpzPolySetString(poly string) (*FmpzPoly, error)

FmpzPolySetString returns a polynomial using the string representation as the definition. e.g. "4 1 2 0 5" produces 5x3+2x+1.

func NewFmpzPoly

func NewFmpzPoly() *FmpzPoly

NewFmpzPoly allocates a new FmpzPoly and returns it.

func NewFmpzPoly2

func NewFmpzPoly2(a int) *FmpzPoly

NewFmpzPoly2 allocates a new FmpzPoly with at least a coefficients and returns it.

func NewFmpzPolyNF

func NewFmpzPolyNF() *FmpzPoly

NewFmpzPolyNF allocates a new FmpzPoly and returns it.

func (*FmpzPoly) Add

func (z *FmpzPoly) Add(a, b *FmpzPoly) *FmpzPoly

Add sets z = a + b and returns z.

func (*FmpzPoly) DivRem

func (z *FmpzPoly) DivRem(m *FmpzPoly) (*FmpzPoly, *FmpzPoly)

DivRem computes q, r such that z=mq+r and 0 ≤ len(r) < len(m).

func (*FmpzPoly) DivScalar

func (z *FmpzPoly) DivScalar(a *FmpzPoly, x *Fmpz) *FmpzPoly

DivScalar sets z = a / x where x is an Fmpz. Rounding coefficients down toward -infinity.

func (*FmpzPoly) Equal

func (z *FmpzPoly) Equal(p *FmpzPoly) bool

Equal returns true if z is equal to p otherwise false.

func (*FmpzPoly) Factor

func (z *FmpzPoly) Factor() *FmpzPolyFactor

Factor uses the Zassenhaus factoring algorithm, which takes as input any FmpzPoly z, and returns a factorization in an FmpzPolyFac type.

func (*FmpzPoly) FitLength

func (z *FmpzPoly) FitLength(l int)

FitLength sets the number of coefficiets in z to l.

func (*FmpzPoly) GCD

func (z *FmpzPoly) GCD(a, b *FmpzPoly) *FmpzPoly

GCD sets z = gcd(a, b) and returns

func (*FmpzPoly) GetCoeff

func (z *FmpzPoly) GetCoeff(c int) *Fmpz

GetCoeff gets the c'th coefficient of z and returns an Fmpz.

func (*FmpzPoly) GetCoeffs

func (z *FmpzPoly) GetCoeffs() []*Fmpz

GetCoeffs gets all of the coefficient of z and returns a slice of Fmpz.

func (*FmpzPoly) Len

func (z *FmpzPoly) Len() int

Len returns the length of the poly z.

func (*FmpzPoly) Mul

func (z *FmpzPoly) Mul(a, b *FmpzPoly) *FmpzPoly

Mul sets z = a * b and returns z.

func (*FmpzPoly) MulScalar

func (z *FmpzPoly) MulScalar(a *FmpzPoly, x *Fmpz) *FmpzPoly

MulScalar sets z = a * x where x is an Fmpz.

func (*FmpzPoly) Neg

func (z *FmpzPoly) Neg(p *FmpzPoly) *FmpzPoly

Neg sets z to the negative of p and returns z.

func (*FmpzPoly) Pow

func (z *FmpzPoly) Pow(m *FmpzPoly, e int) *FmpzPoly

Pow sets z to m^e and returns z.

func (*FmpzPoly) Set

func (z *FmpzPoly) Set(poly *FmpzPoly) *FmpzPoly

Set sets z to poly and returns z.

func (*FmpzPoly) SetCoeff

func (z *FmpzPoly) SetCoeff(c int, x *Fmpz) *FmpzPoly

SetCoeff sets the c'th coefficient of z to x where x is an Fmpz and returns z.

func (*FmpzPoly) SetCoeffUI

func (z *FmpzPoly) SetCoeffUI(c int, x uint) *FmpzPoly

SetCoeffUI sets the c'th coefficient of z to x where x is an uint and returns z.

func (*FmpzPoly) String

func (z *FmpzPoly) String() string

String returns a string representation of the polynomial.

func (*FmpzPoly) StringSimple

func (z *FmpzPoly) StringSimple() string

StringSimple returns a simple string representation of the polynomials length and coefficients. e.g. f(x)=5x^3+2x+1 is "4 1 2 0 5"

func (*FmpzPoly) Sub

func (z *FmpzPoly) Sub(a, b *FmpzPoly) *FmpzPoly

Sub sets z = a - b and returns z.

func (*FmpzPoly) Zero

func (z *FmpzPoly) Zero() *FmpzPoly

Zero sets z to the zero polynomial and returns z.

type FmpzPolyFactor

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

FmpzPolyFactor type represents the factors univariate polynomial over the integers.

func NewFmpzPolyFactor

func NewFmpzPolyFactor() *FmpzPolyFactor

NewFmpzPolyFactor allocates a new FmpzPolyFactor and returns it.

func (*FmpzPolyFactor) GetCoeff

func (f *FmpzPolyFactor) GetCoeff() *Fmpz

GetCoeff gets the coefficient from the FmpzPolyFactor.

func (*FmpzPolyFactor) GetExp

func (f *FmpzPolyFactor) GetExp(n int) int

GetExp gets the exponent of the nth polynomial from the FmpzPolyFactor.

func (*FmpzPolyFactor) GetPoly

func (f *FmpzPolyFactor) GetPoly(n int) *FmpzPoly

GetPoly gets the nth polynomial factor from a FmpzPolyFactor and returns it.

func (*FmpzPolyFactor) GetPolyNF

func (f *FmpzPolyFactor) GetPolyNF(n int) *FmpzPoly

GetPoly gets the nth polynomial factor from a FmpzPolyFactor and returns it.

func (*FmpzPolyFactor) Len

func (f *FmpzPolyFactor) Len() int

Len gets the length of the FmpzPolyFactors list. i.e. the number of factors found.

func (*FmpzPolyFactor) Print

func (f *FmpzPolyFactor) Print()

Print prints the FmpzPolyFactor to stdout.

func (*FmpzPolyFactor) Set

Set sets f to FmpzPolyFactor fac and returns f.

type MpLimb

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

MpLimb type is a mp_limb_t which is a type alias for ulong which in go is a uint64.

func NewMpLimb

func NewMpLimb(x uint64) *MpLimb

NewMpLimb returns a new MpLimb type from a uint64.

type Mpz

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

Mpz is an abitrary size integer type from the Gnu Multiprecision Library.

func NewMpz

func NewMpz(x int64) *Mpz

NewMpz allocates and returns a new Fmpz set to x.

func (*Mpz) Cmp

func (z *Mpz) Cmp(y *Mpz) (r int)

Cmp compares Mpz z and y and returns:

-1 if z <  y
 0 if z == y
+1 if z >  y

func (*Mpz) DivMod

func (z *Mpz) DivMod(x, y, m *Mpz) (*Mpz, *Mpz)

DivMod sets z to the quotient x div y and m to the modulus x mod y and returns the pair (z, m) for y != 0.

func (*Mpz) GetMpz

func (z *Mpz) GetMpz(x *Fmpz)

GetMpz transform x into an Mpz z.

func (*Mpz) MulRMpz

func (z *Mpz) MulRMpz(y, n *Mpz) *Mpz

MulRMpz sets z to the product of z and y modulo n and returns z using Mpz types.

func (*Mpz) SetMpzInt64

func (z *Mpz) SetMpzInt64(x int64) *Mpz

SetMpzInt64 sets z to x and returns z.

func (*Mpz) String

func (z *Mpz) String() string

String returns the decimal representation of z.

func (*Mpz) SubRMpz

func (z *Mpz) SubRMpz(y, n *Mpz) *Mpz

SubRMpz sets z to the z -y modulo n and returns z using Mpz types.

type NmodPoly

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

NmodPoly type represents elements of Z/nZ[x] for a fixed modulus n.

Jump to

Keyboard shortcuts

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