Struct afarray::Coords [−][src]
pub struct Coords { /* fields omitted */ }
Expand description
A hardware-accelerated set of n-dimensional coordinates, all with the same dimension.
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 ArrayExt
of offsets with respect to the given shape.
Panics: if shape
is empty
Constructs a new Coords
from a [TryStream
] of Coord
s.
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 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()
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 Coord
s from these 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.
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 of complex type
Check if Array is of integral 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’s memory is owned by it and not a view of another Array
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
Auto Trait Implementations
impl RefUnwindSafe for Coords
impl UnwindSafe for Coords
Blanket Implementations
Mutably borrows from an owned value. Read more
Returns true
if self
can be cast into the target type T
.
Test if value
can be cast into Self
.
Returns Some(Self)
if the source value can be cast into Self
, otherwise None
.
fn try_cast_from<Err, OnErr>(value: T, on_err: OnErr) -> Result<Self, Err> where
OnErr: FnOnce(&T) -> Err,
fn try_cast_from<Err, OnErr>(value: T, on_err: OnErr) -> Result<Self, Err> where
OnErr: FnOnce(&T) -> Err,
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
.
fn try_cast_into<Err, OnErr>(self, on_err: OnErr) -> Result<T, Err> where
OnErr: FnOnce(&Self) -> Err,
fn try_cast_into<Err, OnErr>(self, on_err: OnErr) -> Result<T, Err> where
OnErr: FnOnce(&Self) -> Err,
Returns Ok(T)
if self
can be cast into T
, otherwise calls on_err
.