Class TensorFunction<NAMETYPE extends Name>

  • 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 Detail

      • TensorFunction

        public TensorFunction()
    • Method Detail

      • arguments

        public abstract List<TensorFunction<NAMETYPE>> arguments()
        Returns the function arguments of this node in the order they are applied
      • 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 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