Documentation of 'cc.redberry.core.indexmapping.Mapping' Java class
Mapping
cc.redberry.core.indexmapping

Class Mapping

  • All Implemented Interfaces:
    Transformation


    public final class Mapping
    extends java.lang.Object
    implements Transformation
    This is the main class which represents the mapping from one tensor to another.

    Mapping implements Transformation and perform transformation by simple invocation of ApplyIndexMapping.applyIndexMappingAutomatically(cc.redberry.core.tensor.Tensor, Mapping) ))} with this as a second argument.

    The underlying data structure is a simple pair of sorted arrays fromNames and toData, such that i-th mapping entry is fromNames[i] -> toData[i]. The array fromNames contains from indices names. The array toData contains names of to indices where the first bit indicates whether the state of from index should be inverted.

    Since:
    1.1.5
    • Constructor Summary

      Constructors 
      Constructor and Description
      Mapping(int[] from, int[] to)
      Creates mapping from given from and to arrays of indices.
      Mapping(int[] from, int[] to, boolean sign)
      Creates mapping from given from and to arrays of indices.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      Mapping addSign(boolean sign)
      Returns mapping, formed from this mapping by multiplying by specified sign.
      boolean equals(java.lang.Object o) 
      IntArray getFromNames()
      Returns the names of from indices.
      boolean getSign()
      Returns the sign of this mapping
      IntArray getToData()
      Returns the data array that represents to indices.
      int hashCode() 
      boolean isEmpty()
      Returns true if this mapping does not contain any entries (however, it can have negative sign).
      boolean isIdentity()
      Returns true if this mapping does not contain any entries and have positive sign.
      int size()
      Returns the number of entries in this mapping.
      java.lang.String toString() 
      Tensor transform(Tensor t)
      Transforms specified tensor and returns the result.
      static Mapping valueOf(java.lang.String string)
      Parses string representation of Mapping in the form -{a->b, ^c->_d} etc.
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • IDENTITY

        public static final Mapping IDENTITY
        Identity mapping
    • Constructor Detail

      • Mapping

        public Mapping(int[] from,
                       int[] to)
        Creates mapping from given from and to arrays of indices.
        Parameters:
        from - indices from
        to - indices to
      • Mapping

        public Mapping(int[] from,
                       int[] to,
                       boolean sign)
        Creates mapping from given from and to arrays of indices.
        Parameters:
        from - indices from
        to - indices to
        sign - the sign of mapping
    • Method Detail

      • transform

        public Tensor transform(Tensor t)
        Description copied from interface: Transformation
        Transforms specified tensor and returns the result.
        Specified by:
        transform in interface Transformation
        Parameters:
        t - tensor
        Returns:
        transformed tensor
      • isEmpty

        public boolean isEmpty()
        Returns true if this mapping does not contain any entries (however, it can have negative sign).
        Returns:
        true if this mapping does not contain any entries (however, it can have negative sign)
        See Also:
        isIdentity()
      • isIdentity

        public boolean isIdentity()
        Returns true if this mapping does not contain any entries and have positive sign.
        Returns:
        true if this mapping does not contain any entries and have positive sign.
      • getSign

        public boolean getSign()
        Returns the sign of this mapping
        Returns:
        sign of this mapping
      • addSign

        public Mapping addSign(boolean sign)
        Returns mapping, formed from this mapping by multiplying by specified sign.
        Parameters:
        sign - false - plus, true - minus one
        Returns:
        a new mapping, formed from this mapping by multiplying by specified sign
      • size

        public int size()
        Returns the number of entries in this mapping.
        Returns:
        the number of entries in this mapping
      • getFromNames

        public IntArray getFromNames()
        Returns the names of from indices.
        Returns:
        names of from indices
      • getToData

        public IntArray getToData()
        Returns the data array that represents to indices.
        Returns:
        data array that represents to indices.
      • equals

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

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

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

        public static Mapping valueOf(java.lang.String string)
        Parses string representation of Mapping in the form -{a->b, ^c->_d} etc.
        Parameters:
        string - string representation of mapping in the form -{a->b, ^c->_d} etc.
        Returns:
        mapping

DataMelt 3.0 © DataMelt by jWork.ORG

Ads help maintain this website.