-- row major upper triangular indexing
idx :: Int -> Int -> Int -> Int
idx n i j = (i * (2 * n - i - 1)) `shiftR` 1 + j
idx :: Int -> Int -> Int -> Int
idx n i j = (i * (2 * n - i - 1)) `shiftR` 1 + j
idx n i j = (i * (2 * n - i - 1)) `shiftR` 1 + j