gocomplex

package module
v0.0.0-...-aa8dbdb Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2019 License: MIT Imports: 1 Imported by: 0

README

GoMath

Build Status GoDoc Go Report Card

GoComplex contains various mathematical operators on Complex Numbers. Unlike from the original complex number implementation in golang, we used a struct to represent Complex128 with float64 for real as well as imaginary part

Couple of pending operations to implement are...

  • tan
  • sin
  • cosine
  • isnan
  • isinf
  • exp

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AlmostEqual

func AlmostEqual(a, b float64) bool

AlmostEqual Checks if the difference of two numbers are within a threshold

func IsComplexNumberEqual

func IsComplexNumberEqual(c1 Complex128, c2 Complex128) bool

IsComplexNumberEqual Check if two complex numbers are almost equal by comparing real and imaginary part

Types

type Complex128

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

Complex128 is the float structure representing the complex number

func CreateComplex128

func CreateComplex128(real float64, imaginary float64) Complex128

CreateComplex128 Returns a Complex 128 structure

func Multiply

func Multiply(c, c1 Complex128) Complex128

Multiply multiplies the two complex numbers passed as argument

func PolarToArgand

func PolarToArgand(magnitude, phase float64) Complex128

PolarToArgand Converts Polar Representation of Complex number to a + ib form

func (Complex128) Compare

func (c Complex128) Compare(c2 Complex128) bool

Compare Checks if both complex numbers are equal

func (Complex128) Conjugate

func (c Complex128) Conjugate() Complex128

Conjugate Returns the conjugate of a complex number

func (Complex128) Imaginary

func (c Complex128) Imaginary() float64

Imaginary returns Imaginary part of complex number

func (Complex128) Log

func (c Complex128) Log() Complex128

Log Return Natural Logarithm of complex number

func (Complex128) Magnitude

func (c Complex128) Magnitude() float64

Magnitude Returns the magnitude of complex numeber

func (Complex128) MultiplyBy

func (c Complex128) MultiplyBy(c1 Complex128) Complex128

MultiplyBy multiplies the original complex number with the complex number passed as argument

func (Complex128) Negate

func (c Complex128) Negate() Complex128

Negate Returns a complex number with same magnitude but opposite sign

func (Complex128) NthPower

func (c Complex128) NthPower(n float64) Complex128

NthPower Returns Nth Power of complex number

func (Complex128) NthRoot

func (c Complex128) NthRoot(n float64) Complex128

NthRoot Returns Nth root of complex number

func (Complex128) Phase

func (c Complex128) Phase() float64

Phase Returns the phase of complex number

func (Complex128) Polar

func (c Complex128) Polar() (float64, float64)

Polar Returns the magnitude and phase of complex number

func (Complex128) Real

func (c Complex128) Real() float64

Real Returns Real Part of Complex number

func (Complex128) Rotate

func (c Complex128) Rotate(angleInRadians float64) Complex128

Rotate Rotates a Complex Number by angle theta in radians

func (Complex128) Scale

func (c Complex128) Scale(scalingFactor float64) Complex128

Scale Scales a complex number with mentioned scaling factor

func (Complex128) Square

func (c Complex128) Square() Complex128

Square Returns Square of complex number

func (Complex128) SquareRoot

func (c Complex128) SquareRoot() Complex128

SquareRoot Returns Square root of complex number

func (Complex128) TranslateWithComplexNumber

func (c Complex128) TranslateWithComplexNumber(c1 Complex128) Complex128

TranslateWithComplexNumber Translates a complex number with another Complex number

func (Complex128) TranslateeWithVector

func (c Complex128) TranslateeWithVector(v [2]float64) Complex128

TranslateeWithVector Translates a complex number with a Vector

func (Complex128) Vector

func (c Complex128) Vector() []float64

Vector Returns an array of two elements where 1st element is the real part and 2nd the imaginary part

Jump to

Keyboard shortcuts

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