this is my first time asking a question so please forgive me if I do something wrong.
I'm trying to code Strassen's algorithm in matlab and it seems to work, but it is very slow (depending on the cut-off, it can already take over a second for 64x64 matrices).
It's slower than the naive implementation (with 3 loops). Is there something I'm doing horribly wrong? Below is the function, input is already of correct size (2^n)
function [ D ] = ActualStrassen( PaddedA, PaddedB )
[m n] = size(PaddedA);
if n < 5
D = PaddedA*PaddedB;
else
A11 = PaddedA( 1:n/2 , 1:n/2 );
A12 = PaddedA( 1:n/2 , n/2+1:end);
A21 = PaddedA( n/2+1:end , 1:n/2 );
A22 = PaddedA( n/2+1:end , n/2+1:end);
B11 = PaddedB( 1:n/2 , 1:n/2 );
B12 = PaddedB( 1:n/2 , n/2+1:end);
B21 = PaddedB( n/2+1:end , 1:n/2 );
B22 = PaddedB( n/2+1:end , n/2+1:end);
M1=ActualStrassen( A11 + A22 , B11 + B22);
M2=ActualStrassen( A21 + A22 , B11 );
M3=ActualStrassen( A11 , B12 - B22);
M4=ActualStrassen( A22 , B21 - B11);
M5=ActualStrassen( A11 + A12 , B22 );
M6=ActualStrassen( A21 - A11 , B11 + B12);
M7=ActualStrassen( A12 - A22 , B21 + B22);
D11= M1 + M4 - M5 + M7;
D12= M3 + M5;
D21= M2 + M4;
D22= M1 - M2 + M3 + M6;
D = [D11, D12; D21, D22];
end
end