Class SortedDoublesArithmetic
- java.lang.Object
-
- com.metsci.glimpse.util.primitives.sorted.SortedDoublesArithmetic
-
- All Implemented Interfaces:
Doubles,SortedDoubles
public class SortedDoublesArithmetic extends Object implements SortedDoubles
- Author:
- hogye
-
-
Field Summary
Fields Modifier and Type Field Description doublehalfVStepintndoubleoneOverVStepdoublev0doublevStep
-
Constructor Summary
Constructors Constructor Description SortedDoublesArithmetic(double v0, double vStep, int n)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static BigDecimalbig(double x)ContinuousIndexcontinuousIndexOf(double x)The continuous index at which x falls in this sequence.voidcontinuousIndexOf(double x, ContinuousIndex result)The continuous index at which x falls in this sequence.ContinuousIndexArraycontinuousIndicesIn(SortedDoubles xs)Like continuousIndicesOf, but in reverse: for each v in this sequence, the continuous index at which v falls in xs.ContinuousIndexArraycontinuousIndicesOf(Doubles xs)For each x in xs, the continuous index at which x falls in this sequence.voidcontinuousIndicesOf(Doubles xs, ContinuousIndexArray result)For each x in xs, the continuous index at which x falls in this sequence.ContinuousIndexArraycontinuousIndicesOf(SortedDoubles xs)For each x in xs, the continuous index at which x falls in this sequence.voidcontinuousIndicesOf(SortedDoubles xs, ContinuousIndexArray result)For each x in xs, the continuous index at which x falls in this sequence.SortedDoublesArithmeticcopy()double[]copyOf()double[]copyOf(int i, int c)voidcopyTo(int i, double[] dest, int iDest, int c)voidcopyTo(int i, DoubleBuffer dest, int c)voidcopyTo(DoubleBuffer dest)doublefirst()intindexAfter(double x)Smallest index whose value is greater than xintindexAtOrAfter(double x)Smallest index whose value is greater than or equal to xintindexAtOrBefore(double x)Largest index whose value is less than or equal to xintindexBefore(double x)Largest index whose value is less than xintindexNearest(double x)Index of the value closest to x.intindexOf(double x)Follows the convention ofArrays.binarySearch(double[], double): Ifxis contained in this sequence, returns the index ofxOtherwise, returns (-insertionPoint - 1)booleanisEmpty()doublelast()intn()Length of the sequencedoublev(int i)Value at index i
-
-
-
Constructor Detail
-
SortedDoublesArithmetic
public SortedDoublesArithmetic(double v0, double vStep, int n)- Throws:
IllegalArgumentException- ifv0is NaN, orv0is infinite, orvStepis NaN, orvStepis infinite, orvStepis non-positive, ornis negative, or(v0 + (n-1)*vStep)is greater thanDouble.MAX_VALUE
-
-
Method Detail
-
big
public static BigDecimal big(double x)
-
v
public double v(int i)
Description copied from interface:DoublesValue at index i
-
n
public int n()
Description copied from interface:DoublesLength of the sequence
-
copyTo
public void copyTo(int i, double[] dest, int iDest, int c)
-
copyTo
public void copyTo(int i, DoubleBuffer dest, int c)
-
copyTo
public void copyTo(DoubleBuffer dest)
-
copy
public SortedDoublesArithmetic copy()
- Specified by:
copyin interfaceDoubles- Specified by:
copyin interfaceSortedDoubles
-
indexOf
public int indexOf(double x)
Description copied from interface:SortedDoublesFollows the convention ofArrays.binarySearch(double[], double):- If
xis contained in this sequence, returns the index ofx - Otherwise, returns (-insertionPoint - 1)
- Specified by:
indexOfin interfaceSortedDoubles- See Also:
Arrays.binarySearch(double[], double)
- If
-
indexNearest
public int indexNearest(double x)
Description copied from interface:SortedDoublesIndex of the value closest to x. If the two closest values are x-C and x+C, returns the index of x+C. If doubles is empty, returns -1.- Specified by:
indexNearestin interfaceSortedDoubles
-
indexBefore
public int indexBefore(double x)
Description copied from interface:SortedDoublesLargest index whose value is less than x- Specified by:
indexBeforein interfaceSortedDoubles
-
indexAfter
public int indexAfter(double x)
Description copied from interface:SortedDoublesSmallest index whose value is greater than x- Specified by:
indexAfterin interfaceSortedDoubles
-
indexAtOrBefore
public int indexAtOrBefore(double x)
Description copied from interface:SortedDoublesLargest index whose value is less than or equal to x- Specified by:
indexAtOrBeforein interfaceSortedDoubles
-
indexAtOrAfter
public int indexAtOrAfter(double x)
Description copied from interface:SortedDoublesSmallest index whose value is greater than or equal to x- Specified by:
indexAtOrAfterin interfaceSortedDoubles
-
continuousIndexOf
public void continuousIndexOf(double x, ContinuousIndex result)Description copied from interface:SortedDoublesThe continuous index at which x falls in this sequence.- Specified by:
continuousIndexOfin interfaceSortedDoubles- See Also:
ContinuousIndex
-
continuousIndexOf
public ContinuousIndex continuousIndexOf(double x)
Description copied from interface:SortedDoublesThe continuous index at which x falls in this sequence.- Specified by:
continuousIndexOfin interfaceSortedDoubles- See Also:
ContinuousIndex
-
continuousIndicesOf
public void continuousIndicesOf(Doubles xs, ContinuousIndexArray result)
Description copied from interface:SortedDoublesFor each x in xs, the continuous index at which x falls in this sequence.- Specified by:
continuousIndicesOfin interfaceSortedDoubles- See Also:
ContinuousIndexArray
-
continuousIndicesOf
public ContinuousIndexArray continuousIndicesOf(Doubles xs)
Description copied from interface:SortedDoublesFor each x in xs, the continuous index at which x falls in this sequence.- Specified by:
continuousIndicesOfin interfaceSortedDoubles- See Also:
com.metsci.tracks.ContinuousIndexArray
-
continuousIndicesOf
public void continuousIndicesOf(SortedDoubles xs, ContinuousIndexArray result)
Description copied from interface:SortedDoublesFor each x in xs, the continuous index at which x falls in this sequence. Since xs is sorted, this method may be faster thanSortedDoubles.continuousIndicesOf(Doubles, ContinuousIndexArray)in some implementations.- Specified by:
continuousIndicesOfin interfaceSortedDoubles- See Also:
ContinuousIndexArray
-
continuousIndicesOf
public ContinuousIndexArray continuousIndicesOf(SortedDoubles xs)
Description copied from interface:SortedDoublesFor each x in xs, the continuous index at which x falls in this sequence. Since xs is sorted, this method may be faster thanSortedDoubles.continuousIndicesOf(Doubles)in some implementations.- Specified by:
continuousIndicesOfin interfaceSortedDoubles- See Also:
ContinuousIndexArray
-
continuousIndicesIn
public ContinuousIndexArray continuousIndicesIn(SortedDoubles xs)
Like continuousIndicesOf, but in reverse: for each v in this sequence, the continuous index at which v falls in xs. This may be faster than continuousIndicesOf when going from a sparser sequence to a dense arithmetic sequence.
-
-