pub trait ToNdarray<T> {
    // Required method
    fn to_ndarray(&self, t: Type) -> Result<ArrayD<T>>;
}

Required Methods§

source

fn to_ndarray(&self, t: Type) -> Result<ArrayD<T>>

Implementors§

source§

impl ToNdarray<bool> for Value

Converts self to a multi-dimensional array if it is a byte vector, then cast the array entries to u64.

Arguments

t - array type used to interpret self

Result

Resulting multi-dimensional array with entries cast to u64

Examples

let a = array![[false, true], [true, false]].into_dyn();
let v = Value::from_ndarray(a.clone(), BIT).unwrap();
let converted = ToNdarray::<bool>::to_ndarray(&v,array_type(vec![2, 2], BIT)).unwrap();
assert_eq!(converted, a);
source§

impl ToNdarray<i8> for Value

Converts self to a multi-dimensional array if it is a byte vector, then cast the array entries to i8.

Arguments

t - array type used to interpret self

Result

Resulting multi-dimensional array with entries cast to i8

Examples

let a = array![[-123, 123], [-456, 456]].into_dyn();
let v = Value::from_ndarray(a, INT32).unwrap();
let a = ToNdarray::<i8>::to_ndarray(&v,array_type(vec![2, 2], INT32)).unwrap();
assert_eq!(a, array![[-123i32 as i8, 123i32 as i8], [-456i32 as i8, 456i32 as i8]].into_dyn());
source§

impl ToNdarray<i16> for Value

Converts self to a multi-dimensional array if it is a byte vector, then cast the array entries to i16.

Arguments

t - array type used to interpret self

Result

Resulting multi-dimensional array with entries cast to i16

Examples

let a = array![[-123, 123], [-456, 456]].into_dyn();
let v = Value::from_ndarray(a, INT32).unwrap();
let a = ToNdarray::<i16>::to_ndarray(&v,array_type(vec![2, 2], INT32)).unwrap();
assert_eq!(a, array![[-123i32 as i16, 123i32 as i16], [-456i32 as i16, 456i32 as i16]].into_dyn());
source§

impl ToNdarray<i32> for Value

Converts self to a multi-dimensional array if it is a byte vector, then cast the array entries to i32.

Arguments

t - array type used to interpret self

Result

Resulting multi-dimensional array with entries cast to i32

Examples

let a = array![[-123, 123], [-456, 456]].into_dyn();
let v = Value::from_ndarray(a, INT32).unwrap();
let a = ToNdarray::<i32>::to_ndarray(&v,array_type(vec![2, 2], INT32)).unwrap();
assert_eq!(a, array![[-123i32, 123i32], [-456i32, 456i32]].into_dyn());
source§

impl ToNdarray<i64> for Value

Converts self to a multi-dimensional array if it is a byte vector, then cast the array entries to i64.

Arguments

t - array type used to interpret self

Result

Resulting multi-dimensional array with entries cast to i64

Examples

let a = array![[-123, 123], [-456, 456]].into_dyn();
let v = Value::from_ndarray(a, INT32).unwrap();
let a = ToNdarray::<i64>::to_ndarray(&v,array_type(vec![2, 2], INT32)).unwrap();
assert_eq!(a, array![[-123i32 as i64, 123i32 as i64], [-456i32 as i64, 456i32 as i64]].into_dyn());
source§

impl ToNdarray<i128> for Value

Converts self to a multi-dimensional array if it is a byte vector, then cast the array entries to i128.

Arguments

t - array type used to interpret self

Result

Resulting multi-dimensional array with entries cast to i128

Examples

let a = array![[-123, 123], [-456, 456]].into_dyn();
let v = Value::from_ndarray(a, INT32).unwrap();
let a = ToNdarray::<i128>::to_ndarray(&v,array_type(vec![2, 2], INT32)).unwrap();
assert_eq!(a, array![[-123i32 as i128, 123i32 as i128], [-456i32 as i128, 456i32 as i128]].into_dyn());
source§

impl ToNdarray<u8> for Value

Converts self to a multi-dimensional array if it is a byte vector, then cast the array entries to u8.

Arguments

t - array type used to interpret self

Result

Resulting multi-dimensional array with entries cast to u8

Examples

let a = array![[-123, 123], [-456, 456]].into_dyn();
let v = Value::from_ndarray(a, INT32).unwrap();
let a = ToNdarray::<u8>::to_ndarray(&v, array_type(vec![2, 2], INT32)).unwrap();
assert_eq!(a, array![[-123i32 as u8, 123i32 as u8], [-456i32 as u8, 456i32 as u8]].into_dyn());
source§

impl ToNdarray<u16> for Value

Converts self to a multi-dimensional array if it is a byte vector, then cast the array entries to u16.

Arguments

t - array type used to interpret self

Result

Resulting multi-dimensional array with entries cast to u16

Examples

let a = array![[-123, 123], [-456, 456]].into_dyn();
let v = Value::from_ndarray(a, INT32).unwrap();
let a = ToNdarray::<u16>::to_ndarray(&v,array_type(vec![2, 2], INT32)).unwrap();
assert_eq!(a, array![[-123i32 as u16, 123i32 as u16], [-456i32 as u16, 456i32 as u16]].into_dyn());
source§

impl ToNdarray<u32> for Value

Converts self to a multi-dimensional array if it is a byte vector, then cast the array entries to u32.

Arguments

t - array type used to interpret self

Result

Resulting multi-dimensional array with entries cast to u32

Examples

let a = array![[-123, 123], [-456, 456]].into_dyn();
let v = Value::from_ndarray(a, INT32).unwrap();
let a = ToNdarray::<u32>::to_ndarray(&v,array_type(vec![2, 2], INT32)).unwrap();
assert_eq!(a, array![[-123i32 as u32, 123i32 as u32], [-456i32 as u32, 456i32 as u32]].into_dyn());
source§

impl ToNdarray<u64> for Value

Converts self to a multi-dimensional array if it is a byte vector, then cast the array entries to u64.

Arguments

t - array type used to interpret self

Result

Resulting multi-dimensional array with entries cast to u64

Examples

let a = array![[-123, 123], [-456, 456]].into_dyn();
let v = Value::from_ndarray(a, INT32).unwrap();
let a = ToNdarray::<u64>::to_ndarray(&v,array_type(vec![2, 2], INT32)).unwrap();
assert_eq!(a, array![[-123i32 as u64, 123i32 as u64], [-456i32 as u64, 456i32 as u64]].into_dyn());
source§

impl ToNdarray<u128> for Value

Converts self to a multi-dimensional array if it is a byte vector, then cast the array entries to u128.

Arguments

t - array type used to interpret self

Result

Resulting multi-dimensional array with entries cast to u64

Examples

let a = array![[-123, 123], [-456, 456]].into_dyn();
let v = Value::from_ndarray(a, INT32).unwrap();
let a = ToNdarray::<u128>::to_ndarray(&v,array_type(vec![2, 2], INT32)).unwrap();
assert_eq!(a, array![[-123i32 as u128, 123i32 as u128], [-456i32 as u128, 456i32 as u128]].into_dyn());