op

package
v0.0.0-...-62a0fd1 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package op defines the operators the user should use to define his Evaluator. When used, these operators update a State. At the end of the execution the miner can get an approximation of Evaluator's complexity.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type State

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

The State struct keeps track of the number of operation performed, in order to give an approximation of the complexity of the executed algorithm.

func MakeState

func MakeState(hash []byte) *State

Build a new State

func (*State) Abs

func (self *State) Abs(a any) any

Returns the absolute value of a numner and updates the State.

func (*State) Acos

func (self *State) Acos(a any) any

Returns the acos of a and updates the State.

func (*State) Acosh

func (self *State) Acosh(a any) any

Returns the acosh of a and updates the State.

func (*State) Add

func (self *State) Add(a, b any) any

Performs an addition and updates the State.

func (*State) And

func (self *State) And(a, b any) bool

Returns a & b and updates the State. Both operands are executed even if a is false.

func (*State) AppBool

func (self *State) AppBool(a *[]bool, b any)

Append a bool to a []bool and update the State.

func (*State) AppFloat32

func (self *State) AppFloat32(a *[]float32, b any)

Append a float32 to a []float32 and update the State.

func (*State) AppFloat64

func (self *State) AppFloat64(a *[]float64, b any)

Append a float64 to a []float64 and update the State.

func (*State) AppInt

func (self *State) AppInt(a *[]int, b any)

Append an int to a []int and update the State.

func (*State) AppInt16

func (self *State) AppInt16(a *[]int16, b any)

Append an int16 to a []int16 and update the State.

func (*State) AppInt32

func (self *State) AppInt32(a *[]int32, b any)

Append an int32 to a []int32 and update the State.

func (*State) AppInt64

func (self *State) AppInt64(a *[]int64, b any)

Append an int64 to a []int64 and update the State.

func (*State) AppInt8

func (self *State) AppInt8(a *[]int8, b any)

Append an int8 to a []int8 and update the State.

func (*State) AppString

func (self *State) AppString(a *[]string, b any)

Append a string to a []string and update the State.

func (*State) AppUint

func (self *State) AppUint(a *[]uint, b any)

Append an uint to a []uint and update the State.

func (*State) AppUint16

func (self *State) AppUint16(a *[]uint16, b any)

Append an uint16 to a []uint16 and update the State.

func (*State) AppUint32

func (self *State) AppUint32(a *[]uint32, b any)

Append an uint32 to a []uint32 and update the State.

func (*State) AppUint64

func (self *State) AppUint64(a *[]uint64, b any)

Append an uint64 to a []uint64 and update the State.

func (*State) AppUint8

func (self *State) AppUint8(a *[]uint8, b any)

Append an uint8 to a []uint8 and update the State.

func (*State) Asin

func (self *State) Asin(a any) any

Returns the asin of a and updates the State.

func (*State) Asinh

func (self *State) Asinh(a any) any

Returns the asinh of a and updates the State.

func (*State) Atan

func (self *State) Atan(a any) any

Returns the atan of a and updates the State.

func (*State) Atanh

func (self *State) Atanh(a any) any

Returns the atanh of a and updates the State.

func (*State) Ceil

func (self *State) Ceil(a any) any

Returns the smaller integer bigger than a and updates the State.

func (*State) Cos

func (self *State) Cos(a any) any

Returns the cos of a and updates the State.

func (*State) Cosh

func (self *State) Cosh(a any) any

Returns the cosh of a and updates the State.

func (*State) Div

func (self *State) Div(a, b any) any

Performs a division and updates the State.

func (*State) Eq

func (self *State) Eq(a, b any) bool

Returns a == b and updates the State.

func (*State) Exp

func (self *State) Exp(a any) any

Returns exp(a) and updates the State.

func (*State) Exp2

func (self *State) Exp2(a any) any

Returns the power 2^a and updates the State.

func (*State) Floor

func (self *State) Floor(a any) any

Returns the biggest integer smaller than a and updates the State.

func (*State) Ge

func (self *State) Ge(a, b any) bool

Returns a >= b and updates the State.

func (*State) Gt

func (self *State) Gt(a, b any) bool

Returns a > b and updates the State.

func (*State) IncOperations

func (self *State) IncOperations(n float64)

Increase the count of operations.

func (*State) Le

func (self *State) Le(a, b any) bool

Returns a <= b and updates the State.

func (*State) Log

func (self *State) Log(a any) any

Returns the natural logarithm of a and updates the State.

func (*State) Log10

func (self *State) Log10(a any) any

Returns the logarithm on base 10 of a and updates the State.

func (*State) Log2

func (self *State) Log2(a any) any

Returns the logarithm on base 2 of a and updates the State.

func (*State) Lt

func (self *State) Lt(a, b any) bool

Returns a < b and updates the State.

func (*State) Max

func (self *State) Max(a, b any) any

Returns the max of a and b and updates the State.

func (*State) Min

func (self *State) Min(a, b any) any

Returns the min of a and b and updates the State.

func (*State) Mod

func (self *State) Mod(a, b any) any

Returns the remainder a % b and updates the State.

func (*State) Mul

func (self *State) Mul(a, b any) any

Performs a multiplication and updates the State.

func (*State) Neg

func (self *State) Neg(a any) any

Returns -a if a is a numeric variable, or !a if a is a boolean variable; and updates the State.

func (*State) NumOperations

func (self *State) NumOperations() float64

Returns the approximation of the complexity of the executed code.

func (*State) Or

func (self *State) Or(a, b any) bool

Returns a | b and updates the State. Both operands are executed even if a is true.

func (*State) Pow

func (self *State) Pow(a, b any) any

Returns the power a^b and updates the State.

func (*State) Prec

func (self *State) Prec(a any) any

Returns a number decremented by 1 and updates the State.

func (*State) Reset

func (s *State) Reset()

Reset the count of operations that approximates the complexity of the executed code.

func (*State) Round

func (self *State) Round(a any) any

Rounds a to the nearest integer and updates the State.

func (*State) SetBlockHash

func (s *State) SetBlockHash(hash []byte)

Change the function's coefficients with the new block hash.

func (*State) SetBool

func (self *State) SetBool(a *bool, b any)

Assigns a bool to a variable and updates the State.

func (*State) SetFloat32

func (self *State) SetFloat32(a *float32, b any)

Assigns a float32 to a variable and updates the State.

func (*State) SetFloat64

func (self *State) SetFloat64(a *float64, b any)

Assigns a float64 to a variable and updates the State.

func (*State) SetInt

func (self *State) SetInt(a *int, b any)

Assigns an int to a variable and updates the State.

func (*State) SetInt16

func (self *State) SetInt16(a *int16, b any)

Assigns an int16 to a variable and updates the State.

func (*State) SetInt32

func (self *State) SetInt32(a *int32, b any)

Assigns an int32 to a variable and updates the State.

func (*State) SetInt64

func (self *State) SetInt64(a *int64, b any)

Assigns an int64 to a variable and updates the State.

func (*State) SetInt8

func (self *State) SetInt8(a *int8, b any)

Assigns an int8 to a variable and updates the State.

func (*State) SetString

func (self *State) SetString(a *string, b any)

Assigns a string to a variable and updates the State.

func (*State) SetUint

func (self *State) SetUint(a *uint, b any)

Assigns an uint to a variable and updates the State.

func (*State) SetUint16

func (self *State) SetUint16(a *uint16, b any)

Assigns an uint16 to a variable and updates the State.

func (*State) SetUint32

func (self *State) SetUint32(a *uint32, b any)

Assigns an uint32 to a variable and updates the State.

func (*State) SetUint64

func (self *State) SetUint64(a *uint64, b any)

Assigns an uint64 to a variable and updates the State.

func (*State) SetUint8

func (self *State) SetUint8(a *uint8, b any)

Assigns an uint8 to a variable and updates the State.

func (*State) Sin

func (self *State) Sin(a any) any

Returns the sin of a and updates the State.

func (*State) Sinh

func (self *State) Sinh(a any) any

Returns the sinh of a and updates the State.

func (*State) Sqrt

func (self *State) Sqrt(a any) any

Returns the square root of a and updates the State.

func (*State) Sub

func (self *State) Sub(a, b any) any

Performs a subtraction and updates the State.

func (*State) Succ

func (self *State) Succ(a any) any

Returns a number incremented by 1 and updates the State.

func (*State) Tan

func (self *State) Tan(a any) any

Returns the tan of a and updates the State.

func (*State) Tanh

func (self *State) Tanh(a any) any

Returns the tanh of a and updates the State.

Jump to

Keyboard shortcuts

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