/** * Returns the product of indexed (with non empty free indices) multipliers of this tensor. * * @return product of indexed (with non empty free indices) multipliers of this tensor */ public Tensor getDataSubProduct() { if (data.length == 0) return Complex.ONE; if (data.length == 1) return data[0]; return new Product(indices, Complex.ONE, new Tensor[0], data, contentReference); }
/** * Returns this product but without numeric factor. * * @return this product but without numeric factor */ public Tensor getSubProductWithoutFactor() { if (factor == Complex.ONE) return this; return new Product(indices, Complex.ONE, indexlessData, data, contentReference); }
private static Tensor createProduct(Indices indices, Complex factor, Tensor[] indexless, Tensor[] data) { if (indexless.length == 0 && data.length == 0) return factor; if (factor == Complex.ONE) { if (indexless.length == 0 && data.length == 1) return data[0]; if (indexless.length == 1 && data.length == 0) return indexless[0]; } return new Product(indices, factor, indexless, data); }
/** * Returns indexless data as a product of tensors. * * @return indexless data as a product of tensors */ public Tensor getIndexlessSubProduct() { if (indexlessData.length == 0) return factor; else if (factor == Complex.ONE && indexlessData.length == 1) return indexlessData[0]; else return new Product(factor, indexlessData, new Tensor[0], ProductContent.EMPTY_INSTANCE, IndicesFactory.EMPTY_INDICES); }
@Override protected Tensor select1(int[] positions) { int add = factor == Complex.ONE ? 0 : 1; Complex newFactor = Complex.ONE; List<Tensor> newIndexless = new ArrayList<>(), newData = new ArrayList<>(); for (int position : positions) { position -= add; if (position == -1) newFactor = factor; else if (position < indexlessData.length) newIndexless.add(indexlessData[position]); else newData.add(data[position - indexlessData.length]); } return new Product(new IndicesBuilder().append(newData).getIndices(), newFactor, newIndexless.toArray(new Tensor[newIndexless.size()]), newData.toArray(new Tensor[newData.size()])); }
return new Product(new IndicesBuilder().append(data).getIndices(), factor, indexLess.toArray(new Tensor[indexLess.size()]),
for (Tensor m : elements) ibs.append(m); return new Product(ibs.getIndices(), factor, indexLess.toArray(new Tensor[indexLess.size()]), elements.toArray(new Tensor[elements.size()]));
return new Product(indices, complex, indexlessData, data, contentReference); return new Product(indices, complex, newIndexless, data, contentReference); } else { Tensor[] newData = ArraysUtils.remove(data, i - indexlessData.length); return new Product(new IndicesBuilder().append(newData).getIndices(), complex, indexlessData, newData);
factor = product.get(1); else//case 2*a*b => factor = a*b factor = new Product(Complex.ONE, product.indexlessData, product.data, product.contentReference.getReferent(), product.indices); } else { complex = Complex.ONE; summand = new Sum(s.indices, sumData, s.hashCode()); } else summand = new Product(product.factor, product.indexlessData, new Tensor[0], ProductContent.EMPTY_INSTANCE, IndicesFactory.EMPTY_INDICES); factor = new Product(Complex.ONE, new Tensor[0], product.data, product.contentReference.getReferent(), product.indices); } else { summand = Complex.ONE;
return new Product(factor, indexless, data, content, indices);
new Product( new IndicesBuilder().append(component.elements).getIndices(), Complex.ONE,
} else summand = new Product(product.factor, product.indexlessData, new Tensor[0], ProductContent.EMPTY_INSTANCE, IndicesFactory.EMPTY_INDICES); else if (dataLength == 1 && product.indexlessData.length == 0 && product.factor == Complex.ONE) summand = scalars[0]; summand = new Product(product.factor, product.indexlessData, data, null, ib.getIndices());
Tensor[] newIndexless = indexlessData.clone(); newIndexless[i] = tensor; return new Product(indices, newFactor, newIndexless, data, contentReference); } else { Tensor[] newData = data.clone(); newData[i - indexlessData.length] = tensor; return new Product(new IndicesBuilder().append(newData).getIndices(), newFactor, indexlessData, newData);
nonScalar = data[0]; else nonScalar = new Product(this.indices, Complex.ONE, new Tensor[0], data, this.contentReference, 0);
if (indexless == null) indexless = p.indexlessData;//no cloning return new Product(p.indices, p.factor, indexless, data, p.contentReference, p.hash);