I’m trying to address the issue of odd matrices for strassen’s algorithm. My implementation truncates the recursion at a certain point, call it Q, and switches over to the standard implementation. Therefore in doing static padding, I don’t actually need to pad up to the next power of 2. I just need to pad up to the least m*2^k greater than the input matrix dimension such that m < Q.
I’m having some trouble implementing this – mainly because I’m not sure what would be most efficient. Do I need to loop through all possible m values, or do I increment from each given input, testing if they fulfill the criteria?
You are correct. Padding up to m * 2^k should perform much better than padding up to next power of 2.
I think you should pad up to value calculated by this function: