mathx

package module
v0.0.0-...-8e30817 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2024 License: MIT Imports: 6 Imported by: 0

README

mathx

build-img pkg-img reportcard-img coverage-img version-img

TODO

Features

  • Simple API.
  • Dependency-free.
  • Clean and tested code.

Install

Go version 1.17+

go get github.com/cristalhq/mathx

Example

Also see examples: examples_test.go.

Documentation

See these docs.

License

MIT License.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DoubleZero   = Double{/* contains filtered or unexported fields */}
	DoubleOne    = Double{/* contains filtered or unexported fields */}
	DoubleInf    = Double{/* contains filtered or unexported fields */}
	DoubleNegInf = Double{/* contains filtered or unexported fields */}
	DoubleNaN    = Double{/* contains filtered or unexported fields */}
	DoublePi     = Double{/* contains filtered or unexported fields */}
	DoubleTau    = Double{/* contains filtered or unexported fields */}
	DoubleE      = Double{/* contains filtered or unexported fields */}
	DoubleLog2   = Double{/* contains filtered or unexported fields */}
	DoublePhi    = Double{/* contains filtered or unexported fields */}
)

Double constants

View Source
var (
	InfNeg = math.Inf(-1)
	InfPos = math.Inf(+1)
	NaN    = math.NaN()
)

Functions

This section is empty.

Types

type Double

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

Double float by T.J. Dekker.

See: Dekker, T.J. A floating-point technique for extending the available precision. Numer. Math. 18, 224–242 (1971). https://doi.org/10.1007/BF01397083

func Cosh2

func Cosh2(x Double) Double

func DoubleFromFloat

func DoubleFromFloat(x float64) Double

func DoubleFromMul

func DoubleFromMul(a, b float64) Double

func DoubleFromSqr

func DoubleFromSqr(x float64) Double

func DoubleFromSum

func DoubleFromSum(a, b float64) Double

func Exp

func Exp(x Double) Double

e ** x

func Ln2

func Ln2(x Double) Double

func Pow22

func Pow22(base Double, exp Double) Double

func Sinh2

func Sinh2(x Double) Double

func Sqr2

func Sqr2(x Double) Double

x ** 2

func Sqrt2

func Sqrt2(x Double) Double

x ** 0.5

func (Double) Abs

func (d Double) Abs() Double

func (Double) Add

func (d Double) Add(x Double) Double

func (Double) Div

func (d Double) Div(x Double) Double

func (Double) Equal

func (d Double) Equal(x Double) bool

func (Double) GE

func (d Double) GE(x Double) bool

func (Double) GT

func (d Double) GT(x Double) bool

func (Double) Inv

func (d Double) Inv() Double

func (Double) LE

func (d Double) LE(x Double) bool

func (Double) LT

func (d Double) LT(x Double) bool

func (Double) Mul

func (d Double) Mul(x Double) Double

func (Double) Neg

func (d Double) Neg() Double

func (Double) Sqr

func (d Double) Sqr() Double

func (Double) Sub

func (d Double) Sub(x Double) Double

func (Double) ToFloat64

func (d Double) ToFloat64() float64

type Histogram

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

Histogram for floats. Based on https://github.com/valyala/histogram with small changes.

func MergeHistograms

func MergeHistograms(hs []*Histogram) *Histogram

MergeHistograms returns 1 histogram built from the given.

func NewHistogram

func NewHistogram() *Histogram

NewHistogram returns new Histogram histogram.

func (*Histogram) Quantile

func (h *Histogram) Quantile(phi float64) float64

Quantile returns the quantile value for the given phi.

func (*Histogram) Quantiles

func (h *Histogram) Quantiles(dst, phis []float64) []float64

Quantiles appends quantile values to dst for the given phis.

func (*Histogram) Reset

func (h *Histogram) Reset()

Reset resets the histogram.

func (*Histogram) Update

func (h *Histogram) Update(v float64)

Update the histogram with v.

type Uint128

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

Uint128 represents a uint128 using 2 uint64.

func NewUint128

func NewUint128(hi, lo uint64) Uint128

func Uint128FromString

func Uint128FromString(s string) (Uint128, error)

func Uint128FromUint64

func Uint128FromUint64(v uint64) Uint128

func (Uint128) Add

func (u Uint128) Add(x Uint128) Uint128

func (Uint128) AddCarry

func (u Uint128) AddCarry(x Uint128, carry uint64) (Uint128, uint64)

func (Uint128) And

func (u Uint128) And(x Uint128) Uint128

func (Uint128) Big

func (u Uint128) Big() *big.Int

func (Uint128) Cmp

func (u Uint128) Cmp(x Uint128) int

func (Uint128) Dec

func (u Uint128) Dec() Uint128

func (Uint128) Equals

func (u Uint128) Equals(x Uint128) bool

func (Uint128) Inc

func (u Uint128) Inc() Uint128

func (Uint128) IsZero

func (u Uint128) IsZero() bool

func (Uint128) Lsh

func (u Uint128) Lsh(n uint) Uint128

func (Uint128) Mul

func (u Uint128) Mul(x Uint128) Uint128

func (Uint128) MulFull

func (a Uint128) MulFull(b Uint128) (Uint128, Uint128)

multiply 128-bit unsigned integers and return high and lower product

func (Uint128) Not

func (u Uint128) Not() Uint128

func (Uint128) Or

func (u Uint128) Or(x Uint128) Uint128

func (Uint128) Parts

func (u Uint128) Parts() (uint64, uint64)

func (Uint128) Rsh

func (u Uint128) Rsh(n uint) Uint128

func (Uint128) String

func (u Uint128) String() string

func (Uint128) Sub

func (u Uint128) Sub(x Uint128) Uint128

func (Uint128) SubBorrow

func (u Uint128) SubBorrow(x Uint128, borrow uint64) (Uint128, uint64)

func (Uint128) Xor

func (u Uint128) Xor(x Uint128) Uint128

type Uint256

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

Uint256 represents a uint256 using 2 uint64.

func NewUint256

func NewUint256(hi, lo Uint128) Uint256

func Uint256FromUint64

func Uint256FromUint64(v uint64) Uint256

func (Uint256) Add

func (u Uint256) Add(x Uint256) Uint256

func (Uint256) AddCarry

func (u Uint256) AddCarry(x Uint256, carry uint64) (Uint256, uint64)

func (Uint256) And

func (u Uint256) And(x Uint256) Uint256

func (Uint256) Big

func (u Uint256) Big() *big.Int

func (Uint256) Cmp

func (u Uint256) Cmp(x Uint256) int

func (Uint256) Dec

func (u Uint256) Dec() Uint256

func (Uint256) Equals

func (u Uint256) Equals(x Uint256) bool

func (Uint256) Inc

func (u Uint256) Inc() Uint256

func (Uint256) IsZero

func (u Uint256) IsZero() bool

func (Uint256) Lsh

func (u Uint256) Lsh(n uint) Uint256

func (Uint256) Mul

func (u Uint256) Mul(v Uint256) Uint256

func (Uint256) MulFull

func (u Uint256) MulFull(x Uint256) (Uint256, Uint256)

func (Uint256) Not

func (u Uint256) Not() Uint256

func (Uint256) Or

func (u Uint256) Or(x Uint256) Uint256

func (Uint256) Parts

func (u Uint256) Parts() (Uint128, Uint128)

func (Uint256) Rsh

func (u Uint256) Rsh(n uint) Uint256

func (Uint256) String

func (u Uint256) String() string

func (Uint256) Sub

func (u Uint256) Sub(x Uint256) Uint256

func (Uint256) SubBorrow

func (u Uint256) SubBorrow(x Uint256, borrow uint64) (Uint256, uint64)

func (Uint256) Xor

func (u Uint256) Xor(x Uint256) Uint256

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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