Skip to main content

ravel

Function ravel 

Source
pub fn ravel<T: Clone>(
    array: &Array<T>,
    order: Option<char>,
) -> Result<Array<T>>
Expand description

Convert array to a flattened 1-D array (C-style order by default).

Unlike flatten(), this function returns a view of the original array when possible.

§Parameters

  • array - The array to flatten
  • order - Memory layout: ‘C’ (row-major, default) or ‘F’ (column-major)

§Returns

A flattened view of the array

§Examples

use numrs2::prelude::*;

let a = Array::from_vec(vec![1, 2, 3, 4, 5, 6]).reshape(&[2, 3]);
let flat = ravel(&a, None).expect("operation should succeed");
assert_eq!(flat.shape(), vec![6]);
assert_eq!(flat.to_vec(), vec![1, 2, 3, 4, 5, 6]);