ndarray
ndarray copied to clipboard
Fixed axis length support similiar to `Eigen`
In Eigen, We can write Matrix<float, 4, 4> to represent a matrix with fixed 4x4 size. In Rust, I would imaging syntax similar to ArrayBase<Array2Repr<T, 4, 4>, FixedIx2<4, 4>>, which has no allocation, const bound check and enable better simd instructions.
I can see several difficulty implementing this:
Dimensiontrait currently requiresAdd/Sub/Mul, which doesn't make sense in fixed length.ArrayReprrequires exact generic argument match toFixedIx2. This might requires refactor toDataorDimensiontraits.- Enable better simd instructions on specific axis length might require
#[feature(const_evaluatable_checked)]and#[feature(specialization)], and both of them are incomplete feature. - Mixing fixed axis length and dynamic axis length in one matrix seems hard.
I think @bluss has indicated in the past that he doesn't want to do this, but it's been a while. Personally, I'm concerned about the additional complexity without sufficient benefit. I think it would make more sense to start with named tensor functionality, with marker types for the axis names. This is more important for n-D arrays, IMO, and then we could consider supporting const lengths associated with the marker types.
You may be interested in the nalgebra crate, which provides fixed axis length support for vectors and matrices (but not arrays with more than 2 dimensions).
I think @bluss has indicated in the past that he doesn't want to do this, but it's been a while. Personally, I'm concerned about the additional complexity without sufficient benefit. I think it would make more sense to start with named tensor functionality, with marker types for the axis names. This is more important for n-D arrays, IMO, and then we could consider supporting const lengths associated with the marker types.
You may be interested in the
nalgebracrate, which provides fixed axis length support for vectors and matrices (but not arrays with more than 2 dimensions).
Thanks, I will look into nalgebra. On the other hand, I will investigate the complexity/benefit factor deeper.