Package cc.redberry.core.indices

Examples of cc.redberry.core.indices.IndicesBuilder


            if (indexlessData.isEmpty() && elements.size() == 1)
                return elements.get(0);
        }

        //Calculating product indices
        IndicesBuilder ibs = new IndicesBuilder();
        Indices indices;
        for (Tensor t : elements)
            ibs.append(t);
        try {
            indices = ibs.getIndices();
        } catch (InconsistentIndicesException exception) {
            throw new InconsistentIndicesException(exception.getIndex());
        }

        return new Product(indices, complex,
View Full Code Here


                indices = IndicesFactory.createSorted(dataContainer.list.get(0).getIndices());
            }
        } else {
            content = null;
            Arrays.sort(data);
            IndicesBuilder builder = new IndicesBuilder();
            for (i = dataContainer.list.size() - 1; i >= 0; --i)
                builder.append(dataContainer.list.get(i));
            try {
                indices = builder.getIndices();
            } catch (InconsistentIndicesException exception) {
                throw new InconsistentIndicesException(exception.getIndex());
            }
        }
View Full Code Here

                return new Sum(s.indices, sumData, s.hashCode());
            }
        }

        //Calculating product indices
        IndicesBuilder ibs = new IndicesBuilder();
        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()]));
    }
View Full Code Here

                indices = IndicesFactory.create(dataContainer.list.get(0).getIndices());
            }
        } else {
            content = null;
            Arrays.sort(data);
            IndicesBuilder builder = new IndicesBuilder();
            for (i = dataContainer.list.size() - 1; i >= 0; --i)
                builder.append(dataContainer.list.get(i));
            try {
                indices = builder.getIndices();
            } catch (InconsistentIndicesException exception) {
                throw new InconsistentIndicesException(exception.getIndex());
            }
        }
View Full Code Here

    }

    public Indices getIndices() {
        switch (tensorType) {
            case Product:
                IndicesBuilder builder = new IndicesBuilder();
                for (ParseNode node : content)
                    builder.append(node.getIndices());
                return builder.getIndices();
            case Sum:
                return IndicesFactory.createSorted(content[0].getIndices());
            case Power:
                return IndicesFactory.EMPTY_INDICES;
            case Expression:
View Full Code Here

                forbidden.forbidden.addAll(getAllIndicesNamesT(newTo));
            } else {
                TIntHashSet allowed = new TIntHashSet();
                for (int index : indexlessBijection)
                    allowed.addAll(TensorUtils.getAllDummyIndicesT(content.indexless[index]));
                IndicesBuilder ib = new IndicesBuilder();
                for (int index : dataBijection) {
                    allowed.addAll(TensorUtils.getAllDummyIndicesT(currentData[index]));
                    ib.append(currentData[index]);
                }
                allowed.addAll(ib.getIndices().getNamesOfDummies());
                allowed.removeAll(IndicesUtils.getIndicesNames(mapping.getToData()));
                newTo = applyIndexMappingAndRenameAllDummies(to, mapping, allowed.toArray());
            }
        }
        return new SubsResult(newTo, remainder);
View Full Code Here

            // mapping, since it is done automatically

            //putting scalar component
            powers.put(
                    new Product(
                            new IndicesBuilder().append(component.elements).getIndices(),
                            Complex.ONE,
                            new Tensor[0], //all tensors have indices with nonzero length
                            component.elements.toArray(new Tensor[component.elements.size()])));
        }
    }
View Full Code Here

                    sumData[i] = Tensors.negate(sumData[i]);
                return new Sum(s.indices, sumData, s.hashCode());
            }
        }

        return new Product(new IndicesBuilder().append(data).getIndices(),
                factor,
                indexLess.toArray(new Tensor[indexLess.size()]),
                data.toArray(new Tensor[data.size()]));
    }
View Full Code Here

            if (newData == null)
                // we can pass the hash code, since we did not changed the order of
                // indexless data, and its hash cannot been changed by the renaming of dummies
                return new Product(product.indices, product.factor, newIndexless, data, product.contentReference);

            return new Product(new IndicesBuilder().append(newData).getIndices(), product.factor, newIndexless, newData);
        }

        if (tensor instanceof Sum) {
            Sum sum = (Sum) tensor;
            Tensor[] data = sum.data, newData = null;
View Full Code Here

            if (newData == null)
                // we can pass the hash code, since we did not changed the order of
                // indexless data, and its hash cannot been changed by the renaming of dummies
                return new Product(product.indices, product.factor, newIndexless, data, product.contentReference);

            return new Product(new IndicesBuilder().append(newData).getIndices(), product.factor, newIndexless, newData);
        }

        if (tensor instanceof Sum) {
            Sum sum = (Sum) tensor;
            Tensor[] data = sum.data, newData = null;
View Full Code Here

TOP

Related Classes of cc.redberry.core.indices.IndicesBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.