bigc

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2022 License: MIT Imports: 8 Imported by: 1

README

bigc

GoDoc

Go (golang) library implementing rational complex numbers.

BigCは実部、虚部が共に有理数であるような複素数を扱うためのパッケージです。

Usage

type BigC
type BigC struct {
}

A BigC object represents a rational complex number.

BigCは複素数を表します。

func NewBigC
func NewBigC(r *big.Rat, i *big.Rat) *BigC

NewBigC creates a new BigC with real-part r and imaginary-part i.

func ParseString
func ParseString(expr string) (*BigC, error)

ParseString returns a new BigC instance of the result of the expression expr. Arithmetic operations and parentheses are supported.

func (*BigC) AbsSq
func (x *BigC) AbsSq() *big.Rat

Abs sets z to square of |x| (the absolute value of x) and returns z.

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

Add sets z to the sum x+y and returns z.

func (*BigC) Conj
func (z *BigC) Conj(x *BigC) *BigC

Conj sets z to the conjugate complex number of x and returns z.

func (*BigC) Equal
func (z *BigC) Equal(x *BigC) bool

Equal reports whether x equals z.

func (*BigC) FloatString
func (x *BigC) FloatString(prec int) string

FloatString returns a string representation of x in decimal form with prec digits of precision after the radix point. The last digit is rounded to nearest, with halves rounded away from zero.

func (*BigC) Imag
func (x *BigC) Imag() *big.Rat

Imag returns the imaginary-part of x. The result is a reference to x's imaginary-part; it may change if a new value is assigned to x, and vice versa.

func (*BigC) Inv
func (z *BigC) Inv(x *BigC) *BigC

Inv sets z to 1/x and returns z. If x == 0, Inv panics.

func (*BigC) IsPureImag
func (x *BigC) IsPureImag() bool

IsPureImag reports whether x is a pure imaginary number.

func (*BigC) IsReal
func (x *BigC) IsReal() bool

IsReal reports whether x is a real number.

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

Mul sets z to the product x*y and returns z.

func (*BigC) Neg
func (z *BigC) Neg(x *BigC) *BigC

Neg sets z to -x and returns z.

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

Quo sets z to the quotient x/y and returns z. If y == 0, Quo panics.

func (*BigC) Real
func (x *BigC) Real() *big.Rat

Real returns the real-part of x. The result is a reference to x's real-part; it may change if a new value is assigned to x, and vice versa.

func (*BigC) Set
func (z *BigC) Set(x *BigC) *BigC

Set sets z to x (by making a copy of x) and returns z.

func (*BigC) String
func (x *BigC) String() string

String returns a string exact representation of x.

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

Sub sets z to the difference x-y and returns z.

Documentation

Overview

Go (golang) library implementing rational complex numbers. BigCは実部、虚部が共に有理数であるような複素数を扱うためのパッケージです。 リポジトリは https://github.com/mathlava/bigc です。

Example
package main

import (
	"fmt"

	"github.com/mathlava/bigc"
)

func main() {
	ex, _ := bigc.ParseString("(1+2i)/(3-4i)")
	fmt.Println(ex.String())
}
Output:

-1/5+2i/5

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BigC

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

A BigC object represents a rational complex number. BigCは複素数を表します

func NewBigC

func NewBigC(r *big.Rat, i *big.Rat) *BigC

NewBigC creates a new BigC with real-part r and imaginary-part i.

func ParseString

func ParseString(expr string) (*BigC, error)

ParseString returns a new BigC instance of the result of the expression expr. Arithmetic operations and parentheses are supported.

func (*BigC) AbsSq

func (x *BigC) AbsSq() *big.Rat

Abs sets z to square of |x| (the absolute value of x) and returns z.

func (*BigC) Add

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

Add sets z to the sum x+y and returns z.

func (*BigC) Conj

func (z *BigC) Conj(x *BigC) *BigC

Conj sets z to the conjugate complex number of x and returns z.

func (*BigC) Equal

func (z *BigC) Equal(x *BigC) bool

Equal reports whether whether x equals z.

func (*BigC) FloatString

func (x *BigC) FloatString(prec int) string

FloatString returns a string representation of x in decimal form with prec digits of precision after the radix point. The last digit is rounded to nearest, with halves rounded away from zero.

func (*BigC) Imag

func (x *BigC) Imag() *big.Rat

Imag returns the imaginary-part of x. The result is a reference to x's imaginary-part; it may change if a new value is assigned to x, and vice versa.

func (*BigC) Inv

func (z *BigC) Inv(x *BigC) *BigC

Inv sets z to 1/x and returns z. If x == 0, Inv panics.

func (*BigC) IsPureImag

func (x *BigC) IsPureImag() bool

IsPureImag reports whether whether x is a pure imaginary number.

func (*BigC) IsReal

func (x *BigC) IsReal() bool

IsReal reports whether whether x is a real number.

func (*BigC) Mul

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

Mul sets z to the product x*y and returns z.

func (*BigC) Neg

func (z *BigC) Neg(x *BigC) *BigC

Neg sets z to -x and returns z.

func (*BigC) Quo

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

Quo sets z to the quotient x/y and returns z. If y == 0, Quo panics.

func (*BigC) Real

func (x *BigC) Real() *big.Rat

Real returns the real-part of x. The result is a reference to x's real-part; it may change if a new value is assigned to x, and vice versa.

func (*BigC) Set

func (z *BigC) Set(x *BigC) *BigC

Set sets z to x (by making a copy of x) and returns z.

func (*BigC) String

func (x *BigC) String() string

String returns a string exact representation of x.

func (*BigC) Sub

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

Sub sets z to the difference x-y and returns z.

Directories

Path Synopsis
math
rho

Jump to

Keyboard shortcuts

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