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

org.tensorics.core.reduction.AbstractLinearDoubleInterpolationStrategy Maven / Gradle / Ivy

Go to download

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.

There is a newer version: 0.0.81
Show newest version
/**
 * Copyright (c) 2015 European Organisation for Nuclear Research (CERN), All Rights Reserved.
 */

package org.tensorics.core.reduction;

import java.util.List;

import org.tensorics.core.tensor.Tensor;

/**
 * An abstract implementation for the linear interpolation of the {@link Double} {@link Tensor}.
 * 

* It returns a value based on the ratio in the comparable (ie. time) domain, between the reference point(t_i) and the * pair of the one before(t_1) and after(t_2) like:
*
* ratio = (t_i - t_1)/(t_2 - t_1) *

* The final interpolated value is: v_i = v(t_1)+(v(t_2)-v(t_1))*ratio. * * @author agorzaws * @param type of the coordinate, must be the {@link Comparable} */ public abstract class AbstractLinearDoubleInterpolationStrategy> extends AbstractInterpolationStrategy { @Override public Double getInterpolatedValue(Tensor tensorWithTheOnlyOneCoordinateOfC, C coordineteToInterpolate) { List orderedList = getOrderedListOfComparableCoodrinate(tensorWithTheOnlyOneCoordinateOfC, coordineteToInterpolate); C thePreviousComparable = findIndex(orderedList, coordineteToInterpolate, 0); C theNextComparable = findIndex(orderedList, coordineteToInterpolate, 1); Double firstPoint = tensorWithTheOnlyOneCoordinateOfC.get(thePreviousComparable); return firstPoint + (tensorWithTheOnlyOneCoordinateOfC.get(theNextComparable) - firstPoint) * ratio(thePreviousComparable, theNextComparable, coordineteToInterpolate); } public abstract double ratio(C previousComparable, C nextComparable, C value); }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy