Skip to content
Snippets Groups Projects
Select Git revision
  • 2316da9985d192051291562247183d3fac932033
  • master default protected
2 results

matrix_transpose.h

Blame
  • 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);
    }