Skip to main content

full

Function full 

Source
pub fn full(shape: impl IntoShape, value: impl Into<ScalarOrArray>) -> Array
Expand description

An array of shape with every element value: a Rust number is weak, as in MLX (0.5 gives float32, 1 int32), and an array keeps its dtype (Array::from(7u8) gives uint8).

use nuvec_core::{Array, DType, ops::full};

assert_eq!(full([2, 2], 0.5).dtype(), DType::F32);
let a = full([2, 2], Array::from(7u8));
assert_eq!((a.dtype(), a.to_vec::<u8>().unwrap()), (DType::U8, vec![7; 4]));