Rmath

package module
v0.0.0-...-4f3f782 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxFloat32             = 0x1p127 * (1 + (1 - 0x1p-23))
	SmallestNonzeroFloat32 = 0x1p-126 * 0x1p-23
	E                      = 2.71828182845904523536028747135266249775724709369995957496696763
	Pi                     = 3.14159265358979323846264338327950288419716939937510582097494459
	Phi                    = 1.61803398874989484820458683436563811772030917980576286213544862
	Sqrt2                  = 1.41421356237309504880168872420969807856967187537694807317667974  // https://oeis.org/A002193
	SqrtE                  = 1.64872127070012814684865078781416357165377610071014801157507931  // https://oeis.org/A019774
	SqrtPi                 = 1.77245385090551602729816748334114518279754945612238712821380779  // https://oeis.org/A002161
	SqrtPhi                = 1.27201964951406896425242246173749149171560804184009624861664038  // https://oeis.org/A139339
	Ln2                    = 0.693147180559945309417232121458176568075500134360255254120680009 // https://oeis.org/A002162
	Log2E                  = 1 / Ln2
	Ln10                   = 2.30258509299404568401799145468436420760110148862877297603332790 // https://oeis.org/A002392
	Log10E                 = 1 / Ln10
	MaxFloat64             = 0x1p1023 * (1 + (1 - 0x1p-52)) // 1.79769313486231570814527423731704356798070e+308
	SmallestNonzeroFloat64 = 0x1p-1022 * 0x1p-52            // 4.9406564584124654417656879286822137236505980e-324
	Sqrt2M1                = 4.142135623730950488017e-01    // Sqrt(2)-1 = 0x3fda827999fcef34
	Sqrt2HalfM1            = -2.928932188134524755992e-01   // Sqrt(2)/2-1 = 0xbfd2bec333018866
	Small                  = 1.0 / (1 << 29)                // 2**-29 = 0x3e20000000000000
	Tiny                   = 1.0 / (1 << 54)                // 2**-54
	Two53                  = 1 << 53                        // 2**53
	Ln2Hi                  = 6.93147180369123816490e-01     // 3fe62e42fee00000
	Ln2Lo                  = 1.90821492927058770002e-10     // 3dea39ef35793c76
	Lp1                    = 6.666666666666735130e-01       // 3FE5555555555593
	Lp2                    = 3.999999999940941908e-01       // 3FD999999997FA04
	Lp3                    = 2.857142874366239149e-01       // 3FD2492494229359
	Lp4                    = 2.222219843214978396e-01       // 3FCC71C51D8E78AF
	Lp5                    = 1.818357216161805012e-01       // 3FC7466496CB03DE
	Lp6                    = 1.531383769920937332e-01       // 3FC39A09D078C69F
	Lp7                    = 1.479819860511658591e-01       // 3FC2F112DF3E5244

)
View Source
const UintSize = uintSize

UintSize is the size of a uint in bits.

Variables

This section is empty.

Functions

func Mul32

func Mul32(x, y uint32) (hi, lo uint32)

Types

type ArbitraryType

type ArbitraryType int

ArbitraryType is here for the purposes of documentation only and is not actually part of the unsafe package. It represents the type of an arbitrary Go expression.

type IntegerType

type IntegerType int

IntegerType is here for the purposes of documentation only and is not actually part of the unsafe package. It represents any arbitrary integer type.

type Pointer

type Pointer *ArbitraryType

Pointer represents a pointer to an arbitrary type. There are four special operations

type RMath

type RMath struct {
}

func (*RMath) Abs

func (math *RMath) Abs(input float64) float64

Abs

func (*RMath) Acosh

func (math *RMath) Acosh(x float64) float64

func (*RMath) Add

func (math *RMath) Add(x, y, carry uint) (sum, carryOut uint)

Add returns the sum with carry of x, y and carry: sum = x + y + carry. The carry input must be 0 or 1; otherwise the behavior is undefined. The carryOut output is guaranteed to be 0 or 1.

This function's execution time does not depend on the inputs.

func (*RMath) Add32

func (math *RMath) Add32(x, y, carry uint32) (sum, carryOut uint32)

Add32 returns the sum with carry of x, y and carry: sum = x + y + carry. The carry input must be 0 or 1; otherwise the behavior is undefined. The carryOut output is guaranteed to be 0 or 1. This function's execution time does not depend on the inputs.

func (*RMath) Add64

func (math *RMath) Add64(x, y, carry uint64) (sum, carryOut uint64)

Add64 returns the sum with carry of x, y and carry: sum = x + y + carry. The carry input must be 0 or 1; otherwise the behavior is undefined. The carryOut output is guaranteed to be 0 or 1. This function's execution time does not depend on the inputs.

func (*RMath) Atan

func (math *RMath) Atan(x float64) float64

arctan

func (*RMath) Ceil

func (math *RMath) Ceil(input float64) int

Ceil

func (*RMath) Cos

func (math *RMath) Cos(input float64) float64

func (*RMath) Cot

func (math *RMath) Cot(input float64) float64

cot

func (*RMath) Cqrt

func (math *RMath) Cqrt(input float64) float64

find cqrt

func (*RMath) Div

func (math *RMath) Div(hi, lo, y uint) (quo, rem uint)

func (*RMath) Div32

func (math *RMath) Div32(hi, lo, y uint32) (quo, rem uint32)

Div32 returns the quotient and remainder of (hi, lo) divided by y: quo = (hi, lo)/y, rem = (hi, lo)%y with the dividend bits' upper half in parameter hi and the lower half in parameter lo. Div32 panics for y == 0 (division by zero) or y <= hi (quotient overflow).

func (*RMath) Div64

func (math *RMath) Div64(hi, lo, y uint64) (quo, rem uint64)

Div64 returns the quotient and remainder of (hi, lo) divided by y: quo = (hi, lo)/y, rem = (hi, lo)%y with the dividend bits' upper half in parameter hi and the lower half in parameter lo. Div64 panics for y == 0 (division by zero) or y <= hi (quotient overflow).

func (*RMath) FSBigNum

func (math *RMath) FSBigNum(input []float64) float64

big number in slice for float Numbers float-slice-big-number

func (*RMath) FSLittleNum

func (math *RMath) FSLittleNum(input []float64) float64

little number in slice for float Numbers float -slice-little-number

func (*RMath) Fact

func (math *RMath) Fact(input int) int

fact

func (*RMath) Fibo

func (math *RMath) Fibo(input int)

find fibo

func (*RMath) FindSlice

func (math *RMath) FindSlice(input interface{}, slice []interface{}) (bool, int, interface{})

func (*RMath) Float64bits

func (math *RMath) Float64bits(f float64) uint64

func (*RMath) Float64frombits

func (math *RMath) Float64frombits(b uint64) float64

func (*RMath) Floor

func (math *RMath) Floor(input float64) int

floor

func (*RMath) Fminus

func (math *RMath) Fminus(input ...float64) float64

multi minus for float numbers

func (*RMath) Fmulti

func (math *RMath) Fmulti(input ...float64) float64

multi Multiplication for float numbers

func (*RMath) Fsumer

func (math *RMath) Fsumer(input ...float64) float64

multi sum for float numbers

func (*RMath) ISBigNum

func (math *RMath) ISBigNum(input []int) int

big number in slice for int Numbers int-slice-big-number

func (*RMath) ISLittleNum

func (math *RMath) ISLittleNum(input []int) int

little number in slice for int Numbers int -slice-little-number

func (*RMath) Iminus

func (math *RMath) Iminus(input ...int) int

multi minus int numbers

func (*RMath) Imod

func (math *RMath) Imod(num int, num2 int) int

mod in int

func (*RMath) Imulti

func (math *RMath) Imulti(input ...int) int

multi Multiplication for Int numbers

func (*RMath) Inf

func (math *RMath) Inf(sign int) float64

//////////////////////////////////////////////////////////////////////////////////

func (*RMath) IsEvenOdd

func (math *RMath) IsEvenOdd(input int) bool

find even or odd

func (*RMath) IsInf

func (math *RMath) IsInf(f float64, sign int) bool

func (*RMath) IsNaN

func (math *RMath) IsNaN(f float64) (is bool)

func (*RMath) IsPrime

func (math *RMath) IsPrime(input int) bool

find prime number

func (*RMath) Isumer

func (math *RMath) Isumer(input ...int) int

multi sum for int numbers

func (*RMath) LeadingZeros

func (math *RMath) LeadingZeros(x uint) int

LeadingZeros returns the number of leading zero bits in x; the result is UintSize for x == 0.

func (*RMath) LeadingZeros16

func (math *RMath) LeadingZeros16(x uint16) int

LeadingZeros16 returns the number of leading zero bits in x; the result is 16 for x == 0.

func (*RMath) LeadingZeros32

func (math *RMath) LeadingZeros32(x uint32) int

LeadingZeros32 returns the number of leading zero bits in x; the result is 32 for x == 0.

func (*RMath) LeadingZeros64

func (math *RMath) LeadingZeros64(x uint64) int

LeadingZeros64 returns the number of leading zero bits in x; the result is 64 for x == 0.

func (*RMath) LeadingZeros8

func (math *RMath) LeadingZeros8(x uint8) int

LeadingZeros8 returns the number of leading zero bits in x; the result is 8 for x == 0.

func (*RMath) Len

func (math *RMath) Len(x uint) int

Len returns the minimum number of bits required to represent x; the result is 0 for x == 0.

func (*RMath) Len16

func (math *RMath) Len16(x uint16) (n int)

Len16 returns the minimum number of bits required to represent x; the result is 0 for x == 0.

func (*RMath) Len32

func (math *RMath) Len32(x uint32) (n int)

Len32 returns the minimum number of bits required to represent x; the result is 0 for x == 0.

func (*RMath) Len64

func (math *RMath) Len64(x uint64) (n int)

Len64 returns the minimum number of bits required to represent x; the result is 0 for x == 0.

func (*RMath) Len8

func (math *RMath) Len8(x uint8) int

Len8 returns the minimum number of bits required to represent x; the result is 0 for x == 0.

func (*RMath) Ln

func (math *RMath) Ln(input float64) float64

log

func (*RMath) Log10

func (math *RMath) Log10(input float64) float64

log 10

func (*RMath) Log1p

func (math *RMath) Log1p(x float64) float64

func (*RMath) Log2

func (math *RMath) Log2(input float64) float64

log 2

func (*RMath) Mul

func (math *RMath) Mul(x, y uint) (hi, lo uint)

Mul returns the full-width product of x and y: (hi, lo) = x * y with the product bits' upper half returned in hi and the lower half returned in lo. This function's execution time does not depend on the inputs.

func (*RMath) Mul64

func (math *RMath) Mul64(x, y uint64) (hi, lo uint64)

func (*RMath) NaN

func (math *RMath) NaN() float64

func (*RMath) OnesCount

func (math *RMath) OnesCount(x uint) int

OnesCount returns the number of one bits ("population count") in x.

func (*RMath) OnesCount16

func (math *RMath) OnesCount16(x uint16) int

OnesCount16 returns the number of one bits ("population count") in x.

func (*RMath) OnesCount32

func (math *RMath) OnesCount32(x uint32) int

OnesCount32 returns the number of one bits ("population count") in x.

func (*RMath) OnesCount64

func (math *RMath) OnesCount64(x uint64) int

OnesCount64 returns the number of one bits ("population count") in x.

func (*RMath) OnesCount8

func (math *RMath) OnesCount8(x uint8) int

OnesCount8 returns the number of one bits ("population count") in x.

func (*RMath) Pow

func (math *RMath) Pow(base float64, exponent int) float64

pow

func (*RMath) Rem

func (math *RMath) Rem(hi, lo, y uint) uint

Rem returns the remainder of (hi, lo) divided by y. Rem panics for y == 0 (division by zero) but, unlike Div, it doesn't panic on a quotient overflow.

func (*RMath) Rem32

func (math *RMath) Rem32(hi, lo, y uint32) uint32

Rem32 returns the remainder of (hi, lo) divided by y. Rem32 panics for y == 0 (division by zero) but, unlike Div32, it doesn't panic on a quotient overflow.

func (*RMath) Rem64

func (math *RMath) Rem64(hi, lo, y uint64) uint64

Rem64 returns the remainder of (hi, lo) divided by y. Rem64 panics for y == 0 (division by zero) but, unlike Div64, it doesn't panic on a quotient overflow.

func (*RMath) Reverse

func (math *RMath) Reverse(x uint) uint

--- Reverse --- Reverse returns the value of x with its bits in reversed order.

func (*RMath) Reverse16

func (math *RMath) Reverse16(x uint16) uint16

Reverse16 returns the value of x with its bits in reversed order.

func (*RMath) Reverse32

func (math *RMath) Reverse32(x uint32) uint32

Reverse32 returns the value of x with its bits in reversed order.

func (*RMath) Reverse64

func (math *RMath) Reverse64(x uint64) uint64

Reverse64 returns the value of x with its bits in reversed order.

func (*RMath) Reverse8

func (math *RMath) Reverse8(x uint8) uint8

Reverse8 returns the value of x with its bits in reversed order.

func (*RMath) ReverseBytes

func (math *RMath) ReverseBytes(x uint) uint

ReverseBytes returns the value of x with its bytes in reversed order.

This function's execution time does not depend on the inputs.

func (*RMath) ReverseBytes16

func (math *RMath) ReverseBytes16(x uint16) uint16

ReverseBytes16 returns the value of x with its bytes in reversed order.

This function's execution time does not depend on the inputs.

func (*RMath) ReverseBytes32

func (math *RMath) ReverseBytes32(x uint32) uint32

ReverseBytes32 returns the value of x with its bytes in reversed order.

This function's execution time does not depend on the inputs.

func (*RMath) ReverseBytes64

func (math *RMath) ReverseBytes64(x uint64) uint64

ReverseBytes64 returns the value of x with its bytes in reversed order.

This function's execution time does not depend on the inputs.

func (*RMath) Reverser

func (math *RMath) Reverser(input int) (sum int, count int, ave float64)

reverse of mum + sum + count of nums +avarage

func (*RMath) RotateLeft

func (math *RMath) RotateLeft(x uint, k int) uint

RotateLeft returns the value of x rotated left by (k mod UintSize) bits. To rotate x right by k bits, call RotateLeft(x, -k). This function's execution time does not depend on the inputs.

func (*RMath) RotateLeft16

func (math *RMath) RotateLeft16(x uint16, k int) uint16

RotateLeft16 returns the value of x rotated left by (k mod 16) bits. To rotate x right by k bits, call RotateLeft16(x, -k). This function's execution time does not depend on the inputs.

func (*RMath) RotateLeft32

func (math *RMath) RotateLeft32(x uint32, k int) uint32

RotateLeft32 returns the value of x rotated left by (k mod 32) bits. To rotate x right by k bits, call RotateLeft32(x, -k). This function's execution time does not depend on the inputs.

func (*RMath) RotateLeft64

func (math *RMath) RotateLeft64(x uint64, k int) uint64

RotateLeft64 returns the value of x rotated left by (k mod 64) bits. To rotate x right by k bits, call RotateLeft64(x, -k). This function's execution time does not depend on the inputs.

func (*RMath) RotateLeft8

func (math *RMath) RotateLeft8(x uint8, k int) uint8

RotateLeft8 returns the value of x rotated left by (k mod 8) bits. To rotate x right by k bits, call RotateLeft8(x, -k). This function's execution time does not depend on the inputs.

func (*RMath) Round

func (math *RMath) Round(input float64) int

Round

func (*RMath) Sin

func (math *RMath) Sin(x float64) float64

Sin returns the sine of the radian argument x.

Special cases are:

Sin(±0) = ±0
Sin(±Inf) = NaN
Sin(NaN) = NaN

func (*RMath) Sqrt

func (math *RMath) Sqrt(number float64) float64

sqrt

func (*RMath) Sub

func (math *RMath) Sub(x, y, borrow uint) (diff, borrowOut uint)

Sub returns the difference of x, y and borrow: diff = x - y - borrow. The borrow input must be 0 or 1; otherwise the behavior is undefined. The borrowOut output is guaranteed to be 0 or 1. This function's execution time does not depend on the inputs.

func (*RMath) Sub32

func (math *RMath) Sub32(x, y, borrow uint32) (diff, borrowOut uint32)

Sub32 returns the difference of x, y and borrow, diff = x - y - borrow. The borrow input must be 0 or 1; otherwise the behavior is undefined. The borrowOut output is guaranteed to be 0 or 1.

This function's execution time does not depend on the inputs.

func (*RMath) Sub64

func (math *RMath) Sub64(x, y, borrow uint64) (diff, borrowOut uint64)

Sub64 returns the difference of x, y and borrow: diff = x - y - borrow. The borrow input must be 0 or 1; otherwise the behavior is undefined. The borrowOut output is guaranteed to be 0 or 1. This function's execution time does not depend on the inputs.

func (*RMath) Tan

func (math *RMath) Tan(x float64) float64

tan

func (*RMath) TrailingZeros

func (math *RMath) TrailingZeros(x uint) int

TrailingZeros returns the number of trailing zero bits in x; the result is UintSize for x == 0.

func (*RMath) TrailingZeros16

func (math *RMath) TrailingZeros16(x uint16) int

TrailingZeros16 returns the number of trailing zero bits in x; the result is 16 for x == 0.

func (*RMath) TrailingZeros32

func (math *RMath) TrailingZeros32(x uint32) int

TrailingZeros32 returns the number of trailing zero bits in x; the result is 32 for x == 0.

func (*RMath) TrailingZeros64

func (math *RMath) TrailingZeros64(x uint64) int

TrailingZeros64 returns the number of trailing zero bits in x; the result is 64 for x == 0.

func (*RMath) TrailingZeros8

func (math *RMath) TrailingZeros8(x uint8) int

TrailingZeros8 returns the number of trailing zero bits in x; the result is 8 for x == 0.

Jump to

Keyboard shortcuts

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