Matrix multiplication: Strassen vs. Standard

前端 未结 5 1506
萌比男神i
萌比男神i 2021-02-06 16:38

I tried to implement the Strassen algorithm for matrix multiplication with C++, but the result isn\'t that, what I expected. As you can see strassen always takes more time then

5条回答
  •  离开以前
    2021-02-06 17:32

    Ok I am no expert in this field, but there might be other issues at work here than processing speed. First the strassen method uses way more stack and has more function calls, which add memory movement. You have a certain penalty the larger your stack gets, since it needs to request larger frames from the OS. Plus you use dynamic allocation, this is also an issue.

    Try to use a fixed size (with template parameter) matrix class? This will at least resolve the allocation issue.

    Note: I am not sure that it event works properly with your code. Your matrix class uses pointers but has no copy constructor or assignment operator. You are also leaking memory at the end, since you don't have a destructor...

提交回复
热议问题