polynomial

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: May 9, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFloat

func NewFloat(f float64) *big.Float

func NewFloatFromInt

func NewFloatFromInt(i int64) *big.Float

Types

type Addition

type Addition struct {
	Left, Right Expression
}

func (*Addition) Evaluate

func (a *Addition) Evaluate(variables map[string]*big.Float) (*big.Float, error)

func (*Addition) String

func (a *Addition) String() string

print Add

func (*Addition) Variables

func (a *Addition) Variables() map[string]struct{}

Variables

type Division

type Division struct {
	Left, Right Expression
}

func (*Division) Evaluate

func (d *Division) Evaluate(variables map[string]*big.Float) (*big.Float, error)

func (*Division) String

func (d *Division) String() string

Division

func (*Division) Variables

func (d *Division) Variables() map[string]struct{}

type Expression

type Expression interface {
	Evaluate(variables map[string]*big.Float) (*big.Float, error)
	String() string

	// Variables returns a map of all variables used in the expression.
	// For example, the expression "4a + 2b" would return a map with keys "a" and "b".
	Variables() map[string]struct{}
}

func Add

func Add(a, b Expression) Expression

func Div

func Div(a, b Expression) Expression

func Log

func Log(a Expression, base ...Expression) Expression

Log returns the logarithm of a with base "base". If base is not provided, it defaults to 2.

func Mul

func Mul(a, b Expression) Expression

func Sub

func Sub(a, b Expression) Expression

func WeightedVar

func WeightedVar(name string, weight *big.Float) Expression

type Logarithm

type Logarithm struct {
	Base, Expression Expression
}

func (*Logarithm) Evaluate

func (l *Logarithm) Evaluate(variables map[string]*big.Float) (*big.Float, error)

func (*Logarithm) String

func (l *Logarithm) String() string

Logarithm

func (*Logarithm) Variables

func (l *Logarithm) Variables() map[string]struct{}

type Multiply

type Multiply struct {
	Left, Right Expression
}

func (*Multiply) Evaluate

func (m *Multiply) Evaluate(variables map[string]*big.Float) (*big.Float, error)

func (*Multiply) String

func (m *Multiply) String() string

Multiply

func (*Multiply) Variables

func (m *Multiply) Variables() map[string]struct{}

type Variable

type Variable struct {
	Name string
}

func (*Variable) Evaluate

func (v *Variable) Evaluate(variables map[string]*big.Float) (*big.Float, error)

func (*Variable) String

func (v *Variable) String() string

Variable

func (*Variable) Variables

func (v *Variable) Variables() map[string]struct{}

type Weight

type Weight struct {
	Value *big.Float
}

func NewWeight

func NewWeight(f float64) *Weight

func (*Weight) Evaluate

func (w *Weight) Evaluate(_ map[string]*big.Float) (*big.Float, error)

func (*Weight) String

func (w *Weight) String() string

Weight

func (*Weight) Variables

func (w *Weight) Variables() map[string]struct{}

Jump to

Keyboard shortcuts

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