Advertisement
Guest User

Untitled

a guest
Apr 20th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.36 KB | None | 0 0
  1.  
  2. template<class T>
  3. void Matris<T>::transpose() {
  4.   T *temp_vec = new T[m_capacity];
  5.  
  6.   for (int row = 0; row < m_rows; ++row) {
  7.     for (int col = 0; col < m_cols; ++col) {
  8.       temp_vec[col * m_rows + row] = m_vec[row * m_cols + col];
  9.     }
  10.   }
  11.  
  12.   delete [] m_vec;
  13.   m_vec = temp_vec;
  14.  
  15.   int temp = m_rows;
  16.   m_rows = m_cols;
  17.   m_cols = temp;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement