pydatastructs icon indicating copy to clipboard operation
pydatastructs copied to clipboard

Add Matrix multiplication (sequential and parallel)

Open HarsheetKakar opened this issue 4 years ago • 17 comments

Description of the problem

Example of the problem

References/Other comments

HarsheetKakar avatar Mar 31 '20 15:03 HarsheetKakar

We would be needing strassen's algorithm to be implemented, which is the best I know, for sequential version. Any other you are aware of?

czgdp1807 avatar Mar 31 '20 18:03 czgdp1807

A lot of algorithms are described here https://en.wikipedia.org/wiki/Matrix_multiplication_algorithm We need to implement them all. Should go to, linear_data_structures.algorithms.

czgdp1807 avatar Mar 31 '20 18:03 czgdp1807

We would be needing strassen's algorithm to be implemented, which is the best I know, for sequential version. Any other you are aware of?

I have tried to pitch that idea in many repos but they all come to the same conclusion to not do it because it takes up a lot of space and practically is slow even if the asymptotics are better

HarsheetKakar avatar Mar 31 '20 18:03 HarsheetKakar

Lets start with naive implementation ( O(n^3) ) of sequential and parallel and then see if strassen is doable.

HarsheetKakar avatar Mar 31 '20 18:03 HarsheetKakar

it takes up a lot of space and practically is slow

Can you provide any numbers(time, space) of from the analysis they used to arrive at the conclusion?

czgdp1807 avatar Mar 31 '20 18:03 czgdp1807

Lets start with naive implementation ( O(n^3) )

Isn't of much use, it's too simple to implement.

czgdp1807 avatar Mar 31 '20 18:03 czgdp1807

it takes up a lot of space and practically is slow

Can you provide any numbers(time, space) of from the analysis they used to arrive at the conclusion?

One of the senior programmers stopped me from actually approaching the problem and closed the issue. So I dont know the actual issues they have but I can try it.

HarsheetKakar avatar Mar 31 '20 18:03 HarsheetKakar

Lets start with naive implementation ( O(n^3) )

Isn't of much use, it's too simple to implement.

and the parallel one?

HarsheetKakar avatar Mar 31 '20 18:03 HarsheetKakar

In practice, Strassen's algorithm can be implemented to attain better performance than conventional multiplication even for small matrices, for matrices that are not at all square, and without requiring workspace beyond buffers that are already needed for a high-performance conventional multiplication

Quoting from, https://en.wikipedia.org/wiki/Strassen_algorithm#Implementation_considerations

The image under https://en.wikipedia.org/wiki/Matrix_multiplication#Computational_complexity gives a graph where all the algorithms are named, so all of them should be implemented.

czgdp1807 avatar Mar 31 '20 18:03 czgdp1807

and the parallel one?

Yes we can go with that. I think it's not that difficult to implement.

czgdp1807 avatar Mar 31 '20 18:03 czgdp1807

and the parallel one?

Yes we can go with that. I think it's not that difficult to implement.

sure

HarsheetKakar avatar Mar 31 '20 18:03 HarsheetKakar

One of the senior programmers stopped me from actually approaching the problem and closed the issue. So I dont know the actual issues they have but I can try it.

Can you please provide a link to that issue? A proper research is needed on this is needed before reaching to any conclusion.

We iterate this division process n times (recursively) until the submatrices degenerate into numbers (elements of the ring R).

May be due to recursion it may be slow for small matrices. We should use iterative logic using stacks.

czgdp1807 avatar Mar 31 '20 18:03 czgdp1807

One of the senior programmers stopped me from actually approaching the problem and closed the issue. So I dont know the actual issues they have but I can try it.

Can you please provide a link to that issue? A proper research is needed on this is needed before reaching to any conclusion.

if I could have I would have but the thing is I was preparing for gsoc last year when I pushed this issue so I have no recollection what so ever from where I got it.

We iterate this division process n times (recursively) until the submatrices degenerate into numbers (elements of the ring R).

May be due to recursion it may be slow for small matrices. We should use iterative logic using stacks.

we can start it and we can optimize as we move, I will start with the parallel multiplication first and then move to strassen.

HarsheetKakar avatar Mar 31 '20 18:03 HarsheetKakar

should it be applicable for DODA also? If yes then how should the None values be handled?

HarsheetKakar avatar Apr 01 '20 17:04 HarsheetKakar

@czgdp1807 Let me take up this work and it seems the Parallel matrix multiplication was already implemented and what's left is Sequential multiplication. Should I go with Strassen algorithm for study or any suggestions!?

Arvind-raj06 avatar Jan 19 '21 10:01 Arvind-raj06

This issue is not in priority as of now.

czgdp1807 avatar Jan 19 '21 10:01 czgdp1807

This issue is not in priority as of now.

Ok I will look for other issues

Arvind-raj06 avatar Jan 19 '21 12:01 Arvind-raj06