dual

package module
v0.0.0-...-843fb89 Latest Latest
Warning

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

Go to latest
Published: May 11, 2016 License: MIT Imports: 6 Imported by: 0

README

dual

Package dual brings dual numbers to Go. It borrows heavily from the math, math/cmplx, and math/big packages.

Go Report Card GoDoc

Documentation

Overview

Package dual implements dual number arithmetic.

Index

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

func ComplexInf(a, b, c, d int) *Complex

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

func NewComplex(a, b, c, d float64) *Complex

NewComplex returns a pointer to a Complex value made from four given float64 values.

func (*Complex) Add

func (z *Complex) Add(x, y *Complex) *Complex

Add sets z equal to the sum of x and y, and returns z.

func (*Complex) Commutator

func (z *Complex) Commutator(x, y *Complex) *Complex

Commutator sets z equal to the commutator of x and y, and returns z.

func (*Complex) Conj

func (z *Complex) Conj(y *Complex) *Complex

Conj sets z equal to the conjugate of y, and returns z.

func (*Complex) Copy

func (z *Complex) Copy(y *Complex) *Complex

Copy copies y onto z, and returns z.

func (*Complex) Dil

func (z *Complex) Dil(y *Complex, a float64) *Complex

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) Equals

func (z *Complex) Equals(y *Complex) bool

Equals returns true if z and y are equal.

func (*Complex) IsInf

func (z *Complex) IsInf() bool

IsInf returns true if any of the components of z are infinite.

func (*Complex) IsNaN

func (z *Complex) IsNaN() bool

IsNaN returns true if any component of z is NaN and neither is an infinity.

func (*Complex) IsZeroDiv

func (z *Complex) IsZeroDiv() bool

IsZeroDiv returns true if z is a zero divisor. This is equivalent to z being nilpotent (i.e. z² = 0).

func (*Complex) Mul

func (z *Complex) Mul(x, y *Complex) *Complex

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) Neg

func (z *Complex) Neg(y *Complex) *Complex

Neg sets z equal to the negative of y, and returns z.

func (*Complex) Quad

func (z *Complex) Quad() float64

Quad returns the quadrance of z, a float64 value.

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})

func (*Complex) String

func (z *Complex) String() string

String returns the string representation of a Complex value.

If z corresponds to the dual complex number a + bi + cε + dεi, then the string is "(a+bi+cε+dεi)", similar to complex128 values.

func (*Complex) Sub

func (z *Complex) Sub(x, y *Complex) *Complex

Sub sets z equal to the difference of x and y, and returns z.

type Hamilton

type Hamilton [2]*quat.Hamilton

A Hamilton represents a dual Hamilton quaternion as an ordered array of two pointers to quat.Hamilton values.

func HamiltonInf

func HamiltonInf(a, b, c, d, e, f, g, h int) *Hamilton

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

func NewHamilton(a, b, c, d, e, f, g, h float64) *Hamilton

NewHamilton returns a pointer to a Hamilton value made from eight given float64 values.

func (*Hamilton) Add

func (z *Hamilton) Add(x, y *Hamilton) *Hamilton

Add sets z equal to the sum of x and y, and returns z.

func (*Hamilton) Associator

func (z *Hamilton) Associator(w, x, y *Hamilton) *Hamilton

Associator sets z equal to the associator of w, x, and y, and returns z.

func (*Hamilton) Commutator

func (z *Hamilton) Commutator(x, y *Hamilton) *Hamilton

Commutator sets z equal to the commutator of x and y, and returns z.

func (*Hamilton) Conj

func (z *Hamilton) Conj(y *Hamilton) *Hamilton

Conj sets z equal to the conjugate of y, and returns z.

func (*Hamilton) Copy

func (z *Hamilton) Copy(y *Hamilton) *Hamilton

Copy copies y onto z, and returns z.

func (*Hamilton) Dil

func (z *Hamilton) Dil(y *Hamilton, a float64) *Hamilton

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) Equals

func (z *Hamilton) Equals(y *Hamilton) bool

Equals returns true if z and y are equal.

func (*Hamilton) IsInf

func (z *Hamilton) IsInf() bool

IsInf returns true if any of the components of z are infinite.

func (*Hamilton) IsNaN

func (z *Hamilton) IsNaN() bool

IsNaN returns true if any component of z is NaN and neither is an infinity.

func (*Hamilton) IsZeroDiv

func (z *Hamilton) IsZeroDiv() bool

IsZeroDiv returns true if z is a zero divisor. This is equivalent to z being nilpotent (i.e. z² = 0).

func (*Hamilton) Mul

func (z *Hamilton) Mul(x, y *Hamilton) *Hamilton

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) Neg

func (z *Hamilton) Neg(y *Hamilton) *Hamilton

Neg sets z equal to the negative of y, and returns z.

func (*Hamilton) Quad

func (z *Hamilton) Quad() float64

Quad returns the quadrance of z, a float64 value.

func (*Hamilton) ScalL

func (z *Hamilton) ScalL(a *quat.Hamilton, y *Hamilton) *Hamilton

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

func (z *Hamilton) ScalR(y *Hamilton, a *quat.Hamilton) *Hamilton

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})

func (*Hamilton) String

func (z *Hamilton) String() string

String returns the string version of a Hamilton value. If z corresponds to the dual Hamilton quaternion a + bi + cj + dk + eε + fεi + gεj + hεk, then the string is "(a+bi+cj+dk+eε+fεi+gεj+hεk)", similar to complex128 values.

func (*Hamilton) Sub

func (z *Hamilton) Sub(x, y *Hamilton) *Hamilton

Sub sets z equal to the difference of x and y, and returns z.

type Hyper

type Hyper [2]*Real

A Hyper represents a hyper dual number as an ordered array of two pointers to Real values.

func HyperInf

func HyperInf(a, b, c, d int) *Hyper

HyperInf returns a pointer to a hyper dual infinity value.

func HyperNaN

func HyperNaN() *Hyper

HyperNaN returns a pointer to a hyper dual NaN value.

func NewHyper

func NewHyper(a, b, c, d float64) *Hyper

NewHyper returns a pointer to a Hyper value made from four given float64 values.

func (*Hyper) Add

func (z *Hyper) Add(x, y *Hyper) *Hyper

Add sets z equal to the sum of x and y, and returns z.

func (*Hyper) Conj

func (z *Hyper) Conj(y *Hyper) *Hyper

Conj sets z equal to the conjugate of y, and returns z.

func (*Hyper) Copy

func (z *Hyper) Copy(y *Hyper) *Hyper

Copy copies y onto z, and returns z.

func (*Hyper) Dil

func (z *Hyper) Dil(y *Hyper, a float64) *Hyper

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) Equals

func (z *Hyper) Equals(y *Hyper) bool

Equals returns true if z and y are equal.

func (*Hyper) IsInf

func (z *Hyper) IsInf() bool

IsInf returns true if any of the components of z are infinite.

func (*Hyper) IsNaN

func (z *Hyper) IsNaN() bool

IsNaN returns true if any component of z is NaN and neither is an infinity.

func (*Hyper) Mul

func (z *Hyper) Mul(x, y *Hyper) *Hyper

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) Neg

func (z *Hyper) Neg(y *Hyper) *Hyper

Neg sets z equal to the negative of y, and returns z.

func (*Hyper) Scal

func (z *Hyper) Scal(y *Hyper, a *Real) *Hyper

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})

func (*Hyper) String

func (z *Hyper) String() string

String returns the string representation of a Hyper value.

If z corresponds to the hyper dual number a + bε + cη + dεη, then the string is "(a+bε+cη+dεη)", similar to complex128 values.

func (*Hyper) Sub

func (z *Hyper) Sub(x, y *Hyper) *Hyper

Sub sets z equal to the difference of x and y, and returns z.

type Perplex

type Perplex [2]*split.Complex

A Perplex represents a dual perplex number as an ordered array of two pointers to split.Complex values.

func NewPerplex

func NewPerplex(a, b, c, d float64) *Perplex

NewPerplex returns a pointer to a Perplex value made from four given float64 values.

func (*Perplex) Add

func (z *Perplex) Add(x, y *Perplex) *Perplex

Add sets z equal to the sum of x and y, and returns z.

func (*Perplex) Cartesian

func (z *Perplex) Cartesian() (a, b, c, d float64)

Cartesian returns the four Cartesian components of z.

func (*Perplex) Commutator

func (z *Perplex) Commutator(x, y *Perplex) *Perplex

Commutator sets z equal to the commutator of x and y, and returns z.

func (*Perplex) Conj

func (z *Perplex) Conj(y *Perplex) *Perplex

Conj sets z equal to the conjugate of y, and returns z.

func (*Perplex) Copy

func (z *Perplex) Copy(y *Perplex) *Perplex

Copy copies y onto z, and returns z.

func (*Perplex) Dil

func (z *Perplex) Dil(y *Perplex, a float64) *Perplex

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) Dual

func (z *Perplex) Dual() *split.Complex

Dual returns the dual part of z, a pointer to a split.Complex value.

func (*Perplex) Equals

func (z *Perplex) Equals(y *Perplex) bool

Equals returns true if z and y are equal.

func (*Perplex) Inf

func (z *Perplex) Inf(a, b, c, d int) *Perplex

Inf sets z equal to a dual perplex infinity value.

func (*Perplex) IsInf

func (z *Perplex) IsInf() bool

IsInf returns true if any of the components of z are infinite.

func (*Perplex) IsNaN

func (z *Perplex) IsNaN() bool

IsNaN returns true if any component of z is NaN and neither is an infinity.

func (*Perplex) Mul

func (z *Perplex) Mul(x, y *Perplex) *Perplex

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) NaN

func (z *Perplex) NaN() *Perplex

NaN sets z equal to a dual perplex NaN value.

func (*Perplex) Neg

func (z *Perplex) Neg(y *Perplex) *Perplex

Neg sets z equal to the negative of y, and returns z.

func (*Perplex) Quad

func (z *Perplex) Quad() float64

Quad returns the quadrance of z, a float64 value.

func (*Perplex) Real

func (z *Perplex) Real() *split.Complex

Real returns the real part of z, a pointer to a split.Complex value.

func (*Perplex) Scal

func (z *Perplex) Scal(y *Perplex, a *split.Complex) *Perplex

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})

func (*Perplex) SetDual

func (z *Perplex) SetDual(b *split.Complex)

SetDual sets the dual part of z equal to b.

func (*Perplex) SetReal

func (z *Perplex) SetReal(a *split.Complex)

SetReal sets the real part of z equal to a.

func (*Perplex) String

func (z *Perplex) String() string

String returns the string representation of a Perplex value.

If z corresponds to the dual perplex number a + bs + cε + dεs, then the string is "(a+bs+cε+dεs)", similar to complex128 values.

func (*Perplex) Sub

func (z *Perplex) Sub(x, y *Perplex) *Perplex

Sub sets z equal to the difference of x and y, and returns z.

type Real

type Real [2]float64

A Real represents a dual real number.

func NewReal

func NewReal(a, b float64) *Real

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

func RealInf(a, b int) *Real

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) Add

func (z *Real) Add(x, y *Real) *Real

Add sets z equal to the sum of x and y, and returns z.

func (*Real) Cartesian

func (z *Real) Cartesian() (a, b float64)

Cartesian returns the two Cartesian components of z.

func (*Real) Conj

func (z *Real) Conj(y *Real) *Real

Conj sets z equal to the conjugate of y, and returns z.

func (*Real) Copy

func (z *Real) Copy(y *Real) *Real

Copy copies y onto z, and returns z.

func (*Real) Cos

func (z *Real) Cos(y *Real) *Real

Cos sets z equal to the dual cosine of y, and returns z.

func (*Real) Cosh

func (z *Real) Cosh(y *Real) *Real

Cosh sets z equal to the dual hyperbolic cosine of y, and returns z.

func (*Real) Dual

func (z *Real) Dual() float64

Dual returns the dual part of z, a float64 value.

func (*Real) Equals

func (z *Real) Equals(y *Real) bool

Equals returns true if z and y are equal.

func (*Real) Exp

func (z *Real) Exp(y *Real) *Real

Exp sets z equal to the dual exponential of y, and returns z.

func (*Real) Inv

func (z *Real) Inv(y *Real) *Real

Inv sets z equal to the inverse of y, and returns z. If y is a zero divisor, then Inv panics.

func (*Real) IsInf

func (z *Real) IsInf() bool

IsInf returns true if any of the components of z are infinite.

func (*Real) IsNaN

func (z *Real) IsNaN() bool

IsNaN returns true if any component of z is NaN and neither is an infinity.

func (*Real) IsZeroDiv

func (z *Real) IsZeroDiv() bool

IsZeroDiv returns true if z is a zero divisor. This is equivalent to z being nilpotent (i.e. z² = 0).

func (*Real) Mul

func (z *Real) Mul(x, y *Real) *Real

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) Neg

func (z *Real) Neg(y *Real) *Real

Neg sets z equal to the negative of y, and returns z.

func (*Real) Quad

func (z *Real) Quad() float64

Quad returns the non-negative dual quadrance of z, a float64 value.

func (*Real) Quo

func (z *Real) Quo(x, y *Real) *Real

Quo sets z equal to the quotient of x and y, and returns z. If y is a zero divisor, then Quo panics.

func (*Real) Real

func (z *Real) Real() float64

Real returns the real part of z, a float64 value.

func (*Real) Scal

func (z *Real) Scal(y *Real, a float64) *Real

Scal sets z equal to y scaled by a, and returns z.

func (*Real) SetDual

func (z *Real) SetDual(b float64)

SetDual sets the dual part of z equal to b.

func (*Real) SetReal

func (z *Real) SetReal(a float64)

SetReal sets the real part of z equal to a.

func (*Real) Sin

func (z *Real) Sin(y *Real) *Real

Sin sets z equal to the dual sine of y, and returns z.

func (*Real) Sinh

func (z *Real) Sinh(y *Real) *Real

Sinh sets z equal to the dual hyperbolic sine of y, and returns z.

func (*Real) String

func (z *Real) String() string

String returns the string version of a Real value.

If z = a + bε, then the string is "(a+bε)", similar to complex128 values.

func (*Real) Sub

func (z *Real) Sub(x, y *Real) *Real

Sub sets z equal to the difference of x and y, and returns z.

type Super

type Super [2]*Real

A Super represents a super dual number as an ordered array of two pointers to Real values.

func NewSuper

func NewSuper(a, b, c, d float64) *Super

NewSuper returns a pointer to a Super value made from four given float64 values.

func SuperInf

func SuperInf(a, b, c, d int) *Super

SuperInf returns a pointer to a super dual infinity value.

func SuperNaN

func SuperNaN() *Super

SuperNaN returns a pointer to a super dual NaN value.

func (*Super) Add

func (z *Super) Add(x, y *Super) *Super

Add sets z equal to the sum of x and y, and returns z.

func (*Super) Cartesian

func (z *Super) Cartesian() (a, b, c, d float64)

Cartesian returns the four Cartesian components of z.

func (*Super) Commutator

func (z *Super) Commutator(x, y *Super) *Super

Commutator sets z equal to the commutator of x and y, and returns z.

func (*Super) Conj

func (z *Super) Conj(y *Super) *Super

Conj sets z equal to the conjugate of y, and returns z.

func (*Super) Copy

func (z *Super) Copy(y *Super) *Super

Copy copies y onto z, and returns z.

func (*Super) Dil

func (z *Super) Dil(y *Super, a float64) *Super

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) Dual

func (z *Super) Dual() *Real

Dual returns the dual part of z, a pointer to a Real value.

func (*Super) Equals

func (z *Super) Equals(y *Super) bool

Equals returns true if z and y are equal.

func (*Super) IsInf

func (z *Super) IsInf() bool

IsInf returns true if any of the components of z are infinite.

func (*Super) IsNaN

func (z *Super) IsNaN() bool

IsNaN returns true if any component of z is NaN and neither is an infinity.

func (*Super) Mul

func (z *Super) Mul(x, y *Super) *Super

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) Neg

func (z *Super) Neg(y *Super) *Super

Neg sets z equal to the negative of y, and returns z.

func (*Super) Quad

func (z *Super) Quad() float64

Quad returns the dual quadrance of z, a float64 value.

func (*Super) Real

func (z *Super) Real() *Real

Real returns the real part of z, a pointer to a Real value.

func (*Super) Scal

func (z *Super) Scal(y *Super, a *Real) *Super

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})

func (*Super) SetDual

func (z *Super) SetDual(b *Real)

SetDual sets the dual part of z equal to b.

func (*Super) SetReal

func (z *Super) SetReal(a *Real)

SetReal sets the real part of z equal to a.

func (*Super) String

func (z *Super) String() string

String returns the string representation of a Super value.

If z corresponds to the super dual real number a + bσ + cτ + dστ, then the string is "(a+bσ+cτ+dστ)", similar to complex128 values.

func (*Super) Sub

func (z *Super) Sub(x, y *Super) *Super

Sub sets z equal to the difference of x and y, and returns z.

type Ultra

type Ultra [2]*Super

An Ultra represents an ultra dual number as an ordered array of two pointers to Super values.

func NewUltra

func NewUltra(a, b, c, d, e, f, g, h float64) *Ultra

NewUltra returns a pointer to a Ultra value made from eight given float64 values.

func UltraInf

func UltraInf(a, b, c, d, e, f, g, h int) *Ultra

UltraInf returns a pointer to an ultra dual infinity value.

func UltraNaN

func UltraNaN() *Ultra

UltraNaN returns a pointer to an ultra dual NaN value.

func (*Ultra) Add

func (z *Ultra) Add(x, y *Ultra) *Ultra

Add sets z equal to the sum of x and y, and returns z.

func (*Ultra) Associator

func (z *Ultra) Associator(w, x, y *Ultra) *Ultra

Associator sets z equal to the associator of w, x, and y, and returns z.

func (*Ultra) Cartesian

func (z *Ultra) Cartesian() (a, b, c, d, e, f, g, h float64)

Cartesian returns the four Cartesian components of z.

func (*Ultra) Commutator

func (z *Ultra) Commutator(x, y *Ultra) *Ultra

Commutator sets z equal to the commutator of x and y, and returns z.

func (*Ultra) Conj

func (z *Ultra) Conj(y *Ultra) *Ultra

Conj sets z equal to the conjugate of y, and returns z.

func (*Ultra) Copy

func (z *Ultra) Copy(y *Ultra) *Ultra

Copy copies y onto z, and returns z.

func (*Ultra) Dil

func (z *Ultra) Dil(y *Ultra, a float64) *Ultra

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) Dual

func (z *Ultra) Dual() *Super

Dual returns the dual part of z, a pointer to a Super value.

func (*Ultra) Equals

func (z *Ultra) Equals(y *Ultra) bool

Equals returns true if z and y are equal.

func (*Ultra) IsInf

func (z *Ultra) IsInf() bool

IsInf returns true if any of the components of z are infinite.

func (*Ultra) IsNaN

func (z *Ultra) IsNaN() bool

IsNaN returns true if any component of z is NaN and neither is an infinity.

func (*Ultra) Mul

func (z *Ultra) Mul(x, y *Ultra) *Ultra

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) Neg

func (z *Ultra) Neg(y *Ultra) *Ultra

Neg sets z equal to the negative of y, and returns z.

func (*Ultra) Quad

func (z *Ultra) Quad() float64

Quad returns the quadrance of z, a float64 value.

func (*Ultra) Real

func (z *Ultra) Real() *Super

Real returns the real part of z, a pointer to a Super value.

func (*Ultra) Scal

func (z *Ultra) Scal(y *Ultra, a *Super) *Ultra

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})

func (*Ultra) SetDual

func (z *Ultra) SetDual(b *Super)

SetDual sets the dual part of z equal to b.

func (*Ultra) SetReal

func (z *Ultra) SetReal(a *Super)

SetReal sets the real part of z equal to a.

func (*Ultra) String

func (z *Ultra) String() string

String returns the string representation of a Ultra value.

If z corresponds to the ultra dual real number a + bσ + cτ + dστ, then the string is "(a+bσ+cτ+dστ)", similar to complex128 values.

func (*Ultra) Sub

func (z *Ultra) Sub(x, y *Ultra) *Ultra

Sub sets z equal to the difference of x and y, and returns z.

Jump to

Keyboard shortcuts

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