m-tosch / mu

A small, simple c++ math library
MIT License
1 stars 0 forks source link

diag() function that returns the Matrix diagonale as a Vector #84

Closed m-tosch closed 3 years ago

m-tosch commented 3 years ago

Example 1

For a matrix

3, 4, 5
6, 7, 8
9, 9, 9

the diag() function should return

3, 7, 9

as a Vector.

Example 2

For a matrix

1, 4
2, 5
3, 6

the diag() function should return

1, 5

as a Vector.

Example 3

For a matrix

1, 2, 3
4, 5, 6

the diag() function should return

1, 5

as a Vector.

Also provide a diag() function that takes a vector as an input argument and builds a diagonal Matrix that has 0 values everywhere else but on the diagonal. TBD: free functions or member functions too?

m-tosch commented 3 years ago

Also provide a diag() function that takes a vector as an input argument and builds a diagonal Matrix that has 0 values everywhere else but on the diagonal.

As of now it is unclear where this function should be put. implementation done. currently in Matrix header file. Problem is that for testing, this needs to be tested with different Vectors, so it would fit into the vector_type.h test header. Therefore it should probably be in the Vector header file, i thought... but of course this introduces a circular dependency between the Vector and Matrix header files. Will postpone this to another issue