All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cc.redberry.core.indexmapping.IndexMappingBuffer Maven / Gradle / Ivy

Go to download

Redberry is an open source computer algebra system designed for tensor manipulation. It implements basic computer algebra system routines as well as complex tools for real computations in physics. This is Redberry core, which contains the implementation of the basic computer algebra routines and general-purpose transformations.

There is a newer version: 1.1.10
Show newest version
/*
 * Redberry: symbolic tensor computations.
 *
 * Copyright (c) 2010-2014:
 *   Stanislav Poslavsky   
 *   Bolotin Dmitriy       
 *
 * This file is part of Redberry.
 *
 * Redberry is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Redberry is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Redberry. If not, see .
 */
package cc.redberry.core.indexmapping;

import gnu.trove.map.hash.TIntObjectHashMap;

/**
 * Intermediate representation of mapping of indices needed inside the index mapping calculation pipeline (the basic
 * implementation idea could be found in the description of {@link IndexMappingProvider}).
 *
 * @author Dmitry Bolotin
 * @author Stanislav Poslavsky
 * @since 1.0
 */
interface IndexMappingBuffer {
    /**
     * Tries to put the mapping entry {@code from->to}
     *
     * @param from from index
     * @param to   to index
     * @return {@code true} if new mapping entry was created or {@code false} if this mapping is inconsistent with
     *         previously added (other mapping to -> from1, where from1 != from, exists)
     */
    boolean tryMap(int from, int to);

    /**
     * Multiplies the sign of this mapping on the specified one
     *
     * @param sign sign ({@code true} states '-' and {@code false} states '+')
     */
    void addSign(boolean sign);

    /**
     * Removes entries for contracted indices (like e.g. _i->_k, ^i->^k)
     */
    void removeContracted();

    /**
     * Returns whether this mapping is empty
     *
     * @return {@code true} if no entries in mapping exist
     */
    boolean isEmpty();

    /**
     * Returns sign of this mapping ({@code true} states '-' and {@code false} states '+')
     *
     * @return sign of this mapping ({@code true} states '-' and {@code false} states '+')
     */
    boolean getSign();

    /**
     * NOT PUBLIC API
     *
     * @return NOT PUBLIC API
     */
    FromToHolder export();

    /**
     * Returns the internal mapping container.
     *
     * @return the internal mapping container
     */
    TIntObjectHashMap getMap();

    /**
     * Returns a deep copy of this mapping.
     *
     * @return a deep copy of this mapping
     */
    IndexMappingBuffer clone();
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy