Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
Tensorics is a java framework which uses a tensor as a central object. A tensor represents a set of values placed in an N-dimensional space. Wherever you are tempted to use maps of maps, a tensor might be a good choice ;-) Tensorics provides methods to create, transform and performing calculations with those tensors.
// @formatter:off
/*******************************************************************************
*
* This file is part of tensorics.
*
* Copyright (c) 2008-2011, CERN. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
// @formatter:on
package org.tensorics.core.tensor;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.HashSet;
import java.util.Set;
import java.util.function.Function;
import com.google.common.base.Objects;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSet.Builder;
import com.google.common.collect.ImmutableSetMultimap;
import com.google.common.collect.Multimap;
import com.google.common.collect.Sets;
import com.google.common.collect.Sets.SetView;
/**
* Contains utility methods for position objects.
*
* @author kfuchsbe
*/
@SuppressWarnings("PMD.TooManyMethods")
public final class Positions {
/**
* private constructor to avoid instantiation
*/
private Positions() {
/* Only static methods */
}
/**
* Constructs a position, whose coordinates are the union of the coordinates of the two individual positions. This
* is only correctly defined, if the two given positions do not have any dimensional overlap (i.e. Any coordinate of
* a certain type (class) is only present in either the left or the right position.)
*
* @param left the first position to use construct the union position
* @param right the second position to construct the union position
* @return a position, which contains the union of the coordinates of the two input positions.
* @throws NullPointerException if one of the arguments is {@code null}
* @throws IllegalArgumentException if the given aguments have an overlap of dimensions and therefor the union of
* the position is not well defined
*/
public static Position union(Position left, Position right) {
checkNotNull(left, "left position must not be null.");
checkNotNull(right, "right position must not be null.");
checkArgument(Sets.intersection(left.dimensionSet(), right.dimensionSet()).isEmpty(),
"Positions have overlapping dimensions. It is not possible to create the union of them.");
SetView