d4_array library
List manipulation, ordering, searching, summarizing, etc.
See one of:
- Adding numbers - Add floating point values with full precision.
- Binning data - Bin discrete samples into continuous, non-overlapping intervals.
- Bisecting data - Quickly find a value in a sorted array.
- Blurring data - Blur quantitative values in one or two dimensions.
- Grouping data - Group discrete values.
- Set operations - Logical operations on sets.
- Sorting data - Sort and reorder arrays of values.
- Summarizing data - Compute summary statistics.
- Ticks - Generate representative values from a continuous interval.
- Transforming data - Derive new arrays.
Classes
- Adder Adding numbers
- Creates a full precision adder for IEEE 754 floating point numbers, setting its initial value to 0.
-
Bin<
T extends num?> Binning data - A bin generator for numerical data.
-
BinBy<
T, R extends num?> Binning data - Equivalent do Bin, except that it allows for customized data processing and flexible binning based on specific attributes of the data elements.
Functions
-
ascending(
Object? a, Object? b) → num Sorting data -
Returns -1 if
a
is less thanb
, or 1 ifa
is greater thanb
, or 0. -
bisectCenter<
T> (List< Bisecting dataT> list, T x, {int lo = 0, int? hi, num comparator(T, T) = ascending, num delta(T, T)?}) → int -
Similar to bisectLeft, but returns the index of the value closest to
x
in the givenlist
according to the specifieddelta
function. -
bisectLeft<
T> (List< Bisecting dataT> list, T x, {int lo = 0, int? hi, num comparator(T, T) = ascending}) → int -
Returns the insertion point for
x
inlist
to maintain sorted order according to the specifiedcomparator
. -
bisectRight<
T> (List< Bisecting dataT> list, T x, {int lo = 0, int? hi, num comparator(T, T) = ascending}) → int -
Similar to bisectLeft, but returns an insertion point which comes after
(to the right of) any existing entries of
x
inlist
. -
blur(
List< Blurring datadouble> data, num radius) → List<double> -
Blurs an list of
data
in-place by applying three iterations of a moving average transform, for a fast approximation of a gaussian kernel of the givenradius
, a non-negative number, and returns the list. -
blur2(
({List< Blurring datadouble> data, int? height, int width}) data, int rx, [int? ry]) → ({List<double> data, int? height, int width}) -
Blurs a matrix of the given width and height in-place, by applying an
horizontal blur of radius
rx
and a vertical blur or radiusry
(which defaults torx
). -
blurImage(
({List< Blurring datadouble> data, int? height, int width}) data, int rx, [int? ry]) → ({List<double> data, int? height, int width}) -
Blurs an ImageData
structure in-place, blurring each of the RGBA layers independently by
applying an horizontal blur of radius
rx
and a vertical blur or radiusry
(which defaults torx
). Returns the blurred ImageData. -
count(
Iterable< Summarizing datanum?> iterable) → int -
Returns the count of values in the
iterable
. -
countBy<
T> (Iterable< Summarizing dataT> iterable, num? accessor(T)) → int? -
Returns the count of values yielded by the
accessor
function applied to each element in theiterable
. -
cross<
T> (Iterable< Transforming dataIterable< iterables) → List<T> >List< T> > -
Returns the
Cartesian product of the
specified
iterables
. -
crossWith<
T, R> (Iterable< Transforming dataIterable< iterables, R reducer(List<T> >T> )) → List<R> -
Returns the
Cartesian product of the
specified
iterables
, applying the specifiedreducer
function to each combination of elements. -
cumsum(
Iterable< Summarizing datanum?> iterable) → List<num?> -
Returns the cumsum of all values in the
iterable
. -
cumsumBy<
T> (Iterable< Summarizing dataT> iterable, num? accessor(T)) → List<num> -
Returns the cumsum of all values yielded by the
accessor
function applied to each element in theiterable
, as a list of the same length. -
descending(
Object? a, Object? b) → num Sorting data - Returns -1 if a is greater than b, or 1 if a is less than b, or 0.
-
deviation(
Iterable< Summarizing datanum?> iterable) → num? -
Returns the standard deviation, defined as the square root of the
bias-corrected variance, of all values in the
iterable
. -
deviationBy<
T> (Iterable< Summarizing dataT> iterable, num? accessor(T)) → num? -
Returns the standard deviation, defined as the square root of the
bias-corrected variance, of all values yielded by the
accessor
function applied to each element in theiterable
. -
difference<
T> (Iterable< Set operationsT> iterable, Iterable<Iterable< others) → Set<Object?> >T> -
Returns a new set containing every value in
iterable
that is not in any of theothers
iterables. -
disjoint<
T> (Iterable< Set operationsObject?> a, Iterable<Object?> b) → bool -
Returns true if
a
andb
are disjoint: ifa
andb
contain no shared value. -
extent<
T extends Comparable?> (Iterable< Summarizing dataT> iterable) → (T?, T?) -
Returns the minimum and maximum values in the
iterable
. -
extentBy<
T, R extends Comparable?> (Iterable< Summarizing dataT> iterable, R accessor(T)) → (R?, R?) -
Returns the minimum and maximum values yielded by the
accessor
function applied to each element in theiterable
. -
fcumsum(
Iterable< Adding numbersnum?> iterable) → Float64List -
Returns a full precision cumulative sum of all values in the
iterable
. -
fcumsumBy<
T> (Iterable< Adding numbersT> iterable, num? accessor(T)) → Float64List -
Returns a full precision cumulative sum of all values yielded by the
accessor
function applied to each element in theiterable
. -
filter<
T> (Iterable< Transforming dataT> iterable, bool test(T)) → List<T> -
Returns a new list containing the values from
iterable
, in order, for which the given test function returns true. -
fsum(
Iterable< Adding numbersnum?> iterable) → double -
Returns a full precision summation of all values in the
iterable
. -
fsumBy<
T> (Iterable< Adding numbersT> iterable, num? accessor(T)) → double -
Returns a full precision summation of all values yielded by the
accessor
function applied to each element in theiterable
. -
greatest<
T> (Iterable< Summarizing dataT> iterable, [num comparator(T, T) = ascending]) → T? -
Returns the greatest of all values in the
iterable
according to the specifiedcomparator
. -
greatestBy<
T, R> (Iterable< Summarizing dataT> iterable, R accessor(T), [num comparator(R, R) = ascending]) → T? -
Returns the element with the greatest of all values yielded by the
accessor
function applied to each element in theiterable
according to the specifiedcomparator
. -
greatestIndex<
T> (Iterable< Summarizing dataT> iterable, [num comparator(T, T) = ascending]) → int -
Returns the index of the greatest of all values in the
iterable
according to the specifiedcomparator
. -
greatestIndexBy<
T, R> (Iterable< Summarizing dataT> iterable, R accessor(T), [num comparator(R, R) = ascending]) → int -
Returns the index of the element with the greatest of all values yielded by
the
accessor
function applied to each element in theiterable
according to the specifiedcomparator
. -
group<
T, K> (Iterable< Grouping dataT> iterable, K key(T)) → Map<K, List< T> > -
Groups the specified
iterable
of values into an Map fromkey
to list of value. -
groupSort<
T, K> (Iterable< Grouping dataT> iterable, K key(T), [num valueComparator(List<T> , List<T> ) = ascending, num keyComparator(K, K) = ascending]) → List<K> -
Groups the specified
iterable
of elements according to the specifiedkey
function, sorts the groups according to the specifiedvalueComparator
for values andkeyComparator
for keys, and then returns a list of keys in sorted order. -
index<
T, K> (Iterable< Grouping dataT> iterable, K key(T)) → Map<K, List< T> > - Equivalent to group but returns a unique value per compound key instead of an list, throwing if the key is not unique.
-
intersection<
T> (Iterable< Set operationsT> iterable, Iterable<Iterable< others) → Set<Object?> >T> - Returns a new set containing every (distinct) value that appears in all of the given iterables.
-
least<
T> (Iterable< Summarizing dataT> iterable, [num comparator(T, T) = ascending]) → T? -
Returns the least of all values in the
iterable
according to the specifiedcomparator
. -
leastBy<
T, R> (Iterable< Summarizing dataT> iterable, R accessor(T), [num comparator(R, R) = ascending]) → T? -
Returns the element with the least of all values yielded by the
accessor
function applied to each element in theiterable
according to the specifiedcomparator
. -
leastIndex<
T> (Iterable< Summarizing dataT> iterable, [num comparator(T, T) = ascending]) → int -
Returns the index of the least of all values in the
iterable
according to the specifiedcomparator
. -
leastIndexBy<
T, R> (Iterable< Summarizing dataT> iterable, R accessor(T), [num comparator(R, R) = ascending]) → int -
Returns the index of the element with the least of all values yielded by
the
accessor
function applied to each element in theiterable
according to the specifiedcomparator
. -
map<
T, R> (Iterable< Transforming dataT> iterable, R mapper(T)) → List<R> -
Returns a new list containing the mapped values from
iterable
, in order, as defined by givenmapper
function. -
max<
T extends Comparable?> (Iterable< Summarizing dataT> iterable) → T? -
Returns the maximum of all values in the
iterable
. -
maxBy<
T, R extends Comparable?> (Iterable< Summarizing dataT> iterable, R accessor(T)) → R? -
Returns the maximum of all values yielded by the
accessor
function applied to each element in theiterable
. -
maxIndex<
T extends Comparable?> (Iterable< Summarizing dataT> iterable) → int -
Returns the index of the maximum of all values in the
iterable
. -
maxIndexBy<
T, R extends Comparable?> (Iterable< Summarizing dataT> iterable, R accessor(T)) → int -
Returns the index of the maximum of all values yielded by the
accessor
function applied to each element in theiterable
. -
mean(
Iterable< Summarizing datanum?> iterable) → num? -
Returns the mean of all values in the
iterable
. -
meanBy<
T> (Iterable< Summarizing dataT> iterable, num? accessor(T)) → num? -
Returns the mean of all values yielded by the
accessor
function applied to each element in theiterable
. -
median(
Iterable< Summarizing datanum?> iterable) → num? -
Returns the median of all values in the
iterable
using the R-7 method. -
medianBy<
T> (Iterable< Summarizing dataT> iterable, num? accessor(T)) → num? -
Returns the median of all values yielded by the
accessor
function applied to each element in theiterable
using the R-7 method. -
medianIndex(
Iterable< Summarizing datanum?> values) → int? - Similar to median, but returns the index of the value to the left of the median.
-
medianIndexBy<
T> (Iterable< Summarizing dataT> values, num? accessor(T)) → int? - Similar to medianBy, but returns the index of the element that yields the value to the left of the median.
-
merge<
T> (Iterable< Transforming dataIterable< iterables) → List<T> >T> -
Merges the specified iterable of
iterables
into a single list. -
min<
T extends Comparable?> (Iterable< Summarizing dataT> iterable) → T? -
Returns the minimum of all values in the
iterable
. -
minBy<
T, R extends Comparable?> (Iterable< Summarizing dataT> iterable, R accessor(T)) → R? -
Returns the minimum of all values yielded by the
accessor
function applied to each element in theiterable
. -
minIndex<
T extends Comparable?> (Iterable< Summarizing dataT> iterable) → int -
Returns the index of the minimum of all values in the
iterable
. -
minIndexBy<
T, R extends Comparable?> (Iterable< Summarizing dataT> iterable, R accessor(T)) → int -
Returns the index of the minimum of all values yielded by the
accessor
function applied to each element in theiterable
. -
mode<
T> (Iterable< Summarizing dataT> iterable) → T? -
Returns the mode of all values in the
iterable
, i.e., the value which appears the most often. -
modeBy<
T, R> (Iterable< Summarizing dataT> iterable, R accessor(T)) → R? -
Returns the mode of all values yielded by the
accessor
function applied to each element in theiterable
, i.e., the value which appears the most often. -
nice(
num start, num stop, num count) → (num, num) Ticks -
Returns a new interval [niceStart, niceStop] covering the given
interval [
start
,stop
] and where niceStart and niceStop are guaranteed to align with the corresponding tickStep. -
pairs<
T> (Iterable< Transforming dataT> iterable) → List<(T, T)> -
Returns a list of pairs from consecutive values of the provided
iterable
. -
pairsWith<
T, R> (Iterable< Transforming dataT> iterable, R reducer(T, T)) → List<R> -
Returns a list of values yielded by the
reducer
function applied to each pair of consecutive elements from the providediterable
. -
permute<
T> (Iterable< Sorting dataT> iterable, Iterable<int> keys) → List<T?> -
Returns a permutation of the specified
iterable
using thekeys
. -
permuteMap<
K, V> (Map< Sorting dataK, V> map, Iterable<K> keys) → List<V?> -
Returns a permutation of the specified
map
using thekeys
. -
quantile(
Iterable< Summarizing datanum?> iterable, num p) → num? -
Returns the
p
-quantile of all values in theiterable
, wherep
is a number in the range [0, 1]. -
quantileBy<
T> (Iterable< Summarizing dataT> iterable, num p, num? accessor(T)) → num? -
Returns the
p
-quantile of all values yielded by theaccessor
function applied to each element in theiterable
, wherep
is a number in the range [0, 1]. -
quantileIndex(
Iterable< Summarizing datanum?> iterable, num p) → int? -
Similar to quantile, but returns the index to the left of
p
. -
quantileIndexBy<
T> (Iterable< Summarizing dataT> values, num p, num? accessor(T)) → int? -
Similar to quantileBy, but returns the index to the left of
p
. -
quantileSorted(
Iterable< Summarizing datanum?> values, num p) → num? - Similar to quantile, but expects the input to be sorted.
-
quantileSortedBy<
T> (Iterable< Summarizing dataT> values, num p, num? accessor(T)) → num? -
Similar to quantileBy, but expects the input to be sorted. In contrast
with quantileBy, the
accessor
is only called on the elements needed to compute the quantile. -
quickselect<
T extends List< (E> , E>T elements, num k, {num left = 0, num right = double.infinity, int compare(E, E) = ascendingDefined}) → T Sorting data - See mourner/quickselect.
-
range(
{num start = 0, required num stop, num step = 1}) → List< Ticksnum> - Returns an list containing an arithmetic progression, similar to the Python built-in range.
-
rank<
T> (Iterable< Summarizing dataT> iterable, [num comparator(T, T) = ascending]) → List<num> -
Returns an list with the rank of each value in the
iterable
, i.e., the zero-based index of the value when the iterable is sorted. -
rankBy<
T, R> (Iterable< Summarizing dataT> iterable, R accessor(T), [num comparator(R, R) = ascending]) → List<num> -
Returns an list with the rank of each element in the
iterable
, i.e., the zero-based index of the element when the iterable is sorted based on the values yielded by theaccessor
function. -
reverse<
T> (Iterable< Sorting dataT> iterable) → List<T> -
Returns an list containing the values in the given
iterable
in reverse order. -
rollup<
T, R, K> (Iterable< Grouping dataT> iterable, R reduce(List<T> ), K key(T)) → Map<K, R> -
Groups and reduces the specified
iterable
of values into an Map from key to value. -
rollupSort<
T, R, K> (Iterable< Grouping dataT> iterable, R reduce(List<T> ), K key(T), [num valueComparator(R, R) = ascending, num keyComparator(K, K) = ascending]) → List<K> -
Groups and reduces the specified
iterable
of elements according to the specifiedkey
function, sorts the reduced groups according to the specifiedvalueComparator
for values andkeyComparator
for keys, and then returns a list of keys in sorted order. -
shuffle<
T> (List< Sorting dataT> list, [int start = 0, int? stop]) → List<T> -
Randomizes the order of the specified
list
in-place using the Fisher–Yates shuffle and returns thelist
. -
shuffler<
T> (num random()) → List< Sorting dataT> Function(List<T> , [int, int?]) -
Returns a shuffle function given the specified
random
source. For example, using randomLcg: -
sort<
T> (Iterable< Sorting dataT> iterable, [num comparator(T, T) = ascending]) → List<T> -
Returns an list containing the values in the given
iterable
in the sorted order defined by the givencomparator
. -
sortBy<
T, R> (Iterable< Sorting dataT> iterable, R accessor(T), [num comparator(R, R) = ascending]) → List<T> -
Returns a list containing the elements of the given
iterable
in the sorted order defined by the values yielded by the givenaccessor
function. -
subset<
T> (Iterable< Set operationsObject?> a, Iterable<Object?> b) → bool -
Returns true if
a
is a subset ofb
: if every value in the given iterablea
is also in the given iterableb
. -
sum(
Iterable< Summarizing datanum?> iterable) → num -
Returns the sum of all values in the
iterable
. -
sumBy<
T> (Iterable< Summarizing dataT> iterable, num? accessor(T)) → num -
Returns the sum of all values yielded by the
accessor
function applied to each element in theiterable
. -
superset<
T> (Iterable< Set operationsObject?> a, Iterable<Object?> b) → bool -
Returns true if
a
is a superset ofb
: if every value in the given iterableb
is also in the given iterablea
. -
thresholdFreedmanDiaconis<
T> (Iterable< Binning datanum?> values, num min, num max) → int -
Returns the number of bins according to the
Freedman–Diaconis rule;
the input
values
must be numbers. -
thresholdScott<
T> (Iterable< Binning datanum?> values, num min, num max) → int -
Returns the number of bins according to
Scott’s normal reference rule;
the input
values
must be numbers. -
thresholdSturges(
Iterable< Binning datanum?> values, [num? min, num? max]) → int -
Returns the number of bins according to
Sturges’ formula;
the input
values
must be numbers. -
tickIncrement(
num start, num stop, num count) → num Ticks -
Like tickStep, except requires that
start
is always less than or equal tostop
, and if the tick step for the givenstart
,stop
andcount
would be less than one, returns the negative inverse tick step instead. -
ticks(
num start, num stop, num count) → List< Ticksnum> -
Returns an list of approximately
count
+ 1 uniformly-spaced, nicely-rounded values betweenstart
andstop
(inclusive). -
tickStep(
num start, num stop, num count) → num Ticks - Returns the difference between adjacent tick values if the same arguments were passed to ticks: a nicely-rounded value that is a power of ten multiplied by 1, 2 or 5.
-
transpose<
T> (Iterable< Transforming dataIterable< matrix) → List<T> >List< T> > -
Returns a list of lists, where the ith list contains the ith element from
each of the iterables in the
matrix
. -
union<
T> (Iterable< Set operationsIterable< iterables) → Set<T> >T> -
Returns a new set containing every (distinct) value that appears in any of
the given
iterables
. -
variance(
Iterable< Summarizing datanum?> iterable) → num? -
Returns an unbiased estimator of the population variance
of all values in the
iterable
using Welford’s algorithm. -
varianceBy<
T> (Iterable< Summarizing dataT> iterable, num? accessor(T)) → num? -
Returns an unbiased estimator of the population variance
of all values yielded by the
accessor
function applied to each element in theiterable
using Welford’s algorithm.