Documentation ¶
Overview ¶
Package dual implements dual number arithmetic.
Index ¶
- type Complex
- func (z *Complex) Add(x, y *Complex) *Complex
- func (z *Complex) Commutator(x, y *Complex) *Complex
- func (z *Complex) Conj(y *Complex) *Complex
- func (z *Complex) Copy(y *Complex) *Complex
- func (z *Complex) Dil(y *Complex, a float64) *Complex
- func (z *Complex) Equals(y *Complex) bool
- func (z *Complex) IsInf() bool
- func (z *Complex) IsNaN() bool
- func (z *Complex) IsZeroDiv() bool
- func (z *Complex) Mul(x, y *Complex) *Complex
- func (z *Complex) Neg(y *Complex) *Complex
- func (z *Complex) Quad() float64
- func (z *Complex) Scal(y *Complex, a complex128) *Complex
- func (z *Complex) String() string
- func (z *Complex) Sub(x, y *Complex) *Complex
- type Hamilton
- func (z *Hamilton) Add(x, y *Hamilton) *Hamilton
- func (z *Hamilton) Associator(w, x, y *Hamilton) *Hamilton
- func (z *Hamilton) Commutator(x, y *Hamilton) *Hamilton
- func (z *Hamilton) Conj(y *Hamilton) *Hamilton
- func (z *Hamilton) Copy(y *Hamilton) *Hamilton
- func (z *Hamilton) Dil(y *Hamilton, a float64) *Hamilton
- func (z *Hamilton) Equals(y *Hamilton) bool
- func (z *Hamilton) IsInf() bool
- func (z *Hamilton) IsNaN() bool
- func (z *Hamilton) IsZeroDiv() bool
- func (z *Hamilton) Mul(x, y *Hamilton) *Hamilton
- func (z *Hamilton) Neg(y *Hamilton) *Hamilton
- func (z *Hamilton) Quad() float64
- func (z *Hamilton) ScalL(a *quat.Hamilton, y *Hamilton) *Hamilton
- func (z *Hamilton) ScalR(y *Hamilton, a *quat.Hamilton) *Hamilton
- func (z *Hamilton) String() string
- func (z *Hamilton) Sub(x, y *Hamilton) *Hamilton
- type Hyper
- func (z *Hyper) Add(x, y *Hyper) *Hyper
- func (z *Hyper) Conj(y *Hyper) *Hyper
- func (z *Hyper) Copy(y *Hyper) *Hyper
- func (z *Hyper) Dil(y *Hyper, a float64) *Hyper
- func (z *Hyper) Equals(y *Hyper) bool
- func (z *Hyper) IsInf() bool
- func (z *Hyper) IsNaN() bool
- func (z *Hyper) Mul(x, y *Hyper) *Hyper
- func (z *Hyper) Neg(y *Hyper) *Hyper
- func (z *Hyper) Scal(y *Hyper, a *Real) *Hyper
- func (z *Hyper) String() string
- func (z *Hyper) Sub(x, y *Hyper) *Hyper
- type Perplex
- func (z *Perplex) Add(x, y *Perplex) *Perplex
- func (z *Perplex) Cartesian() (a, b, c, d float64)
- func (z *Perplex) Commutator(x, y *Perplex) *Perplex
- func (z *Perplex) Conj(y *Perplex) *Perplex
- func (z *Perplex) Copy(y *Perplex) *Perplex
- func (z *Perplex) Dil(y *Perplex, a float64) *Perplex
- func (z *Perplex) Dual() *split.Complex
- func (z *Perplex) Equals(y *Perplex) bool
- func (z *Perplex) Inf(a, b, c, d int) *Perplex
- func (z *Perplex) IsInf() bool
- func (z *Perplex) IsNaN() bool
- func (z *Perplex) Mul(x, y *Perplex) *Perplex
- func (z *Perplex) NaN() *Perplex
- func (z *Perplex) Neg(y *Perplex) *Perplex
- func (z *Perplex) Quad() float64
- func (z *Perplex) Real() *split.Complex
- func (z *Perplex) Scal(y *Perplex, a *split.Complex) *Perplex
- func (z *Perplex) SetDual(b *split.Complex)
- func (z *Perplex) SetReal(a *split.Complex)
- func (z *Perplex) String() string
- func (z *Perplex) Sub(x, y *Perplex) *Perplex
- type Real
- func (z *Real) Add(x, y *Real) *Real
- func (z *Real) Cartesian() (a, b float64)
- func (z *Real) Conj(y *Real) *Real
- func (z *Real) Copy(y *Real) *Real
- func (z *Real) Cos(y *Real) *Real
- func (z *Real) Cosh(y *Real) *Real
- func (z *Real) Dual() float64
- func (z *Real) Equals(y *Real) bool
- func (z *Real) Exp(y *Real) *Real
- func (z *Real) Inv(y *Real) *Real
- func (z *Real) IsInf() bool
- func (z *Real) IsNaN() bool
- func (z *Real) IsZeroDiv() bool
- func (z *Real) Mul(x, y *Real) *Real
- func (z *Real) Neg(y *Real) *Real
- func (z *Real) Quad() float64
- func (z *Real) Quo(x, y *Real) *Real
- func (z *Real) Real() float64
- func (z *Real) Scal(y *Real, a float64) *Real
- func (z *Real) SetDual(b float64)
- func (z *Real) SetReal(a float64)
- func (z *Real) Sin(y *Real) *Real
- func (z *Real) Sinh(y *Real) *Real
- func (z *Real) String() string
- func (z *Real) Sub(x, y *Real) *Real
- type Super
- func (z *Super) Add(x, y *Super) *Super
- func (z *Super) Cartesian() (a, b, c, d float64)
- func (z *Super) Commutator(x, y *Super) *Super
- func (z *Super) Conj(y *Super) *Super
- func (z *Super) Copy(y *Super) *Super
- func (z *Super) Dil(y *Super, a float64) *Super
- func (z *Super) Dual() *Real
- func (z *Super) Equals(y *Super) bool
- func (z *Super) IsInf() bool
- func (z *Super) IsNaN() bool
- func (z *Super) Mul(x, y *Super) *Super
- func (z *Super) Neg(y *Super) *Super
- func (z *Super) Quad() float64
- func (z *Super) Real() *Real
- func (z *Super) Scal(y *Super, a *Real) *Super
- func (z *Super) SetDual(b *Real)
- func (z *Super) SetReal(a *Real)
- func (z *Super) String() string
- func (z *Super) Sub(x, y *Super) *Super
- type Ultra
- func (z *Ultra) Add(x, y *Ultra) *Ultra
- func (z *Ultra) Associator(w, x, y *Ultra) *Ultra
- func (z *Ultra) Cartesian() (a, b, c, d, e, f, g, h float64)
- func (z *Ultra) Commutator(x, y *Ultra) *Ultra
- func (z *Ultra) Conj(y *Ultra) *Ultra
- func (z *Ultra) Copy(y *Ultra) *Ultra
- func (z *Ultra) Dil(y *Ultra, a float64) *Ultra
- func (z *Ultra) Dual() *Super
- func (z *Ultra) Equals(y *Ultra) bool
- func (z *Ultra) IsInf() bool
- func (z *Ultra) IsNaN() bool
- func (z *Ultra) Mul(x, y *Ultra) *Ultra
- func (z *Ultra) Neg(y *Ultra) *Ultra
- func (z *Ultra) Quad() float64
- func (z *Ultra) Real() *Super
- func (z *Ultra) Scal(y *Ultra, a *Super) *Ultra
- func (z *Ultra) SetDual(b *Super)
- func (z *Ultra) SetReal(a *Super)
- func (z *Ultra) String() string
- func (z *Ultra) Sub(x, y *Ultra) *Ultra
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Complex ¶
type Complex [2]complex128
A Complex represents a dual complex number as an ordered array of two complex128 values.
func ComplexInf ¶
ComplexInf returns a pointer to a dual complex infinity value.
func ComplexNaN ¶
func ComplexNaN() *Complex
ComplexNaN returns a pointer to a dual complex NaN value.
func NewComplex ¶
NewComplex returns a pointer to a Complex value made from four given float64 values.
func (*Complex) Commutator ¶
Commutator sets z equal to the commutator of x and y, and returns z.
func (*Complex) Dil ¶
Dil sets z equal to the dilation of y by a, and returns z.
This is a special case of Mul:
Dil(y, a) = Mul(y, Complex{complex(a, 0), 0})
func (*Complex) IsZeroDiv ¶
IsZeroDiv returns true if z is a zero divisor. This is equivalent to z being nilpotent (i.e. z² = 0).
func (*Complex) Mul ¶
Mul sets z equal to the product of x and y, and returns z.
The basic rules are:
ε * ε = 0 i * i = -1 εi * εi = 0 ε * i = i * ε = εi εi * i = i * εi = -ε ε * εi = εi * ε = 0
This multiplication rule is noncommutative but associative.
func (*Complex) Scal ¶
func (z *Complex) Scal(y *Complex, a complex128) *Complex
Scal sets z equal to y scaled by a (with a being a complex128), and returns z.
This is a special case of Mul:
Scal(y, a) = Mul(y, Complex{a, 0})
type Hamilton ¶
A Hamilton represents a dual Hamilton quaternion as an ordered array of two pointers to quat.Hamilton values.
func HamiltonInf ¶
HamiltonInf returns a pointer to a dual Hamilton quaternion infinity value.
func HamiltonNaN ¶
func HamiltonNaN() *Hamilton
HamiltonNaN returns a pointer to a dual Hamilton quaternion NaN value.
func NewHamilton ¶
NewHamilton returns a pointer to a Hamilton value made from eight given float64 values.
func (*Hamilton) Associator ¶
Associator sets z equal to the associator of w, x, and y, and returns z.
func (*Hamilton) Commutator ¶
Commutator sets z equal to the commutator of x and y, and returns z.
func (*Hamilton) Dil ¶
Dil sets z equal to the dilation of y by a, and returns z.
This is a special case of Mul:
Dil(y, a) = Mul(y, Hamilton{quat.Hamilton{a, 0, 0, 0}, 0})
func (*Hamilton) IsNaN ¶
IsNaN returns true if any component of z is NaN and neither is an infinity.
func (*Hamilton) IsZeroDiv ¶
IsZeroDiv returns true if z is a zero divisor. This is equivalent to z being nilpotent (i.e. z² = 0).
func (*Hamilton) Mul ¶
Mul sets z equal to the product of x and y, and returns z.
The basic rules are:
i * i = j * j = k * k = -1 i * j = -j * i = k j * k = -k * j = i k * i = -i * k = j ε * ε = 0 ε * i = i * ε = εi ε * j = j * ε = εj ε * k = k * ε = εk εi * i = i * εi = -ε εj * j = j * εj = -ε εk * k = k * εk = -ε εi * j = -j * εi = εk εj * k = -k * εj = εi εk * i = -i * εk = εj ε * εi = εi * ε = 0 ε * εj = εj * ε = 0 ε * εk = εk * ε = 0 εi * εi = εj * εj = εk * εk = 0 εi * εj = εj * εi = 0 εi * εk = εk * εi = 0 εj * εk = εk * εj = 0 εj * εk = εk * εj = 0
This multiplication rule is noncommutative and nonassociative.
func (*Hamilton) ScalL ¶
ScalL sets z equal to y scaled by a on the left, and returns z.
This is a special case of Mul:
ScalL(y, a) = Mul(Hamilton{a, 0}, y)
func (*Hamilton) ScalR ¶
ScalR sets z equal to y scaled by a on the right, and returns z.
This is a special case of Mul:
ScalR(y, a) = Mul(y, Hamilton{a, 0})
type Hyper ¶
type Hyper [2]*Real
A Hyper represents a hyper dual number as an ordered array of two pointers to Real values.
func (*Hyper) Dil ¶
Dil sets z equal to the dilation of y by a, and returns z.
This is a special case of Mul:
Dil(y, a) = Mul(y, Hyper{Real{a, 0}, 0})
func (*Hyper) Mul ¶
Mul sets z equal to the product of x and y, and returns z.
The basic multiplication rules are:
ε * ε = η * η = 0 ε * η = η * ε = εη εη * εη = 0 ε * εη = εη * ε = 0 η * εη = εη * η = 0
This multiplication rule is commutative and associative.
func (*Hyper) Scal ¶
Scal sets z equal to y scaled by a (with a being a Real pointer), and returns z.
This is a special case of Mul:
Scal(y, a) = Mul(y, Hyper{a, 0})
type Perplex ¶
A Perplex represents a dual perplex number as an ordered array of two pointers to split.Complex values.
func NewPerplex ¶
NewPerplex returns a pointer to a Perplex value made from four given float64 values.
func (*Perplex) Commutator ¶
Commutator sets z equal to the commutator of x and y, and returns z.
func (*Perplex) Dil ¶
Dil sets z equal to the dilation of y by a, and returns z.
This is a special case of Mul:
Dil(y, a) = Mul(y, Perplex{split.Complex{a, 0}, 0})
func (*Perplex) Mul ¶
Mul sets z equal to the product of x and y, and returns z.
The basic multiplication rules are:
ε * ε = 0 s * s = +1 εs * εs = 0 ε * s = s * ε = εs εs * s = s * εs = +ε ε * εs = εs * ε = 0
This multiplication rule is noncommutative but associative.
func (*Perplex) Scal ¶
Scal sets z equal to y scaled by a (with a being a split.Complex pointer), and returns z.
This is a special case of Mul:
Scal(y, a) = Mul(y, Perplex{a, 0})
type Real ¶
type Real [2]float64
A Real represents a dual real number.
func NewReal ¶
NewReal returns a pointer to a Real value made from two given float64 values.
Example ¶
fmt.Println(NewReal(1, 0)) fmt.Println(NewReal(0, 1)) fmt.Println(NewReal(2, -3)) fmt.Println(NewReal(-4, 5))
Output: (1+0ε) (0+1ε) (2-3ε) (-4+5ε)
func RealInf ¶
RealInf returns a pointer to a dual real infinity value.
Example ¶
fmt.Println(RealInf(+1, +1)) fmt.Println(RealInf(+1, -1)) fmt.Println(RealInf(-1, +1)) fmt.Println(RealInf(-1, -1))
Output: (+Inf+Infε) (+Inf-Infε) (-Inf+Infε) (-Inf-Infε)
func RealNaN ¶
func RealNaN() *Real
RealNaN returns a pointer to a dual real NaN value.
Example ¶
fmt.Println(RealNaN())
Output: (NaN+NaNε)
func (*Real) Inv ¶
Inv sets z equal to the inverse of y, and returns z. If y is a zero divisor, then Inv panics.
func (*Real) IsZeroDiv ¶
IsZeroDiv returns true if z is a zero divisor. This is equivalent to z being nilpotent (i.e. z² = 0).
func (*Real) Mul ¶
Mul sets z equal to the product of x and y, and returns z.
The basic rule is:
ε * ε = 0
This multiplication operation is commutative and associative.
func (*Real) Quo ¶
Quo sets z equal to the quotient of x and y, and returns z. If y is a zero divisor, then Quo panics.
type Super ¶
type Super [2]*Real
A Super represents a super dual number as an ordered array of two pointers to Real values.
func (*Super) Commutator ¶
Commutator sets z equal to the commutator of x and y, and returns z.
func (*Super) Dil ¶
Dil sets z equal to the dilation of y by a, and returns z.
This is a special case of Mul:
Dil(y, a) = Mul(y, Super{Real{a, 0}, 0})
func (*Super) Mul ¶
Mul sets z equal to the product of x and y, and returns z.
The basic multiplication rules are:
σ * σ = τ * τ = 0 σ * τ = -τ * σ = στ στ * στ = 0 σ * στ = στ * σ = 0 τ * στ = στ * τ = 0
This multiplication operation is noncommutative but associative.
func (*Super) Scal ¶
Scal sets z equal to y scaled by a (with a being a Real pointer), and returns z.
This is a special case of Mul:
Scal(y, a) = Mul(y, Super{a, 0})
type Ultra ¶
type Ultra [2]*Super
An Ultra represents an ultra dual number as an ordered array of two pointers to Super values.
func (*Ultra) Associator ¶
Associator sets z equal to the associator of w, x, and y, and returns z.
func (*Ultra) Commutator ¶
Commutator sets z equal to the commutator of x and y, and returns z.
func (*Ultra) Dil ¶
Dil sets z equal to the dilation of y by a, and returns z.
This is a special case of Mul:
Dil(y, a) = Mul(y, Ultra{Super{a, 0}, 0})
func (*Ultra) Mul ¶
Mul sets z equal to the product of x and y, and returns z.
The basic multiplication rules are:
υ₁ * υ₂ = -υ₂ * υ₁ = υ₃ υ₁ * υ₄ = -υ₄ * υ₁ = υ₅ υ₂ * υ₄ = -υ₄ * υ₂ = υ₆ υ₂ * υ₅ = -υ₅ * υ₂ = υ₇ υ₃ * υ₄ = -υ₄ * υ₃ = υ₇ υ₆ * υ₁ = -υ₁ * υ₆ = υ₇
All other products vanish. This multiplication operation is noncommutative and nonassociative.
func (*Ultra) Scal ¶
Scal sets z equal to y scaled by a (with a being a Super pointer), and returns z.
This is a special case of Mul:
Scal(y, a) = Mul(y, Ultra{a, 0})