You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Feature request] ArrayRef<A, Ix2>.dot() for axis greater than Ix2 #1587
In NumPy, the left-hand side of a matrix multiplication can have as many axes as desired, as long as it has more than 2 axes and the last axis's dimension matches that of the 0th axis of the right-hand side, e.g.:
$ cargo run
Compiling playground v0.1.0 (/home/connor/RustroverProjects/playground)
error[E0275]: overflow evaluating the requirement `&ArrayBase<_, _, _>: Not`
--> src/main.rs:15:17
|
15 | let x_y = x.dot(&y);
| ^^^
|
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`playground`)
= note: required for `&ArrayBase<_, _, _>` to implement `Not`
= note: 127 redundant requirements hidden
= note: required for `&ArrayBase<OwnedRepr<f64>, Dim<[usize; 3]>, f64>` to implement `Not`
For more information about this error, try `rustc --explain E0275`.
error: could not compile `playground` (bin "playground") due to 1 previous error
Emulating the behavior in the previous NumPy example requires a non-trivial amount of work, e.g. for x with 3 axes:
use ndarray::prelude::*;use ndarray_rand::RandomExt;use ndarray_rand::rand_distr::Uniform;fnmain(){let x:Array<f64,Ix3> = Array::random((12,4,3),Uniform::new(0.,1.).unwrap());let y = Array::random((3,2),Uniform::new(0.,1.).unwrap());let(a, b, c) = (x.len_of(Axis(0)), x.len_of(Axis(1)), x.len_of(Axis(2)));let d = y.len_of(Axis(1));let x_y:Array3<f64> = x
.to_shape((a * b, c)).unwrap().dot(&y).to_shape((a, b, d)).unwrap().to_owned();println!("{:?}", x_y);}
Therefore, I think it would be nice to have dot() be implemented for axis numbers greater than Ix2
changed the title [-]`ArrayRef<A, Ix2>.dot()` for axis greater than `Ix2`[/-][+][Feature request] `ArrayRef<A, Ix2>.dot()` for axis greater than `Ix2`[/+]on Mar 2, 2026
This might be a duplicate of #16, though I'm uncertain why the original issue poster specifies that the proposed feature would be restricted to float types.
Activity
[-]`ArrayRef<A, Ix2>.dot()` for axis greater than `Ix2`[/-][+][Feature request] `ArrayRef<A, Ix2>.dot()` for axis greater than `Ix2`[/+]boyleconnor commentedon Mar 2, 2026
This might be a duplicate of #16, though I'm uncertain why the original issue poster specifies that the proposed feature would be restricted to float types.