public interface DoubleList
java.util.List.| Modifier and Type | Method and Description |
|---|---|
boolean |
add(double e)
Appends the specified element to the end of this list.
|
void |
add(int index,
double element)
Inserts the specified element at the specified position in this list.
|
boolean |
addAll(DoubleList c)
Appends all of the elements in the specified list to the end of this
list, in the order that they are returned by the specified list's
DIterator.
|
boolean |
addAll(int index,
DoubleList c)
Inserts all of the elements in the specified list into this list,
starting at the specified position.
|
static boolean |
approxEqual(DoubleList a,
DoubleList b)
Tests for approximate equality (or "closeness") of the two DoubleLists
a and b where a and b must have the same
length and each element xa of a is tested for approximate
equality against the corresponding element xb of b as
defined in approxEqual(DoubleList, DoubleList, double, double). |
static boolean |
approxEqual(DoubleList a,
DoubleList b,
double relTol,
double absTol)
Tests for approximate equality (or "closeness") of the two DoubleLists
a and b where a and b must have the same
length and each element xa of a is tested for approximate
equality against the corresponding element xb of b. |
DoubleList |
assignConst(double val)
Assign the constant
val to each element in this list. |
double |
avg()
Returns the average value of the elements in this list if this list has
at least one element, otherwise throws
NoSuchElementException. |
void |
clear()
Removes all of the elements from this list.
|
boolean |
contains(double o)
Returns
true if this list contains the specified element. |
boolean |
containsAll(DoubleList c)
Returns
true if this DoubleList contains all of the elements in
the specified DoubleList. |
DoubleList |
cross(double[] array)
Computes the cross
product of this DoubleList and the given
array provided that
both, this DoubleList and the given array, have a dimension of
3. |
DoubleList |
cross(DoubleList list)
Computes the cross
product of this DoubleList and the given
list provided that
both, this DoubleList and the given list, have a dimension of
3. |
double |
dot(double[] array)
Computes the dot product of this list and the given
array. |
double |
dot(DoubleList list)
Computes the dot product of this list and the given
list. |
boolean |
equals(Object o)
Compares the specified object with this DoubleList for equality.
|
default void |
forEach(DoubleConsumer action)
Performs the given action for each element of this list in the order of
iteration until all elements have been processed or the action throws an
exception.
|
double |
get(int index)
Returns the element at the specified position in this list.
|
double[] |
getArrayUnsafe()
Returns the underlying array as an escape hatch.
|
int |
hashCode()
Returns the hash code value for this DoubleList.
|
int |
indexOf(double o)
Returns the index of the first occurrence of the specified element in
this list, or -1 if this list does not contain the element.
|
boolean |
isEmpty()
Returns
true if this list contains no elements. |
DForEachIterator |
iterator()
Returns an iterator over the elements in this list in proper sequence.
|
int |
lastIndexOf(double o)
Returns the index of the last occurrence of the specified element in this
list, or -1 if this list does not contain the element.
|
DListIterator |
listIterator()
Returns a list iterator over the elements in this list (in proper
sequence).
|
DListIterator |
listIterator(int index)
Returns a list iterator over the elements in this list (in proper
sequence), starting at the specified position in the list.
|
double |
logSumExp()
Returns the logarithm of the sum of the exponentials of this list (see
LogSumExp) if it
has at least one element, otherwise
NoSuchElementException is
thrown. |
double |
max()
Returns the maximum of the elements in this list if this list has at
least one element, otherwise throws
NoSuchElementException. |
double |
median()
Returns the median value of the elements in this list if this list has at
least one element, otherwise throws
NoSuchElementException. |
double |
min()
Returns the minimum of the elements in this list if this list has at
least one element, otherwise throws
NoSuchElementException. |
DoubleList |
mul(double val)
Multiply each element in this list by the scalar
val. |
double |
muli(int index,
double val)
Multiply the element at
index by the scalar val. |
DoubleList |
muln(double[] array)
Multiplies the scalars from this list by the scalars from the given
array. |
DoubleList |
muln(DoubleList list)
Multiplies the scalars from this list by the scalars from the given
list. |
double |
norm2()
Computes the euclidean norm (magnitude) of this list.
|
DoubleList |
normalizedSoftmax(double normalizedSum)
Returns a new list that contains the contents of this list normalized to
a distribution according to the
softmax
function which sums up to
normalizedSum. |
static DoubleList |
of(double... values)
Constructs a list containing the passed values in the order of their
appearance.
|
int |
offset()
Returns the offset of this list.
|
default DoubleStream |
parallelStream()
Returns a parallel
Stream with this list as its source. |
DoubleList |
plus(double val)
Add the scalar
val to each element in this list. |
double |
plusi(int index,
double val)
Add the scalar
val to the element at index. |
DoubleList |
plusn(double[] array)
Add the scalars from the given
array to the elements in this
list. |
DoubleList |
plusn(DoubleList list)
Add the scalars from the given
list to the elements in this list. |
static DoubleList |
randomNormal(double mu,
double sigma,
int size)
Constructs a random list of length
size with random values
normally distributed with mean mu and standard deviation
sigma. |
static DoubleList |
randomUniform(double min,
double max,
int size)
Constructs a random list of length
size with random values
uniformly distributed between min and max. |
boolean |
remove(double o)
Removes the first occurrence of the specified element from this list, if
it is present.
|
double |
remove(int index)
Removes the element at the specified position in this list.
|
boolean |
removeAll(DoubleList c)
Removes from this list all of its elements that are contained in the
specified list.
|
boolean |
retainAll(DoubleList c)
Retains only the elements in this list that are contained in the
specified list.
|
DoubleList |
round(int scale)
Round the scalars in this list to
scale. |
DoubleList |
sanitizeNonFinite(double nanSurrogate,
double posInfSurrogate,
double negInfSurrogate)
Set all scalars that are either NaN, positive or negative infinity to the
respective ersatz value provided by the
nanSurrogate,
posInfSurrogate and negInfSurrogate arguments. |
double |
set(int index,
double element)
Replaces the element at the specified position in this list with the
specified element.
|
int |
size()
Returns the number of elements in this list.
|
DoubleList |
softmax()
Returns a new list that contains the contents of this list normalized to
a probability distribution according to the
softmax
function which sums up to
1.0. |
default void |
sort()
Sorts this list in ascending order.
|
Spliterator.OfDouble |
spliterator()
Creates a late-binding and fail-fast
Spliterator over the elements in this list. |
double |
stddev()
Returns the standard deviation of the elements in this list if this list
has at least two elements, otherwise throws
IllegalArgumentException. |
default DoubleStream |
stream()
Returns a sequential
Stream with this list as its source. |
DoubleList |
subList(int fromIndex,
int toIndex)
Returns a view of the portion of this list between the specified
fromIndex, inclusive, and toIndex, exclusive. |
double |
sum()
Returns the sum of the elements in this list.
|
double[] |
toArray()
Returns an array containing all of the elements in this list in proper
sequence (from first to last element).
|
default DoubleStream stream()
Stream with this list as its source.Stream over the elements in this listdefault DoubleStream parallelStream()
Stream with this list as its source.Stream over the elements in this listdefault void forEach(DoubleConsumer action)
action - The action to be performed for each elementNullPointerException - if the specified action is nulldefault void sort()
static DoubleList of(double... values)
values - the values which are to be placed into the listDoubleList constructed from the passed valuesstatic boolean approxEqual(DoubleList a, DoubleList b)
a and b where a and b must have the same
length and each element xa of a is tested for approximate
equality against the corresponding element xb of b as
defined in approxEqual(DoubleList, DoubleList, double, double).
This method is equivalent to a call of
approxEqual(DoubleList, DoubleList, double, double) with an
relTol argument of value 1.0e-8 and an absTol
argument equal to 0.0:
approxEqual(a, b, 1.0e-8, 0.0)
a - one of the two DoubleLists to test for approximate equality
(it doesn't matter which one since the test is symmetric)b - the other one of the two DoubleLists to test for approximate
equality (it doesn't matter which one since the test is
symmetric)true if a and b are approximately equal
according to the criterion defined in
approxEqual(DoubleList, DoubleList, double, double)static boolean approxEqual(DoubleList a, DoubleList b, double relTol, double absTol)
a and b where a and b must have the same
length and each element xa of a is tested for approximate
equality against the corresponding element xb of b.
If, for all pairs (xa, xb),
abs(xa - xb) <= max( relTol * max(abs(xa), abs(xb)), absTol )
the lists a and b are considered approximately equal,
otherwise they are not. This test is symmetric, so interchanging
a and b doesn't change the result.
Implementation Note:
The definition of approximate equality used here is the one employed in
Python's math.isclose() function defined in PEP 485 - A Function for
testing approximate equality. This document gives a nice discussion
of the rationale for this approach, how to use it, and the alternatives
they had considered.
a - one of the two DoubleLists to test for approximate equality
(it doesn't matter which one since the test is symmetric)b - the other one of the two DoubleLists to test for approximate
equality (it doesn't matter which one since the test is
symmetric)relTol - relative tolerance, must be >= 0.0absTol - absolute tolerance, must be >= 0.0true if a and b are approximately equal
according to the criterion defined above, otherwise falseIllegalArgumentException - if relTol < 0.0 or absTol < 0.0static DoubleList randomUniform(double min, double max, int size)
size with random values
uniformly distributed between min and max.min - lower bound of the uniform distributionmax - upper bound of the uniform distributionsize - length of the listsizestatic DoubleList randomNormal(double mu, double sigma, int size)
size with random values
normally distributed with mean mu and standard deviation
sigma.mu - mean (expectation) of the normal distributionsigma - standard deviation of the normal distribution, must be
> 0.0size - length of the listsizeint size()
boolean isEmpty()
true if this list contains no elements.true if this list contains no elementsboolean contains(double o)
true if this list contains the specified element. More
formally, returns true if and only if this list contains at least
one element e such that o == e.o - element whose presence in this list is to be testedtrue if this list contains the specified elementboolean containsAll(DoubleList c)
true if this DoubleList contains all of the elements in
the specified DoubleList.c - DoubleList to be checked for containment in this DoubleListtrue if this DoubleList contains all of the elements in
the specified DoubleListint indexOf(double o)
i such that
o == get(i), or -1 if there is no such index.o - element to search for-1 if not foundint lastIndexOf(double o)
i such that o == get(i), or -1
if there is no such index.o - element to search for-1 if not founddouble[] toArray()
The returned array will be "safe" in that no references to it are maintained by this list. (In other words, this method must allocate a new array). The caller is thus free to modify the returned array.
double get(int index)
index - index of the element to returnIndexOutOfBoundsException - if the index is out of range
(index < 0 || index >= size())double set(int index,
double element)
index - index of the element to replaceelement - element to be stored at the specified positionIndexOutOfBoundsException - if the index is out of range
(index < 0 || index >= size())boolean add(double e)
e - element to be appended to this listtruevoid add(int index,
double element)
index - index at which the specified element is to be insertedelement - element to be insertedIndexOutOfBoundsException - if the index is out of range
(index < 0 || index >= size())double remove(int index)
index - the index of the element to be removedIndexOutOfBoundsException - if the index is out of range
(index < 0 || index >= size())boolean equals(Object o)
true if and only if the specified object is also a DoubleList,
both lists have the same size, and all corresponding pairs of elements in
the two lists are equal. In other words, two DoubleList are
defined to be equal if they contain the same elements in the same order.int hashCode()
int hashCode = 1;
for (int i = 0; i < list.size(); i++) {
hashCode = 31 * hashCode + Double.hashCode(list.get(i));
}
This ensures that list1.equals(list2) implies that
list1.hashCode()==list2.hashCode() for any two DoubleLists,
list1 and list2, as required by the general contract of
Object.hashCode().boolean remove(double o)
i such
that o == get(i) (if such an element exists). Returns
true if this list contained the specified element (or
equivalently, if this list changed as a result of the call).o - element to be removed from this list, if presenttrue if this list contained the specified elementvoid clear()
boolean addAll(DoubleList c)
c - list containing elements to be added to this listtrue if this list changed as a result of the callNullPointerException - if the specified list is nullboolean addAll(int index,
DoubleList c)
index - index at which to insert the first element from the specified
listc - list containing elements to be added to this listtrue if this list changed as a result of the callIndexOutOfBoundsException - if the index is out of range
(index < 0 || index >= size())NullPointerException - if the specified list is nullboolean removeAll(DoubleList c)
c - list containing elements to be removed from this listtrue if this list changed as a result of the callboolean retainAll(DoubleList c)
c - list containing elements to be retained in this listtrue if this list changed as a result of the callDListIterator listIterator(int index)
next. An initial call to
previous would return the element with the
specified index minus one.
The returned list iterator is fail-fast.
index - starting positionIndexOutOfBoundsException - if the index is out of range
(index < 0 || index >= size())DListIterator listIterator()
The returned list iterator is fail-fast.
DForEachIterator iterator()
The returned iterator is fail-fast.
DoubleList subList(int fromIndex, int toIndex)
fromIndex, inclusive, and toIndex, exclusive. (If
fromIndex and toIndex are equal, the returned list is
empty.) The returned list is backed by this list, so non-structural
changes in the returned list are reflected in this list, and vice-versa.
The returned list supports all of the optional list operations.
This method eliminates the need for explicit range operations (of the sort that commonly exist for arrays). Any operation that expects a list can be used as a range operation by passing a subList view instead of a whole list. For example, the following idiom removes a range of elements from a list:
list.subList(from, to).clear();Similar idioms may be constructed for
indexOf(double) and
lastIndexOf(double), and all of the algorithms in a
DoubleList can be applied to a subList.
The semantics of the list returned by this method become undefined if the backing list (i.e., this list) is structurally modified in any way other than via the returned list. (Structural modifications are those that change the size of this list, or otherwise perturb it in such a fashion that iterations in progress may yield incorrect results.)
fromIndex - start index, inclusivetoIndex - end index, exclusiveIndexOutOfBoundsException - if an endpoint index value is out of range
(fromIndex < 0 || toIndex > size)IllegalArgumentException - if the endpoint indices are out of order
(fromIndex > toIndex)Spliterator.OfDouble spliterator()
Spliterator over the elements in this list.
The Spliterator.OfDouble reports Spliterator.SIZED,
Spliterator.SUBSIZED, and Spliterator.ORDERED. Overriding
implementations should document the reporting of additional
characteristic values.
Spliterator.OfDouble over the elements in this listint offset()
double[] getArrayUnsafe()
DoubleList assignConst(double val)
val to each element in this list.val - the constant to assignDoubleListDoubleList plus(double val)
val to each element in this list.val - the scalar to addDoubleListDoubleList mul(double val)
val.val - the scalar to multiply byDoubleListdouble min()
NoSuchElementException.NoSuchElementException - if this list is emptydouble max()
NoSuchElementException.NoSuchElementException - if this list is emptydouble avg()
NoSuchElementException.NoSuchElementException - if this list is emptydouble stddev()
IllegalArgumentException. The value is computed without Bessel's
correction, i.e., we divide by n, not by n - 1.IllegalArgumentException - if this list has less than two elementsdouble median()
NoSuchElementException.NoSuchElementException - if this list is emptydouble sum()
double plusi(int index,
double val)
val to the element at index.index - index of the element to increment by valval - the scalar to add to the elementdouble muli(int index,
double val)
index by the scalar val.index - index of the element to multiply by valval - the scalar to multiply bydouble dot(DoubleList list)
list.list - a DoubleList which must have the same size() as this
listlistdouble dot(double[] array)
array.array - an array which must have the same length as this list's
size()array.DoubleList cross(DoubleList list)
list provided that
both, this DoubleList and the given list, have a dimension of
3. If this DoubleList is not of size() == 3 an
UnsupportedOperationException is thrown. Also, if the given
list doesn't satisfy list.size() == 3 an
IllegalArgumentException is thrown.list - a DoubleList which must have the size() == 3listUnsupportedOperationException - if this DoubleList is not of size() == 3IllegalArgumentException - if the given list doesn't satisfy
list.size() == 3DoubleList cross(double[] array)
array provided that
both, this DoubleList and the given array, have a dimension of
3. If this DoubleList is not of size() == 3 an
UnsupportedOperationException is thrown. Also, if the given
array doesn't satisfy array.length == 3 an
IllegalArgumentException is thrown.array - an array which must have length == 3arrayUnsupportedOperationException - if this DoubleList is not of size() == 3IllegalArgumentException - if the given array doesn't satisfy
array.length == 3DoubleList softmax()
1.0.DoubleList normalizedSoftmax(double normalizedSum)
normalizedSum.normalizedSum - the overall sum of the desired distributionnormalizedSumdouble norm2()
double logSumExp()
NoSuchElementException is
thrown.NoSuchElementException - if this list is emptyDoubleList plusn(DoubleList list)
list to the elements in this list.
Note that list doesn't have to have the same size() as
this list as the minimum of both list sizes is used to determine the
number of scalars to add.list - a DoubleList of scalars to add to this listDoubleListDoubleList plusn(double[] array)
array to the elements in this
list. Note that array doesn't have to have the same length as
this list as the minimum of both lengths is used to determine the number
of scalars to add.array - an array of scalars to add to this listDoubleListDoubleList muln(DoubleList list)
list. Note that list doesn't have to have the same
size() as this list as the minimum of both list sizes is used to
determine the number of scalars to multiply.list - a DoubleList of scalars to multiply by the elements in this
listDoubleListDoubleList muln(double[] array)
array. Note that array doesn't have to have the same
length as this list as the minimum of both lengths is used to determine
the number of scalars to multiply.array - an array of scalars to multiply by the elements in this listDoubleListDoubleList round(int scale)
scale.scale - if zero or positive, the scale is the number of digits to the
right of the decimal point. If negative, the unscaled value of
the number is multiplied by ten to the power of the negation
of the scale.DoubleListDoubleList sanitizeNonFinite(double nanSurrogate, double posInfSurrogate, double negInfSurrogate)
nanSurrogate,
posInfSurrogate and negInfSurrogate arguments.nanSurrogate - the substitution value to use for NaN values, NaNs won't get
substituted if you pass Double.NaNposInfSurrogate - the substitution value to use for positive infinity values, no
substitution happens if you pass
Double.POSITIVE_INFINITYnegInfSurrogate - the substitution value to use for negative infinity values, no
substitution happens if you pass
Double.NEGATIVE_INFINITYDoubleListCopyright © 2022. All rights reserved.