Crate afarray

Source
Expand description

Provides a generic one-dimensional Array which wraps arrayfire::Array and supports all number_general::NumberType variants. Array and ArrayExt support basic math like Add, Sub, Mul, Div, and Rem, with hardware acceleration on systems which support CUDA or OpenCL. ArrayExt<bool> supports common logical operations and, not, or, and xor.

N-dimensional array functionality can be implemented using Coords and Offsets, which provide methods for indexing a one-dimensional Array or ArrayExt as an n-dimensional tensor.

Array supports (de)serialization without type hinting. ArrayExt<T> supports serialization for T: Serialize and deserialization for T: Deserialize.

Example usage:

let a = [1, 2, 3];
let b = [5];

let product = &Array::from(&a[..]) * &Array::from(&b[..]);
assert_eq!(product, Array::from_iter(vec![5, 10, 15]));
assert_eq!(product.sum(), Number::from(30))

This crate depends on ArrayFire version 3.8. You will have to install ArrayFire separately by following the instructions at https://arrayfire.org/docs/installing.htm in order to build this crate.

You can find detailed instructions for building the Rust arrayfire crate from crates.io at https://crates.io/crates/arrayfire.

Structs§

Aggregate
Aggregate a Stream of numbers into a Stream of ArrayExts.
ArrayError
The error type used for Array which may fail recoverably.
ArrayExt
A wrapper around af::Array which defines common operations.
CoordBlocks
A Stream of Coords, as constructed from an input stream of Coords.
CoordMerge
Stream for merging two sorted CoordBlocks streams.
CoordUnique
Return only the unique coordinates from a sorted stream of Coords.
Coords
A hardware-accelerated set of n-dimensional coordinates, all with the same dimension.
Resize
Struct for the ArrayTryStream::resize method.

Enums§

Array
A generic one-dimensional array which supports all variants of NumberType.

Traits§

ArrayInstance
Defines common access methods for instance of ArrayExt.
ArrayInstanceAbs
Defines an absolute value method abs.
ArrayInstanceAnyAll
Defines cumulative boolean operations any and all.
ArrayInstanceCompare
Defines element-wise comparison operations.
ArrayInstanceIndex
Indexing operations for ArrayExt
ArrayInstanceLog
Defines a general logarithm.
ArrayInstanceMinMax
Defines common reduction operations min and max.
ArrayInstanceNaturalLog
Defines the natural logarithm.
ArrayInstancePow
Defines an exponentiation method pow.
ArrayInstanceProduct
Defines common reduction operation product.
ArrayInstanceRound
Defines a rounding method round.
ArrayInstanceSum
Defines common reduction operation sum.
ArrayInstanceTrig
ArrayInstanceUnreal
Methods to check for infinite or non-numeric array elements.
ArrayMinMaxTryStream
Trait to reduce the sum of a Stream of ArrayExts.
ArrayProductTryStream
Trait to reduce the product of a Stream of ArrayExts.
ArraySumTryStream
Trait to reduce the sum of a Stream of ArrayExts.
ArrayTryStream
Methods for handling a Stream of ArrayExts.
HasArrayExt
Convenience methods defining the base value of a reduce operation on an ArrayExt.
Max
Trait defining the maximum of two numbers.
Min
Trait defining the minimum of two numbers.
Product
Trait defining the product of two numbers.
Sum
Trait defining the sum of two numbers.

Functions§

coord_to_offset
Convert a coordinate to a linear offset.
print_af_info
Call arrayfire::info.
product_dtype
The NumberType of the product of an Array with the given array_dtype.
reduce_max
Compute the maximum of each stride of a Stream of Arrays.
reduce_min
Compute the minimum of each stride of a Stream of Arrays.
reduce_product
Compute the product of each stride of a Stream of Arrays.
reduce_sum
Compute the sum of each stride of a Stream of Arrays.
sum_dtype
The NumberType of the sum of an Array with the given array_dtype.

Type Aliases§

Complex
A complex number (an alias for num_complex::Complex.
Coord
An n-dimensional coordinate.
Offsets
One-dimensional array indices corresponding to n-dimensional coordinates.
Result
The result of an Array operation which may fail recoverably.