Skip to content
Snippets Groups Projects
Select Git revision
  • 85fbb669bd5e966b9c84a971a81a44416c95e37f
  • devel default
  • master
  • fo
  • jirka/typing
  • fo-base
  • mj/submit-images
  • jk/issue-96
  • jk/issue-196
  • honza/add-contestant
  • honza/mr7
  • honza/mrf
  • honza/mrd
  • honza/mra
  • honza/mr6
  • honza/submit-images
  • honza/kolo-vs-soutez
  • jh-stress-test-wip
  • shorten-schools
19 results

setup.py

Blame
  • matrix_transpose.py 641 B
    class Matrix:
        """Interface of a matrix.
    
        This class provides only the matrix size N and a method for swapping
        two items. The actual storage of the matrix in memory is provided by
        subclasses in testing code.
        """
    
        def __init__(self, N):
            self.N = N
    
        def swap(self, i1, j1, i2, j2):
            """Swap elements (i1,j1) and (i2,j2)."""
    
            # Overridden in subclasses
            raise NotImplementedError
    
        def transpose(self):
            """Transpose the matrix."""
    
            # TODO: Implement more efficiently
            for i in range(self.N):
                for j in range(i):
                    self.swap(i, j, j, i)