cc.redberry.core.tensor
Class Product
- java.lang.Object
-
- cc.redberry.core.tensor.Tensor
-
- cc.redberry.core.tensor.MultiTensor
-
- cc.redberry.core.tensor.Product
-
public final class Product extends MultiTensor
Representation of product of mathematical expressions.The implementation keeps numerical factor, indexless multipliers, and multipliers with non empty free indices separately. If there is no numeric factor in product, it is equal to 1. Bot indexless and indexed data are sorted according to
Tensor.compareTo(Tensor)method. Indexed data is additionally sorted according to a special comparator based onStructureOfContractionsof this product.- Since:
- 1.0
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description Tensorget(int i)Returns element at i-th position.Tensor[]getAllScalars()Returns all scalar factors in this product.Tensor[]getAllScalarsWithoutFactor()Returns all scalar factors in this product excluding the numerical factor.TensorBuildergetBuilder()Creates a builder for this tensor.ProductContentgetContent()Returns the product content, i.e.TensorgetDataSubProduct()Returns the product of indexed (with non empty free indices) multipliers of this tensor.ComplexgetFactor()Returns numerical factor of this product.TensorFactorygetFactory()Returns a factory for this tensor.Tensor[]getIndexless()Returns a copy of indexless data.TensorgetIndexlessSubProduct()Returns indexless data as a product of tensors.IndicesgetIndices()Returns indices of this tensor.Tensor[]getRange(int from, int to)Retrieves several sub-tensors from current tensor.TensorgetSubProductWithoutFactor()Returns this product but without numeric factor.TensorgetWithoutFactor(int i)Returns element at i-th position excluding numerical factor of this product from numbering.Tensorremove(int position)Removes tensor at the specified position and returns the result.Tensorset(int i, Tensor tensor)Returns new tensor instance with i-th sub-tensor replaced by provided tensor.intsize()Returns the number of elements in this tensor.intsizeOfIndexlessPart()Returns the size of indexless part (including numerical factor).intsizeWithoutFactor()Returns the size of product without factor.java.lang.StringtoString(OutputFormat format)Returns a string representation of a tensor according to the specifiedOutputFormat.-
Methods inherited from class cc.redberry.core.tensor.MultiTensor
remove, remove, select
-
-
-
-
Method Detail
-
getIndices
public Indices getIndices()
Description copied from class:TensorReturns indices of this tensor.- Overrides:
getIndicesin classMultiTensor- Returns:
- indices of this tensor
-
get
public Tensor get(int i)
Description copied from class:TensorReturns element at i-th position.
-
getRange
public Tensor[] getRange(int from, int to)
Description copied from class:TensorRetrieves several sub-tensors from current tensor. This function is faster than sequential invocations ofTensor.get(int)method.
-
size
public int size()
Description copied from class:TensorReturns the number of elements in this tensor.
-
sizeWithoutFactor
public int sizeWithoutFactor()
Returns the size of product without factor. I.e. if factor is one, thensizeWithoutFactor() == size(), otherwisesizeWithoutFactor() == size() - 1.- Returns:
- size of product without factor
-
sizeOfIndexlessPart
public int sizeOfIndexlessPart()
Returns the size of indexless part (including numerical factor).- Returns:
- size of indexless part (including numerical factor)
-
set
public Tensor set(int i, Tensor tensor)
Description copied from class:TensorReturns new tensor instance with i-th sub-tensor replaced by provided tensor.
-
remove
public Tensor remove(int position)
Description copied from class:MultiTensorRemoves tensor at the specified position and returns the result.- Specified by:
removein classMultiTensor- Parameters:
position- position in tensor- Returns:
- result of removing
-
getWithoutFactor
public Tensor getWithoutFactor(int i)
Returns element at i-th position excluding numerical factor of this product from numbering. So, if factor is one, then this method returnsget(i), otherwise is returnsget(i-1).- Parameters:
i- position- Returns:
- element at i-th position excluding numerical factor of this product from numbering
-
getFactor
public Complex getFactor()
Returns numerical factor of this product.- Returns:
- numerical factor of this product
-
getContent
public ProductContent getContent()
Returns the product content, i.e. the information about the corresponding graph.- Returns:
- product content
-
getIndexless
public Tensor[] getIndexless()
Returns a copy of indexless data.- Returns:
- a copy of indexless data
-
getBuilder
public TensorBuilder getBuilder()
Description copied from class:TensorCreates a builder for this tensor. SeeTensorBuilderfor more information.- Specified by:
getBuilderin classTensor- Returns:
- builder for this tensor
-
getAllScalars
public Tensor[] getAllScalars()
Returns all scalar factors in this product. For example, if this is 2*a*f_mn*G^mn*f_a*T^ab, the result will be [2,a,f_mn*G^mn].- Returns:
- all scalar factors in this product
-
getAllScalarsWithoutFactor
public Tensor[] getAllScalarsWithoutFactor()
Returns all scalar factors in this product excluding the numerical factor. For example, if this is 2*a*f_mn*G^mn*f_a*T^ab, the result will be [a,f_mn*G^mn].- Returns:
- all scalar factors in this product excluding the numerical factor
-
getIndexlessSubProduct
public Tensor getIndexlessSubProduct()
Returns indexless data as a product of tensors.- Returns:
- indexless data as a product of tensors
-
getSubProductWithoutFactor
public Tensor getSubProductWithoutFactor()
Returns this product but without numeric factor.- Returns:
- this product but without numeric factor
-
getDataSubProduct
public Tensor getDataSubProduct()
Returns the product of indexed (with non empty free indices) multipliers of this tensor.- Returns:
- product of indexed (with non empty free indices) multipliers of this tensor
-
getFactory
public TensorFactory getFactory()
Description copied from class:TensorReturns a factory for this tensor. SeeTensorFactoryfor more information.- Specified by:
getFactoryin classTensor- Returns:
- builder for this tensor
-
toString
public java.lang.String toString(OutputFormat format)
Description copied from class:TensorReturns a string representation of a tensor according to the specifiedOutputFormat.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG