code: private static int pivsign(int[] piv, int n) {
          int pivsign = 1;
          for (int i = 0; i < n; i++) {
              if (piv[i] != (i+1))
                  pivsign = -pivsign;
          }
  
          return pivsign;
      }
docs: Returns the pivot sign.