vectorIntNodes

package
v2.1.0 Latest Latest
Warning

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

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

Documentation

Overview

Package vectorIntNodes defines the vector of integers function collection available for the GEP algorithm.

Index

Constants

This section is empty.

Variables

View Source
var VectorIntFuncs = functions.FuncMap{

	"+": VectorIntNode{0, "+", 2, func(x []VectorInt) VectorInt {
		op := func(in []int) (result int) {
			for i := 0; i < 2; i++ {
				result += in[i]
			}
			return result
		}
		return ProcessVector(x, op)
	}},
	"-": VectorIntNode{1, "-", 2, func(x []VectorInt) VectorInt {
		op := func(in []int) (result int) {
			result = in[0]
			for i := 1; i < 2; i++ {
				result -= in[i]
			}
			return result
		}
		return ProcessVector(x, op)
	}},
	"*": VectorIntNode{2, "*", 2, func(x []VectorInt) VectorInt {
		op := func(in []int) (result int) {
			result = in[0]
			for i := 1; i < 2; i++ {
				result *= in[i]
			}
			return result
		}
		return ProcessVector(x, op)
	}},
	"/": VectorIntNode{3, "/", 2, func(x []VectorInt) VectorInt {
		op := func(in []int) (result int) {
			result = in[0]
			for i := 1; i < 2; i++ {
				if in[0] == 0 {
					result = 0
				} else {
					result /= in[i]
				}
			}
			return result
		}
		return ProcessVector(x, op)
	}},
}

Int lists all the available vector of integers functions for this package.

Functions

This section is empty.

Types

type VectorInt

type VectorInt = functions.VectorInt

func ProcessVector

func ProcessVector(x []VectorInt, op sliceOp) (result VectorInt)

ProcessVector is a helper function that processes each index of an array of VectorInts.

type VectorIntNode

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

VectorIntNode is a vector of integers function used for the formation of GEP expressions.

func (VectorIntNode) BoolFunction

func (n VectorIntNode) BoolFunction([]bool) bool

BoolFunction is unused in this package and returns an error.

func (VectorIntNode) Float64Function

func (n VectorIntNode) Float64Function([]float64) float64

Float64Function is unused in this package and returns an error.

func (VectorIntNode) IntFunction

func (n VectorIntNode) IntFunction([]int) int

IntFunction calls the vector of integers function and returns the result.

func (VectorIntNode) Symbol

func (n VectorIntNode) Symbol() string

Symbol returns the Karva symbol for this vector of integers function.

func (VectorIntNode) Terminals

func (n VectorIntNode) Terminals() int

Terminals returns the number of input terminals for this vector of integers function.

func (VectorIntNode) VectorIntFunction

func (n VectorIntNode) VectorIntFunction(x []VectorInt) VectorInt

VectorIntFunction allows FuncMap to implement interace functions.FuncMap.

Jump to

Keyboard shortcuts

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