m-tosch / mu

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

row() and col() to return specific rows and columns #89

Closed m-tosch closed 3 years ago

m-tosch commented 3 years ago

Rename current rows() and cols() to n_rows() and n_cols() implement row() and col() such that they take a number and return a Vector object of that row/column

mu::Matrix<2,2,int> m{  {1,2}, {3,4} };
mu::Vector<2,int> = m.row(1); // [ 3,4 ]
mu::Vector<2,int> = m.col(1); // [ 2,4 ]
m-tosch commented 3 years ago

puts asserts in these functions to catch invalid index access outside the matrix dimensions. From pointer arithmetic this is valid and would case a compile time error! checked the asserts in the tests too