code: public void decode(int[] received, int twoS) throws ReedSolomonException {
      GenericGFPoly poly = new GenericGFPoly(field, received);
      int[] syndromeCoefficients = new int[twoS];
      boolean noError = true;
      for (int i = 0; i < twoS; i++) {
        int eval = poly.evaluateAt(field.exp(i + field.getGeneratorBase()));
        syndromeCoefficients[syndromeCoefficients.length - 1 - i] = eval;
        if (eval != 0) {
          noError = false;
        }
      }
      if (noError) {
        return;
      }
      GenericGFPoly syndrome = new GenericGFPoly(field, syndromeCoefficients);
      GenericGFPoly[] sigmaOmega =
          runEuclideanAlgorithm(field.buildMonomial(twoS, 1), syndrome, twoS);
      GenericGFPoly sigma = sigmaOmega[0];
      GenericGFPoly omega = sigmaOmega[1];
      int[] errorLocations = findErrorLocations(sigma);
      int[] errorMagnitudes = findErrorMagnitudes(omega, errorLocations);
      for (int i = 0; i < errorLocations.length; i++) {
        int position = received.length - 1 - field.log(errorLocations[i]);
        if (position < 0) {
          throw new ReedSolomonException("Bad error location");
        }
        received[position] = GenericGF.addOrSubtract(received[position], errorMagnitudes[i]);
      }
    }
docs: <p>Decodes given set of received codewords, which include both data and error-correction
  codewords. Really, this means it uses Reed-Solomon to detect and correct errors, in-place,
  in the input.</p>
  
  @param received data and error-correction codewords
  @param twoS number of error-correction codewords available
  @throws ReedSolomonException if decoding fails for any reason