I'm new to Rust.
Suppose a matrix a has shape (n1, n2), b has (m1, m2), and c has (k1, k2).
I would like to check that a and b can be multiplied (as matrices) and the shape of a * b is equal to c. In other words, (n2 == m1) && (n1 == k1) && (m2 == k2).
use ndarray::Array2;
// a : Array2<i64>
// b : Array2<i64>
// c : Array2<i64>
.shape method returns the shape of the array as a slice.
What is the concise way to do it?
Is the returned array from .shape() guaranteed to have length 2, or should I check it? If it guaranteed, is there a way to skip the None checking?
let n1 = a.shape().get(0); // this is Optional<i64>