Multiplying transposed matrices in mir
jmh530
john.michael.hall at gmail.com
Sun Apr 19 20:06:23 UTC 2020
On Sunday, 19 April 2020 at 19:20:28 UTC, p.shkadzko wrote:
> [snip]
> well no, "assumeContiguous" reverts the results of the
> "transposed" and it's "a * a".
> I would expect it to stay transposed as NumPy does "assert
> np.all(np.ascontiguous(a.T) == a.T)".
Ah, you're right. I use it in other places where it hasn't been
an issue.
I can do it with an allocation (below) using the built-in syntax,
but not sure how do-able it is without an allocation (Ilya would
know better than me).
/+dub.sdl:
dependency "lubeck" version="~>1.1.7"
dependency "mir-algorithm" version="~>3.7.28"
+/
import mir.ndslice;
import lubeck;
void main() {
auto a = [2.1, 1.0, 3.2, 4.5, 2.4, 3.3, 1.5, 0,
2.1].sliced(3, 3);
auto b = a * a.transposed.slice;
}
More information about the Digitalmars-d-learn
mailing list