Struct afarray::Coords[][src]

pub struct Coords { /* fields omitted */ }
Expand description

A hardware-accelerated set of n-dimensional coordinates, all with the same dimension.

TODO: separate out a CoordBasis struct

Implementations

Constructs Coords with the given size full of zeros (origin points) for the given shape.

Panics: if shape is empty

Constructs a new Coords from an iterator of Coords.

Panics: if any Coord is not of length ndim, or if ndim is zero.

Constructs a new Coords from an ArrayExt of offsets with respect to the given shape.

Panics: if shape is empty

Constructs a new Coords from a [Stream] of Coords.

Panics: if any Coord has a length other than ndim, or if ndim is zero

Constructs a new Coords from a [TryStream] of Coords.

Panics: if any Coord has a length other than ndim

Return true if the number of coordinates in these Coords is zero.

Return true if these Coords are in sorted order with respect to the given shape.

Return the number of coordinates stored in these Coords.

Return the number of dimensions of these Coords.

Return a copy of these Coords without the specified axis.

Panics: if there is no dimension at axis

Return a copy of these Coords with a new dimension at the given axis.

Panics: if axis is greater than self.ndim()

Return these Coords as flipped around axis with respect to the given shape.

E.g. flipping axis 1 of coordinate [0, 1, 2] in shape [5, 5, 5] produces [0, 4, 2].

Panics: if self.ndim() != shape.len()

Transform the coordinate basis of these Coords from a source tensor to a slice.

Transpose these Coords according to the given permutation.

If no permutation is given, the coordinate axes will be inverted.

Invert the given broadcast of these Coords.

Panics: if source_shape and broadcast are not the same length.

Transform the coordinate basis of these Coords from a slice to a source tensor.

Panics: if source_shape.len() - self.ndim() does not match elided.len()

Construct a new Coords from the selected indices.

Panics: if any index is out of bounds

Update these Coords by writing the given value at the given index.

Panics: if any index is out of bounds, or if value.len() does not match self.len()

Return these Coords as Offsets with respect to the given shape.

Panics: if shape.len() does not equal self.ndim()

Return a list of Coords from these Coords.

Panics: if the given number of dimensions does not fit the set of coordinates

Convert these Coords into a list of Coords.

Panics: if the given number of dimensions does not fit the set of coordinates.

Methods from Deref<Target = Array<u64>>

Returns the backend of the Array

Return Values

Returns an value of type Backend which indicates which backend was active when Array was created.

Returns the device identifier(integer) on which the Array was created

Return Values

Return the device id on which Array was created.

Returns the number of elements in the Array

Returns the Array data type

Returns the dimensions of the Array

Returns the strides of the Array

Returns the number of dimensions of the Array

Returns the offset to the pointer from where data begins

Returns the native FFI handle for Rust object Array

Set the native FFI handle for Rust object Array

Copies the data from the Array to the mutable slice data

Examples

Basic case

let a:Vec<u8> = vec![0,1,2,3,4,5,6,7,8];
let b = Array::<u8>::new(&a,Dim4::new(&[3,3,1,1]));
let mut c = vec!(u8::default();b.elements());
b.host(&mut c);
assert_eq!(c,a);

Generic case

fn to_vec<T:HasAfEnum+Default+Clone>(array:&Array<T>) -> Vec<T> {
    let mut vec = vec!(T::default();array.elements());
    array.host(&mut vec);
    return vec;
}

let a = Array::<u8>::new(&[0,1,2,3,4,5,6,7,8],Dim4::new(&[3,3,1,1]));
let b:Vec<u8> = vec![0,1,2,3,4,5,6,7,8];
assert_eq!(to_vec(&a),b);

Evaluates any pending lazy expressions that represent the data in the Array object

Makes an copy of the Array

This does a deep copy of the data into a new Array

Check if Array is empty

Check if Array is scalar

Check if Array is a row

Check if Array is a column

Check if Array is a vector

Check if Array is of real (not complex) type

Check if Array is of complex type

Check if Array’s numerical type is of double precision

Check if Array’s numerical type is of single precision

Check if Array’s numerical type is of half precision

Check if Array is of integral type

Check if Array is of boolean type

Check if Array is floating point real(not complex) data type

Check if Array is floating point type, either real or complex data

Check if Array’s memory layout is continuous and one dimensional

Check if Array is a sparse matrix

Check if Array’s memory is owned by it and not a view of another Array

Cast the Array data type to target_type

Lock the device buffer in the memory manager

Locked buffers are not freed by memory manager until unlock is called.

Unlock the device buffer in the memory manager

This function will give back the control over the device pointer to the memory manager.

Get the device pointer and lock the buffer in memory manager

The device pointer is not freed by memory manager until unlock is called.

Get the size of physical allocated bytes.

This function will return the size of the parent/owner if the current Array object is an indexed Array.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

The resulting type after dereferencing.

Dereferences the value.

Mutably dereferences the value.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Cast an instance of T into an instance of Self.

Cast an instance of Self into an instance of T.

Performs the conversion.

Performs the conversion.

Returns true if self can be cast into the target type T.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

Test if value can be cast into Self.

Returns Some(Self) if the source value can be cast into Self, otherwise None.

Returns Ok(Self) if the source value can be cast into Self, otherwise calls on_err.

Test if self can be cast into T.

Returns Some(T) if self can be cast into T, otherwise None.

Returns Ok(T) if self can be cast into T, otherwise calls on_err.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.