Array Members
ILNumerics arrays are strongly typed. The types do not only specify the type of the elements but also lifetime and mutability. Hence, the set of attributes / methods on ILNumerics arrays differs with the type of the array. Attributes only reading from the array are available on all array types. Mutating methods are available only on mutable arrays.
The complete list of array members is found in the array class reference. Below, a subset of functions is listed.
- General Array Atrributes (readonly)
- Mutating Array Attributes
- General Array Methods (readonly)
- Mutating Array Methods
- Numpy Methods
General Array Attributes (readonly)
Attribute / Property |
Description |
---|---|
.C |
Copy or clone the array (lazy copy on write). |
.flat | Gives a (readonly) iterator over the arrays elements (row major order). |
.IsEmpty | Gives true on arrays with no elements. |
.IsNumeric |
Gives true on arrays with numeric elements (Sytem.ValueType: long, uint, float, double, complex, ...) |
.IsScalar | Gives true if the array has exactly one element. |
.ndim | Number of dimensions stored in the array. |
.S, .Size | The size descriptor of the array, storing info about number & length of dimensions and strides. |
.shape | Gives a vector with the lengths of the array dimensions. |
.size | The number of elements in the array. |
.strides | Gets a vector with the strides of the arrays elements within each dimension. |
.T | Matrix transpose. If ndims > 2 the method depends on the current ArrayStyle. |
Mutable Array Attributes
Following properties are readable on all arrays, and writable on mutable arrays (Array<T>, OutArray<T>, ...)
Attribute / Property | Description |
---|---|
.shape |
Can be used to change the shape of the array. |
.a | Supports efficient assignments to the array. |
.data | Gets a data pointer to the arrays elements. The same as GetHostPointerForWrite(). |
General Array Methods (readonly)
Method | Description |
---|---|
.Equals(obj) |
Overwrites object.Equals(). Gives true if the type, shape and values of two arrays are equal. |
.ExportValues(arr) | Exports array elements into a 1D system array T[]. Allows to control the targets storage order. |
.GetValue(i0,i1,..) | Retrieve a single element as its natural type, without wrapping it into an array. |
.GetLimits(out min, out max) | Computes the minimum and maximum value of an array. |
.Iterator(order) | Gives an IEnumerable<T> for iterating over the array elements, f.e. in foreach loops. |
.Iterator<Tout>(conv, order) | Gives an IEnumerable<Tout> for iterating over the array elements, f.e. in foreach loops. |
.Reshape(i0,i1,...,order) | Gives a shallow, lazy copy of the array, by reshaping / reordering the elements. |
.Reshape<IndT>(ind,order) | Like Reshape(), accepts new dimensions as index array. |
.Subarray(d0,d1,...) | Extracts part of this array into a new array. See: subarrays. |
.ToString() | Converts the array and its elements into a structured string representation. |
Mutable Array Methods
Method | Description |
---|---|
.Assign(arr) |
Efficiently assign new array data to this array variable. This is a faster alternative to '='. |
.GetHostPointerForWrite() | Gives the memory address of the first element of the array and allows modifications. |
.SetRange(arr, d0,d1,...) | Replaces the values of a range of elements, supports expanding and shrinking. |
.SetValue(val, d0,d1,...) | Replaces the value of a single element, supports expanding and shrinking. |
Extension Array Methods (numpy style)
A number of extension methods can be enabled on ILNumerics arrays by referencing the module ILNumerics.numpy in your project.
Note: in version 5.0 the following namespace needed to be imported also. This is not required in later versions:
These methods were designed for best compatibility with the corresponding numpy array methods. The set of functions is split between such functions only reading from the array and the set of mutating functions.
More functions can be implemented on request (contact: sales@ilnumerics.net).
General numpy methods (readonly)
Method | Description |
---|---|
all(axes), any(axes) |
Accumulating tests for non-0 elements. |
min(dim, I), max(dim, I), argmin(dim, V), argmax(dim, V), sort(), argsort(), |
Accumulating selection functions. |
nanmin(), nanmax(), nanargmin(), nanargmax() |
Accumulating selection functions ignoring NaN values. |
cumprod(), cumsum(), sum(), prod() |
[Cumulative] sums, - products over arrays or individual dimensions. |
mean() | Mean of the array or individual dimensions. |
astype<T>(), copy(), flatten(), ravel() | Derive [reordered][type changed][flattened] copies of the array. |
item(i0,i1,...) | Single item retrieval. |
repeat() | Repeats elements, forming a new array. |
round() | Gives an array, rounding elements to specific number of decimals. |
swapaxes(d0,d1) | Returns an array, having both dimensions d0,d1 exchanged. |
transpose(axes) | Returns an array, having the dimensions of this array reordered. |
real(), imag() | Extract real or imaginary parts from complex arrays. |
Mutating numpy methods
The following functions are available on mutable arrays after referencing ILNumerics.numpy module:
Method | Description |
---|---|
fill(scalar) |
Sets all elements to the same value. |
itemset(i0,i1,...,, value) |
Replaces a single elements value. |
sort() |
Sort elements of this array inplace. |
resize(size)
|
Resizes this array. |
squeeze(axes) | Removes singleton dimensions from this array. |