mridul1809's blog

By mridul1809, history, 4 weeks ago, In English,

Hey everyone!

I have been trying to implement a Matrix class that contains the operations required frequently when facing problems of that domain.

So here it is : Link

I would like to invite everyone to use this for their convenience.

The implementation is to best of my knowledge but I am sure it's not perfect or complete. So if you can think of any improvements or additions please comment or DM or add a pull request!

I also intend to add templates regarding other topics as well. Please suggest me a few topics to work on.

Thank You! :)

 
 
 
 
  • Vote: I like it
  • +5
  • Vote: I do not like it

»
4 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

I think, method to calculate determinant for square matrices can be useful.

»
4 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Nice work bro

»
4 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

In your template, all operations are being computed modulo $$$mod$$$, but unary $$$-$$$ is not. So, that will be an issue.

»
4 weeks ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

For large matrices this is fine, but for small (2x2 for example) matrices the cost of allocating and deallocating memory on the heap would be significant. I usually use template<int N, int M> struct Matrix { std::array<std::array<int, M>, N> A; }, or even template<int N, int M> struct Matrix : std::array<std::array<int, M>, N> { } (the latter way has the advantage of having operator == and operator [] implemented).

»
6 days ago, # |
  Vote: I like it 0 Vote: I do not like it

One of the most useful and well written templates I have seen. mridul1809

»
6 days ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

Better overload the assignment operations, i.e. +=,-=,*= and ^=, and implement them without creating a new matrix in order to save time and memory. And what about other operations like transpose ?

»
6 days ago, # |
  Vote: I like it 0 Vote: I do not like it

Great work bro.