math

package
v1.2.31 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2024 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ZERO  = NewInt(0)
	ONE   = NewInt(1)
	TWO   = NewInt(2)
	THREE = NewInt(3)
	FOUR  = NewInt(4)
	FIVE  = NewInt(5)
	SIX   = NewInt(6)
	SEVEN = NewInt(7)
	EIGHT = NewInt(8)
)

Number constants

Functions

This section is empty.

Types

type Field

type Field []complex128

Field instances are input/output objects for transformation methods.

type Int

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

Int is an integer of arbitrary size

func NewInt

func NewInt(v int64) *Int

NewInt returns a new Int from an intrinsic int64

func NewIntFromBig

func NewIntFromBig(i *big.Int) *Int

NewIntFromBig creates a new Int from a *big.Int.

func NewIntFromBytes

func NewIntFromBytes(buf []byte) *Int

NewIntFromBytes converts a binary array into an unsigned integer.

func NewIntFromHex

func NewIntFromHex(s string) *Int

NewIntFromHex converts a hexadecimal string into an unsigned integer.

func NewIntFromString

func NewIntFromString(s string) *Int

NewIntFromString converts a string representation of an integer

func NewIntRnd

func NewIntRnd(j *Int) *Int

NewIntRnd creates a new random value between [0,j[

func NewIntRndBits

func NewIntRndBits(n int) *Int

NewIntRndBits creates a new random value with a max. bitlength.

func NewIntRndPrime

func NewIntRndPrime(j *Int) *Int

NewIntRndPrime generates a new random prime number between [0,j[

func NewIntRndPrimeBits

func NewIntRndPrimeBits(n int) *Int

NewIntRndPrimeBits generates a new random prime number with a maximum bitlength

func NewIntRndRange

func NewIntRndRange(lower, upper *Int) *Int

NewIntRndRange returns a random integer value within given range.

func SqrtModP

func SqrtModP(n, p *Int) (*Int, error)

SqrtModP computes the square root of a quadratic residue mod p It uses the Shanks-Tonelli algorithm to compute the square root see (http://en.wikipedia.org/wiki/Shanks%E2%80%93Tonelli_algorithm)

func (*Int) Abs

func (i *Int) Abs() *Int

Abs returns the unsigned value of an Int.

func (*Int) Add

func (i *Int) Add(j *Int) *Int

Add two Ints

func (*Int) Bit

func (i *Int) Bit(n int) uint

Bit returns the bit value of an Int at a given position.

func (*Int) BitLen

func (i *Int) BitLen() int

BitLen returns the number of bits in an Int.

func (*Int) Bytes

func (i *Int) Bytes() []byte

Bytes returns a byte array representation of the integer.

func (*Int) Cmp

func (i *Int) Cmp(j *Int) int

Cmp returns the comparison between two Ints.

func (*Int) Div

func (i *Int) Div(j *Int) *Int

Div divides two Int (no fraction)

func (*Int) DivMod

func (i *Int) DivMod(j *Int) (*Int, *Int)

DivMod returns the quotient and modulus of two Ints.

func (*Int) Equals

func (i *Int) Equals(j *Int) bool

Equals check if two Ints are equal.

func (*Int) ExtendedEuclid

func (i *Int) ExtendedEuclid(j *Int) [2]*Int

ExtendedEuclid computes the factors (x,y) for (a,b) where the following equation is satisfied: x*a + b*y = gcd(a,b)

func (*Int) FixedBytes

func (i *Int) FixedBytes(n int) []byte

FixedBytes returns a byte array representation of the integer of a given size.

func (*Int) GCD

func (i *Int) GCD(j *Int) *Int

GCD return the greatest common divisor of two Ints.

func (*Int) Int64

func (i *Int) Int64() int64

Int64 returns the int64 value of an Int.

func (*Int) LCM

func (i *Int) LCM(j *Int) *Int

LCM returns the least common multiplicative of two Ints.

func (*Int) Legendre

func (i *Int) Legendre(p *Int) int

Legendre computes (i\p)

func (*Int) Lsh

func (i *Int) Lsh(n uint) *Int

Lsh returns the left shifted value of an Int.

func (*Int) Mod

func (i *Int) Mod(j *Int) *Int

Mod returns the modulus of two Ints

func (*Int) ModInverse

func (i *Int) ModInverse(j *Int) *Int

ModInverse returns the multiplicative inverse of i in the ring ℤ/jℤ.

func (*Int) ModPow

func (i *Int) ModPow(n, m *Int) *Int

ModPow returns the modular exponentiation of an Int as (i^n mod m).

func (*Int) ModSign

func (i *Int) ModSign(j *Int) *Int

ModSign returns a signed modulus of two Ints.

func (*Int) Mul

func (i *Int) Mul(j *Int) *Int

Mul multiplies two Ints

func (*Int) Neg

func (i *Int) Neg() *Int

Neg flips the sign of an Int.

func (*Int) NthRoot

func (i *Int) NthRoot(n int, upper bool) *Int

NthRoot computes the n.th root of an Int. If upper is set, the result is raised to the next highest value.

func (*Int) Pow

func (i *Int) Pow(n int) *Int

Pow raises an Int to power n.

func (*Int) ProbablyPrime

func (i *Int) ProbablyPrime(n int) bool

ProbablyPrime checks if an Int is prime. The chances this is wrong are less than 2^(-n).

func (*Int) Rsh

func (i *Int) Rsh(n uint) *Int

Rsh returns the right shifted value of an Int.

func (*Int) SetBit

func (i *Int) SetBit(n int, v uint) *Int

SetBit sets the bit value of an Int at a given position.

func (*Int) Sign

func (i *Int) Sign() int

Sign returns the sign of an Int.

func (*Int) String

func (i *Int) String() string

String converts an Int to a string representation.

func (*Int) Sub

func (i *Int) Sub(j *Int) *Int

Sub subtracts two Ints

type Transformer

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

Transformer type declaration (worker object for FF transformations).

func NewTransformer

func NewTransformer(n int) (*Transformer, error)

NewTransformer creates a new transformer worker instance.

func (*Transformer) Freq2Time

func (t *Transformer) Freq2Time(in Field) (Field, error)

Freq2Time transforms a frequency series into the time domain.

func (*Transformer) GetSize

func (t *Transformer) GetSize() int

GetSize returns the field size for a transformation worker instance.

func (*Transformer) Time2Freq

func (t *Transformer) Time2Freq(in Field) (Field, error)

Time2Freq transforms a time series into the frequency domain.

Jump to

Keyboard shortcuts

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