MCPcopy Index your code
hub / github.com/arrayfire/arrayfire-rust / identity

Function identity

src/core/data.rs:362–375  ·  view source on GitHub ↗

Create an identity array with 1's in diagonal # Parameters - `dims` is the output Array dimensions # Return Values Identity matrix

(dims: Dim4)

Source from the content-addressed store, hash-verified

360///
361/// Identity matrix
362pub fn identity<T: HasAfEnum>(dims: Dim4) -> Array<T> {
363 let aftype = T::get_af_dtype();
364 unsafe {
365 let mut temp: af_array = std::ptr::null_mut();
366 let err_val = af_identity(
367 &mut temp as *mut af_array,
368 dims.ndims() as c_uint,
369 dims.get().as_ptr() as *const dim_t,
370 aftype as c_uint,
371 );
372 HANDLE_ERROR(AfError::from(err_val));
373 temp.into()
374 }
375}
376
377/// Create a diagonal matrix
378///

Callers

nothing calls this directly

Calls 4

HANDLE_ERRORFunction · 0.85
ndimsMethod · 0.80
intoMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected