Rename to from_array

This commit is contained in:
Luis Moreno
2020-11-11 22:23:56 -04:00
parent 49487bccd3
commit 6587ac032b
2 changed files with 5 additions and 5 deletions
+4 -4
View File
@@ -86,11 +86,11 @@ pub trait BaseVector<T: RealNumber>: Clone + Debug {
/// Create a new vector from a &[T]
/// ```
/// use smartcore::linalg::naive::dense_matrix::*;
/// let slice: &[f64] = &[0., 0.5, 2., 3., 4.];
/// let a: Vec<f64> = BaseVector::from_slice(slice);
/// assert_eq!(a, vec![0., 0.5, 2., 3., 4.]);
/// let a: [f64; 5] = [0., 0.5, 2., 3., 4.];
/// let v: Vec<f64> = BaseVector::from_array(&a);
/// assert_eq!(v, vec![0., 0.5, 2., 3., 4.]);
/// ```
fn from_slice(f: &[T]) -> Self {
fn from_array(f: &[T]) -> Self {
let mut v = Self::zeros(f.len());
for (i, elem) in f.iter().enumerate() {
v.set(i, *elem);