amount

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2020 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Amount

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

Amount represents an amount in some commodity, along with a set of valuations.

func New

func New(amount decimal.Decimal, valuations []decimal.Decimal) Amount

New creates a new amount with value zero.

func (Amount) Amount

func (a Amount) Amount() decimal.Decimal

Amount returns the amount.

func (Amount) Equal

func (a Amount) Equal(b Amount) bool

Equal tests if both amounts are equal.

func (Amount) Minus

func (a Amount) Minus(b Amount) Amount

Minus computes the difference between two amounts.

func (Amount) Neg

func (a Amount) Neg() Amount

Neg computes the negation of this amount.

func (Amount) Plus

func (a Amount) Plus(b Amount) Amount

Plus computes the sum of two amounts.

func (Amount) String

func (a Amount) String() string

func (Amount) Valuation

func (a Amount) Valuation(i int) decimal.Decimal

Valuation returns the valuation at position i. If the valuation does not exist, 0 is returned.

type Vec

type Vec struct {
	Values []decimal.Decimal
}

Vec is a vector of decimals.

func NewVec

func NewVec(n int) Vec

NewVec creates a new vector.

func (Vec) Add

func (v Vec) Add(u Vec)

Add mutably adds the given vector to the receiver.

func (Vec) Neg

func (v Vec) Neg()

Neg mutably negates the given vector.

Jump to

Keyboard shortcuts

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