Multiplying transposed matrices in mir

9il ilyayaroshenko at gmail.com
Mon Apr 20 02:42:33 UTC 2020


On Sunday, 19 April 2020 at 20:29:54 UTC, p.shkadzko wrote:
> On Sunday, 19 April 2020 at 20:06:23 UTC, jmh530 wrote:
>> On Sunday, 19 April 2020 at 19:20:28 UTC, p.shkadzko wrote:
>>> [...]
>>
>> 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;
>> }
>
> Thanks. I somehow missed the whole point of "a * a.transposed" 
> not working because "a.transposed" is not allocated.

In the same time, the SliceKind isn't matter for assignment 
operations:

auto b = a.slice; // copy a to b
b[] *= a.transposed; // works well


More information about the Digitalmars-d-learn mailing list