split

package module
v0.0.0-...-77e4f70 Latest Latest
Warning

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

Go to latest
Published: May 12, 2016 License: MIT Imports: 3 Imported by: 1

README

split

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

Go Report Card GoDoc

To Do

  1. Better handling of special values like NaN and Infs
  2. Improve documentation
  3. Tests
  4. Improve README

Documentation

Overview

Package split implements the split-complex number arithmetic.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Complex

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

A Complex represents a split-complex number.

func New

func New(a, b float64) *Complex

New returns a pointer to a Complex value made from two given real float64 values.

Example
fmt.Println(New(1, 0))
fmt.Println(New(0, -1))
fmt.Println(New(3, -1))
fmt.Println(New(5, 7))
Output:

(1+0s)
(0-1s)
(3-1s)
(5+7s)

func (*Complex) Add

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

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

func (*Complex) Cartesian

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

Cartesian returns the two Cartesian components of 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) Curv

func (z *Complex) Curv() (r, ξ float64, sign int)

Curv returns the curvilinear coordinates of a Complex value, along with the sign of the quadrance.

func (*Complex) Equals

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

Equals returns true if y and z are equal.

func (*Complex) Idempotent

func (z *Complex) Idempotent(sign int) *Complex

Idempotent sets z equal to one of two possible idempotents (i.e. z = z*z).

func (*Complex) Imag

func (z *Complex) Imag() float64

Imag returns the imaginary part of z, a float64 value.

func (*Complex) Inf

func (z *Complex) Inf(a, b int) *Complex

Inf returns a pointer to a split-complex infinity value.

func (*Complex) Inv

func (z *Complex) Inv(y *Complex) *Complex

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

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 (i.e. if z has vanishing quadrance).

func (*Complex) Mul

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

Mul sets z to the product of x and y, and returns z.

func (*Complex) NaN

func (z *Complex) NaN() *Complex

NaN returns a pointer to a split-complex NaN value.

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, which can be either positive, negative, or zero.

func (*Complex) Quo

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

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

func (*Complex) Real

func (z *Complex) Real() float64

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

func (*Complex) Rect

func (z *Complex) Rect(r, ξ float64, sign int) *Complex

Rect sets z equal to the Complex value made from given curvilinear coordinates and quadrance sign, and returns z.

func (*Complex) Scal

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

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

func (*Complex) SetImag

func (z *Complex) SetImag(b float64)

SetImag sets the imaginary part of z equal to b.

func (*Complex) SetReal

func (z *Complex) SetReal(a float64)

SetReal sets the real part of z equal to a.

func (*Complex) String

func (z *Complex) String() string

String returns the string version of a Complex value. If z = a + bs, then the string is "(a+bs)", similar to complex128 values.

func (*Complex) Sub

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

Sub sets z 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