ndarray icon indicating copy to clipboard operation
ndarray copied to clipboard

Dot product with dyn arrays

Open FredrikNoren opened this issue 5 years ago • 3 comments

Hi, for some reason this isn't working for me:

let a = array![[1.]].into_dyn();
let b = array![[1.]].into_dyn();
let c = a.dot(&b);

I'm getting this error:

no method named `dot` found for struct `ArrayBase<OwnedRepr<{float}>, Dim<IxDynImpl>>` in the current scope
method not found in `ArrayBase<OwnedRepr<{float}>, Dim<IxDynImpl>>`

Am I doing something wrong or is this a bug? Version 0.14.0

FredrikNoren avatar Jan 07 '21 14:01 FredrikNoren

The dot product isn't implemented for dynamic-dimensional arrays right now, although I wouldn't be opposed to adding these implementations. For the time being, you can work around this by converting dynamic-dimensional arrays into const-dimensional arrays with .into_dimensionality() before calling .dot().

jturner314 avatar Jan 08 '21 01:01 jturner314

@jturner314 Ah ok perfect, thanks!

FredrikNoren avatar Jan 08 '21 11:01 FredrikNoren

The dot product isn't implemented for dynamic-dimensional arrays right now, although I wouldn't be opposed to adding these implementations. For the time being, you can work around this by converting dynamic-dimensional arrays into const-dimensional arrays with .into_dimensionality() before calling .dot().

And how do I change the result dimensions back to the previous ones after that?

georgikolev17 avatar Apr 20 '23 21:04 georgikolev17