kgp.tree / Function

Function

abstract class Function : Node

A node that can perform some function on a set of arguments.

Function nodes make up the inner nodes of a program tree.

Constructors

<init> Function(arity: Int, representation: String)

A node that can perform some function on a set of arguments.

Properties

arity open val arity: Int

The number of arguments this function operates on.

operation abstract val operation: Operation

An operation that this function performs when evaluated.

representation val representation: String

A representation of this function that can be output.

Functions

evaluate open fun evaluate(args: List<Double>): Double

Evaluates this function on the given arguments.

Inheritors

Addition class Addition : Function

Adds two arguments together (x + y).

Cosine class Cosine : Function

Performs the cosine function on a single argument (cos(x))

Cube class Cube : Function

Cubes a single argument (x^3).

Division class Division : Function

Divides one argument by the other in a protected manner (x / if (x == 0) 1.0 else y).

Exponent class Exponent : Function

Performs the exponent function on two arguments (|x|^y).

HyperbolicTangent class HyperbolicTangent : Function

Performs the hyperbolic tangent function on a single argument (tanh(x)).

Inverse class Inverse : Function

Performs the inverse function on a single argument (1 / x).

Multiplication class Multiplication : Function

Multiplies two arguments together (x * y).

NaturalLog class NaturalLog : Function

Performs the natural log function on a single argument (ln(x)).

Negation class Negation : Function

Performs the negation function on a single argument (-x).

Sine class Sine : Function

Performs the sine function on a single argument (sin(x))

Square class Square : Function

Squares a single argument (x^2).

SquareRoot class SquareRoot : Function

Performs the square root function on a single argument (sqrt(x)).

Subtraction class Subtraction : Function

Subtracts one argument from the other (x - y).

Tangent class Tangent : Function

Performs the tangent function on a single argument (tan(x)).