unified

package
v0.0.0-...-c99f163 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2025 License: MIT Imports: 4 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var E = sync.OnceValue(func() *Real {
	return New(constructive.E(), rational.One())
})
View Source
var Half = sync.OnceValue(func() *Real {
	return New(constructive.One(), rational.New64(1, 2))
})
View Source
var Ln2 = sync.OnceValue(func() *Real {
	return New(constructive.Ln2(), rational.One())
})
View Source
var NegativeOne = sync.OnceValue(func() *Real {
	return New(constructive.One(), rational.New64(-1, 1))
})
View Source
var One = sync.OnceValue(func() *Real {
	return New(constructive.One(), rational.One())
})
View Source
var Phi = sync.OnceValue(func() *Real {
	return New(constructive.Phi(), rational.One())
})
View Source
var Pi = sync.OnceValue(func() *Real {
	return New(constructive.Pi(), rational.One())
})
View Source
var Sqrt2 = sync.OnceValue(func() *Real {
	return New(constructive.Sqrt2(), rational.One())
})
View Source
var Ten = sync.OnceValue(func() *Real {
	return New(constructive.One(), rational.New64(10, 1))
})
View Source
var Two = sync.OnceValue(func() *Real {
	return New(constructive.One(), rational.New64(2, 1))
})
View Source
var Zero = sync.OnceValue(func() *Real {
	return New(constructive.One(), rational.Zero())
})

Functions

This section is empty.

Types

type Real

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

Real represents a real number as a unification of a constructive real and a rational number.

func New

func New(cr constructive.Real, rr *rational.Number) *Real

New creates a new Real number from the given constructive real and rational number. The actual value being represented is `cr * rr`; if either argument is nil, it defaults to one.

func (*Real) Add

func (u *Real) Add(other *Real) *Real

Add adds the current number and another number together, returning a new Real number.

func (*Real) Constructive

func (u *Real) Constructive() constructive.Real

Constructive returns the constructive real representation of the unified real number.

func (*Real) Divide

func (u *Real) Divide(other *Real) *Real

Divide divides the current number by another number, returning a new Real number.

func (*Real) Format

func (u *Real) Format(f fmt.State, c rune)

Format implements the fmt.Formatter interface for custom formatting.

func (*Real) FormattedString

func (u *Real) FormattedString(decimalDigits, radix int) string

FormattedString returns a string representation of the unified real number with the specified number of decimal digits and radix.

func (*Real) Inverse

func (u *Real) Inverse() *Real

Inverse returns the multiplicative inverse of the current number as a new Real number.

func (*Real) IsZero

func (u *Real) IsZero() bool

IsZero returns true if the current number is zero. In order for the number to be zero, the rational component must be zero. The constructive component cannot be used to determine if the number is zero, since constructive reals can only approximate zero at a specific precision (unless it's the zero object).

func (*Real) Multiply

func (u *Real) Multiply(other *Real) *Real

Multiply multiplies the current number by another number, returning a new Real number.

func (*Real) Negate

func (u *Real) Negate() *Real

Negate returns the negation of the current number as a new Real number.

func (*Real) ShiftLeft

func (u *Real) ShiftLeft(n int) *Real

ShiftLeft shifts the number to the left by the specified number of bits, which is equivalent to multiplying the number by 2^n.

func (*Real) ShiftRight

func (u *Real) ShiftRight(n int) *Real

ShiftRight shifts the number to the right by the specified number of bits, which is equivalent to dividing the number by 2^n.

func (*Real) Subtract

func (u *Real) Subtract(other *Real) *Real

Subtract `other` from the current number, returning a new Real number.

Jump to

Keyboard shortcuts

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