cc.redberry.core.indexmapping
Class Mapping
- java.lang.Object
-
- cc.redberry.core.indexmapping.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.MappingimplementsTransformationand perform transformation by simple invocation ofApplyIndexMapping.applyIndexMappingAutomatically(cc.redberry.core.tensor.Tensor, Mapping)))} withthisas a second argument.The underlying data structure is a simple pair of sorted arrays
fromNamesandtoData, such that i-th mapping entry isfromNames[i] -> toData[i]. The arrayfromNamescontains from indices names. The arraytoDatacontains names of to indices where the first bit indicates whether the state of from index should be inverted.- Since:
- 1.1.5
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface cc.redberry.core.transformations.Transformation
Transformation.Util
-
-
Field Summary
Fields Modifier and Type Field and Description static MappingIDENTITYIdentity mapping-
Fields inherited from interface cc.redberry.core.transformations.Transformation
INDENTITY
-
-
Constructor Summary
Constructors Constructor and Description Mapping(int[] from, int[] to)Creates mapping from givenfromandtoarrays of indices.Mapping(int[] from, int[] to, boolean sign)Creates mapping from givenfromandtoarrays of indices.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description MappingaddSign(boolean sign)Returns mapping, formed from this mapping by multiplying by specified sign.booleanequals(java.lang.Object o)IntArraygetFromNames()Returns the names of from indices.booleangetSign()Returns the sign of this mappingIntArraygetToData()Returns the data array that represents to indices.inthashCode()booleanisEmpty()Returnstrueif this mapping does not contain any entries (however, it can have negative sign).booleanisIdentity()Returnstrueif this mapping does not contain any entries and have positive sign.intsize()Returns the number of entries in this mapping.java.lang.StringtoString()Tensortransform(Tensor t)Transforms specified tensor and returns the result.static MappingvalueOf(java.lang.String string)Parses string representation of Mapping in the form -{a->b, ^c->_d} etc.
-
-
-
Field Detail
-
IDENTITY
public static final Mapping IDENTITY
Identity mapping
-
-
Constructor Detail
-
Mapping
public Mapping(int[] from, int[] to)Creates mapping from givenfromandtoarrays of indices.- Parameters:
from- indices fromto- indices to
-
Mapping
public Mapping(int[] from, int[] to, boolean sign)Creates mapping from givenfromandtoarrays of indices.- Parameters:
from- indices fromto- indices tosign- the sign of mapping
-
-
Method Detail
-
transform
public Tensor transform(Tensor t)
Description copied from interface:TransformationTransforms specified tensor and returns the result.- Specified by:
transformin interfaceTransformation- Parameters:
t- tensor- Returns:
- transformed tensor
-
isEmpty
public boolean isEmpty()
Returnstrueif this mapping does not contain any entries (however, it can have negative sign).- Returns:
trueif this mapping does not contain any entries (however, it can have negative sign)- See Also:
isIdentity()
-
isIdentity
public boolean isIdentity()
Returnstrueif this mapping does not contain any entries and have positive sign.- Returns:
trueif 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:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.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