← Back

Module constructors

fn zeros[T; const N: u32](dims: [usize; N]) -> NDArray[T; N]

Create an NDArray filled with zeros.

Source: constructors.joule:18

fn ones[T; const N: u32](dims: [usize; N]) -> NDArray[T; N]

Create an NDArray filled with ones.

Source: constructors.joule:29

fn full[T; const N: u32](dims: [usize; N], value: T) -> NDArray[T; N]

Create an NDArray filled with a constant value.

Source: constructors.joule:39

fn from_data[T; const N: u32](data: *mut T, dims: [usize; N]) -> NDArray[T; N]

Create an NDArray from an existing data buffer. Takes ownership of the buffer — zero-copy.

Source: constructors.joule:46

fn eye[T](size: usize) -> NDArray[T; 2]

Create an identity matrix (rank 2 only).

Source: constructors.joule:56

fn linspace[T](start: T, stop: T, num: usize) -> NDArray[T; 1]

Create a rank-1 array with evenly spaced values.

Source: constructors.joule:66

fn arange[T](start: T, stop: T, step: T) -> NDArray[T; 1]

Create a rank-1 array with values in [start, stop) with given step.

Source: constructors.joule:76

fn diag[T](vec: &NDArray[T; 1]) -> NDArray[T; 2]

Create a diagonal matrix from a rank-1 array.

Source: constructors.joule:87

fn zeros_aligned[T; const N: u32](dims: [usize; N], alignment: usize) -> NDArray[T; N]

Create a SIMD-aligned NDArray (alignment must be power of 2).

Source: constructors.joule:97