from solvers import solvers, solve_theoretical
from util import Grid

import numpy as np

if __name__ == '__main__':
  I = 16
  K = 512

  grid = Grid(I, K)

  for solver in solvers:
    solution = solver(grid)
    if solution is None:
      continue

    print(solver.__name__)

    reference = solve_theoretical(grid)

    e = np.abs(reference - solution)

    flat_indices = np.argsort(e, axis=None)

    for index in flat_indices[-10:]:
      i, j = np.unravel_index(index, e.shape)
      print(f'{i:4} {j:4} {e[i, j]}')
