Array1D class
This class provides utility functions for 1D arrays (vectors):
- adding arrays with various options
- Finding the minimum or maximum values with various options
- splitting, shuffling, swapping, extracting given index ranges
Constructors
- Array1D()
Properties
- hashCode → int
-
The hash code for this object. [...]
read-only, inherited
- runtimeType → Type
-
A representation of the runtime type of the object.
read-only, inherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed. [...]
inherited
-
toString(
) → String -
Returns a string representation of this object.
inherited
Operators
-
operator ==(
dynamic other) → bool -
The equality operator. [...]
inherited
Static Properties
Static Methods
-
addArrays(
Float64List a1, Float64List a2, int type) → Float64List -
Returns the index-wise sum of
a1
anda2
according totype
:type
= POS: adds the positive or zero values ofa1
anda2
onlytype
= NEG: adds the negative or zero values ofa1
anda2
onlytype
= POSNEG: normal add of all values Application: Building "projections". -
getMax(
Float64List array) → List -
Finds the maximum value of the numbers in
array
.array
may contain null values, they are skipped. Returnsthe maximum, its index
. If 2 maxima with the same value exist, the 1st one is returned. -
getMaxInRange(
Float64List arr, int firstIx, int lastIx) → double -
Finds the maximum value of the numbers in
array
in the range fromfirstIx
tolastIx
, both indices inclusive. Both indices may have the values null (at the same time), the the entirearray
is searched.array
may contain null values, they are skipped. Returns the maximum, if 2 maxima with the same value exist, the 1st one is returned. -
getMaxInRangeStep(
Float64List array, int startix, int endix, int incr) → List -
Finds the maximum value of the numbers in
array
in the range fromfirstIx
, inclusive, toendix
, exclusive.incr
is an index increment. If, e.g.,incr
==1, only every second array element is considered.array
may contain null values, they are skipped. Returnsthe maximum, its index
. If 2 maxima with the same value exist, the 1st one is returned. -
getMaxIntPos(
List< int> array) → List<int> -
Finds the positive-valued maximum value of the numbers in
array
, assuming thatarray
] contains values >= 0.array
may contain null values, they are skipped. Returnsthe maximum, its index
. If 2 maxima with the same value exist, the 1st one is returned. -
getMin(
Float64List array) → List -
Finds the minimum value of the numbers in
array
.array
may contain null values, they are skipped. Returnsthe minimum, its index
. If 2 minima with the same value exist, the 1st one is returned. -
getMinInRange(
Float64List array, int startix, int endix, int incr) → List -
Finds the minimum value of the numbers in
array
in the range fromfirstIx
, inclusive, toendix
, exclusive.incr
is an index increment. If, e.g.,incr
==1, only every second array element is considered.array
may contain null values, they are skipped. Returnsthe minimum, its index
. If 2 minima with the same value exist, the 1st one is returned. -
getMinMaxVals(
Float64List array) → List< double> -
Returns a pair of doubles which are the max and min values contained in
array
, in the following order:min, max
ormax, min
depending on whether min occurs before max in the array, or the other way around. -
getMinVal(
Float64List array) → double -
Returns the minimum value of the numbers in
array
. -
getRow(
Float64List array, int row, int nrows) → Float64List -
Considers
array
as a two-dimensional array withnrows
rows. The rows, when appended to each other in sequence, are building uparray
. Returns a new array consisting of the rowrow
whose length will be (array.length / nrows). Returns null ifrow
outside range. Conditions: row >= 0. If array.length cannot be divided by nrows without a remainder, the repective part ofarray
can't be obtained.array
will remain unmodified. -
isPowerOfTwo(
int n) → bool -
Returns true if
n
is a power of 2. -
nextPowerOfTwo(
int n) → int - Returns a number which: [...]
-
rotate(
Float64List array, int n) → void -
Rotates
array
to the right byn
positions in place. For example, with n = 3, the array1,2,3,4,5,6,7
is rotated to5,6,7,1,2,3,4
. -
shuffle(
Float64List a1, Float64List a2) → Float64List -
Merges the arrays
a1
anda2
to a new array "result" with double size. The even indices of "result" will be filled witha1
, the odd ones ofa2
.a1
anda2
must have the same length. See also method unshuffle. -
splitArray(
Float64List array, int size) → List< Float64List> -
Makes a 2D array from
array
. Each row of the 2D array will havesize
elements. The last row may be smaller if the length ofarray
can't be divided bysize
without remainder. Ifsize
is 0 or equal or greater than the length ofarray
, the result will containarray
as its single row. -
swap(
Float64List array) → void -
Inverts the order of
array
in place. Reverses the order ofarray
in place. Example:1,2,3,4,5,6,7,8,9,10
=>10,9,8,7,6,5,4,3,2,1
See also method swapHalf. -
swapHalf(
Float64List array) → void -
Reverses the order of the first half and the second half of
array
in place. Example:1,2,3,4,5,6,7,8,9,10
=>5,4,3,2,1,10,9,8,7,6
. See also method swap. -
unshuffle(
Float64List array) → List< Float64List> -
Makes 2 arrays "resultArray" (of half length) from
array
: resultArray0
consists of the even indices ofarray
. resultArray1
consists of the even indices ofarray
. Application:array
represents a sequence complex numbers:real, imag, real, imag, ....
. Then: resultArray0
is the real part:real, real, ...
, resultArray1
is the imaginary part:imag, imag, ...
. See also method shuffle. -
zeroFill(
Float64List array, int newLength, bool zeroFillExtend) → Float64List -
Zero-fills
array
as follows and returns the result: [...]