Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template<class T>
- void Matris<T>::transpose() {
- T *temp_vec = new T[m_capacity];
- for (int row = 0; row < m_rows; ++row) {
- for (int col = 0; col < m_cols; ++col) {
- temp_vec[col * m_rows + row] = m_vec[row * m_cols + col];
- }
- }
- delete [] m_vec;
- m_vec = temp_vec;
- int temp = m_rows;
- m_rows = m_cols;
- m_cols = temp;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement