pub fn try_from_vec2d<T: Clone + Zero>(
data: Vec<Vec<T>>,
) -> Result<Matrix<T>, MatrixShapeError>Expand description
Create a matrix from a 2D vector, returning an error for ragged rows.
Each inner Vec is one row. The resulting matrix is stored internally in
column-major order.
§Errors
Returns MatrixShapeError::RaggedRows when any row has a different length
than the first row.
§Examples
use tensor4all_tensorbackend::try_from_vec2d;
let m = try_from_vec2d(vec![
vec![1.0, 2.0],
vec![3.0, 4.0],
])?;
assert_eq!(m.nrows(), 2);
assert_eq!(m.ncols(), 2);
assert_eq!(m[[0, 1]], 2.0);
assert_eq!(m[[1, 0]], 3.0);