Select Git revision
matrix_transpose.h
Tung Anh Vu authored
matrix_transpose.h 566 B
/*
* This file is #include'd inside the definition of a matrix class
* like this:
*
* class ClassName {
* // Number of rows and columns of the matrix
* unsigned N;
*
* // Swap elements (i1,j1) and (i2,j2)
* void swap(unsigned i1, unsigned j1, unsigned i2, unsigned j2);
*
* // Your code
* #include "matrix_transpose.h"
* }
*/
void transpose()
{
// TODO: Implement this efficiently
for (unsigned i=0; i<N; i++)
for (unsigned j=0; j<i; j++)
swap(i, j, j, i);
}