1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
pub mod product; use array::Array; /// Checks if array is matrix like /// /// # Arguments /// /// * `array` - array /// /// # Examples /// /// ``` /// use numas::array::Array; /// /// let matrix = Array::new(vec![1, 2, 3, 4, 5, 6], vec![2, 3]); /// let vector = Array::new(vec![1, 2, 3, 4, 5, 6], vec![6]); /// /// assert_eq!(numas::linear_algebra::is_matrix(&matrix), true); /// assert_ne!(numas::linear_algebra::is_matrix(&vector), true); /// ``` #[inline] pub fn is_matrix<T: Copy>(array: &Array<T>) -> bool { return array.get_shape().len() == 2; } /// Checks if array is vector like /// /// # Arguments /// /// * `array` - array /// /// # Examples /// /// ``` /// use numas::array::Array; /// /// let matrix = Array::new(vec![1, 2, 3, 4, 5, 6], vec![2, 3]); /// let vector = Array::new(vec![1, 2, 3, 4, 5, 6], vec![6]); /// /// assert_eq!(numas::linear_algebra::is_vector(&vector), true); /// assert_ne!(numas::linear_algebra::is_vector(&matrix), true); /// ``` #[inline] pub fn is_vector<T: Copy>(array: &Array<T>) -> bool { return array.get_shape().len() == 1; }