Class InnerTensorOperation<V>

  • Type Parameters:
    V -
    All Implemented Interfaces:
    java.io.Serializable, BinaryFunction<Tensor<V>,​Tensor<V>>, BinaryOperation<Tensor<V>>

    public class InnerTensorOperation<V>
    extends java.lang.Object
    implements BinaryOperation<Tensor<V>>, java.io.Serializable
    Represents a binary operation on tensorics, respecting the equivalent of Einstein Summation Convention in tensorics representation. The details are as follows:

    Since every tensor within the tensorics framework, has to have unique classes for the tensor dimensions (equivalent to the 'indizes' in a usual tensor notation), it is only possible to have at maximum one index (dimension) of the same type in a tensor. Such coordinates are considered per default as contravariant coordinates (indizes). To consistently describe a inner product it is necessary to have corresponding covariant indizes (dimensions in tensorics). This can be achieved by using classes that are derived from the Covariant class.

    The most common of the type of operations, represented by this class, is the inner tensor product. However, this operation is designed to be a bit more general, it uses two provided operations:

    • A binary operation on the type of the tensor values, by which the the elements of the two tensors are treated.
    • An operation on iterables of the tensor values, which is used to reduce the tensor dimension, if applicable (see below). NOTE: This operation must be associative, because it is performed in all directions at the same time. (The user of this class has to take care about this, but it is currently not enforced by the class design).
    Using these preconditions, this operation applies the following rules:
    1. The usual broadcasting and shaping rules are applied (with a modification, which take care about the correct mapping of co- and contravariant dimensions)
    2. The element-wise binary operation is applied on all the elements
    3. For each dimension, where there is a covariant version in one tensor and a contravariant version in the other tensor, the reduction operation is applied. If one tensor contains both variants and the other only one, then the order the operation still is uniquely defined and the order of the operands (left, right) does not matter. However, if both tensors contain both variants, then the contravariant (default) dimension of the right tensor is reduced together with the covariant dimension of the left tensor. This is equivalent (and can be memorized like) the usual matrix multiplication.
    4. The result will always be contravariant
    See Also:
    Covariant, Covariants, Serialized Form
    • Method Detail

      • perform

        public Tensor<V> perform​(Tensor<V> left,
                                 Tensor<V> right)
        Description copied from interface: BinaryFunction
        Has to be implemented to perform the actual operation. The order of operands might be important or not, depending, if the operation is commutative or not.
        Specified by:
        perform in interface BinaryFunction<Tensor<V>,​Tensor<V>>
        Parameters:
        left - the left operand to be used in the operation
        right - the right operand to be used in the operation
        Returns:
        the result of the operation
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object