Converts a matrix into a comma seperated list of values. As delimiter between the columns the string `sep` is used. As delimiter between the rows a newline is used. # Example ``` # #[macro_use] extern crate rustml; use rustml::*; use rustml::csv::matrix_to_csv; # fn main() { let m = mat![1.0, 2.0; 3.0, 4.0]; assert_eq!(matrix_to_csv(&m, ","), "1,2\n3,4\n") # } ```
(m: &Matrix<T>, sep: &str)
| 49 | /// # } |
| 50 | /// ``` |
| 51 | pub fn matrix_to_csv<T: fmt::Display + Clone>(m: &Matrix<T>, sep: &str) -> String { |
| 52 | |
| 53 | m.row_iter() |
| 54 | .map(|row| vec_to_csv(row, sep)) |
| 55 | .fold(String::new(), |s, val| s + &val + "\n") |
| 56 | } |
| 57 | |
| 58 | |
| 59 | /// Reads a matrix from a CSV. |
nothing calls this directly
no test coverage detected