Class TensorFunction<NAMETYPE extends Name>

java.lang.Object
com.yahoo.tensor.functions.TensorFunction<NAMETYPE>
Direct Known Subclasses:
CompositeTensorFunction, PrimitiveTensorFunction

public abstract class TensorFunction<NAMETYPE extends Name> extends Object
A representation of a tensor function which is able to be translated to a set of primitive tensor functions if necessary. All tensor functions are immutable.
Author:
bratseth
  • Constructor Details

    • TensorFunction

      public TensorFunction()
  • Method Details

    • arguments

      public abstract List<TensorFunction<NAMETYPE>> arguments()
      Returns the function arguments of this node in the order they are applied
    • withArguments

      public abstract TensorFunction<NAMETYPE> withArguments(List<TensorFunction<NAMETYPE>> arguments)
      Returns a copy of this tensor function with the arguments replaced by the given list of arguments.
      Throws:
      IllegalArgumentException - if the argument list has the wrong size for this function
    • toPrimitive

      public abstract PrimitiveTensorFunction<NAMETYPE> toPrimitive()
      Translate this function - and all of its arguments recursively - to a tree of primitive functions only.
      Returns:
      a tree of primitive functions implementing this
    • evaluate

      public abstract Tensor evaluate(EvaluationContext<NAMETYPE> context)
      Evaluates this tensor.
      Parameters:
      context - a context which must be passed to all nested functions when evaluating
    • type

      public abstract TensorType type(TypeContext<NAMETYPE> context)
      Returns the type of the tensor this produces given the input types in the context
      Parameters:
      context - a context which must be passed to all nexted functions when evaluating
    • evaluate

      public final Tensor evaluate()
      Evaluate with no context
    • toString

      public abstract String toString(ToStringContext<NAMETYPE> context)
      Return a string representation of this context.
      Parameters:
      context - a context which must be passed to all nested functions when requesting the string value
    • asScalarFunction

      public Optional<ScalarFunction<NAMETYPE>> asScalarFunction()
      Returns this as a scalar function, or empty if it cannot be represented as a scalar function
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hashCode

      public abstract int hashCode()
      Returns a hashcode computed from the data in this
      Overrides:
      hashCode in class Object