private void findExtremalIndices() throws FilterDesignException {
  mExtremalIndices.clear();
  if (((mGridErrors[0] > 0.0 && mGridErrors[0] > mGridErrors[1]) || (mGridErrors[0] < 0.0 && mGridErrors[0] < mGridErrors[1])) && isGTEDelta(mGridErrors[0])) {
    mExtremalIndices.add(0);
  }
  for (int x=1; x < mGridErrors.length - 1; x++) {
    if (((mGridErrors[x] > 0.0 && (mGridErrors[x - 1] <= mGridErrors[x] && mGridErrors[x] > mGridErrors[x + 1])) || (mGridErrors[x] < 0.0 && (mGridErrors[x - 1] >= mGridErrors[x] && mGridErrors[x] < mGridErrors[x + 1]))) && isGTEDelta(mGridErrors[x])) {
      mExtremalIndices.add(x);
    }
  }
  int last=mGridErrors.length - 1;
  if (((mGridErrors[last] > 0.0 && (mGridErrors[last] > mGridErrors[last - 1])) || (mGridErrors[last] < 0.0 && (mGridErrors[last] < mGridErrors[last - 1]))) && isGTEDelta(mGridErrors[last])) {
    mExtremalIndices.add(last);
  }
  if (mExtremalIndices.size() < mSpecification.getExtremaCount()) {
    throw new FilterDesignException("Couldn't find the minimum extremal frequencies in " + "error set");
  }
  List<Integer> indicesToRemove=new ArrayList<>();
  Iterator<Integer> it=mExtremalIndices.iterator();
  Integer current=it.next();
  Integer next;
  boolean positiveAxis=mGridErrors[current] > 0.0;
  while (it.hasNext()) {
    next=it.next();
    if (!(positiveAxis ^ (mGridErrors[next] > 0.0))) {
      if (Math.abs(mGridErrors[next]) <= Math.abs(mGridErrors[current])) {
        it.remove();
        next=current;
      }
 else {
        indicesToRemove.add(current);
      }
    }
 else {
      positiveAxis=!positiveAxis;
    }
    current=next;
  }
  mExtremalIndices.removeAll(indicesToRemove);
  while (mExtremalIndices.size() > mSpecification.getExtremaCount()) {
    mExtremalIndices.remove(mExtremalIndices.size() - 1);
  }
  if (mExtremalIndices.size() > mSpecification.getExtremaCount()) {
    int lastIndex=mExtremalIndices.size() - 1;
    if (Math.abs(mGridErrors[mExtremalIndices.get(0)]) > Math.abs(mGridErrors[mExtremalIndices.get(lastIndex)])) {
      mExtremalIndices.remove(lastIndex);
    }
 else {
      mExtremalIndices.remove(0);
    }
  }
  if (mExtremalIndices.size() < mSpecification.getExtremaCount()) {
    throw new FilterDesignException("Couldn't find the minimum extremal frequencies in " + "error set");
  }
}

private void findExtremalIndices ( ) throws FilterDesignException { mExtremalIndices . clear ( ) ; if ( ( ( mGridErrors [ 0 ] > 0.0 && mGridErrors [ 0 ] > mGridErrors [ 1 ] ) || ( mGridErrors [ 0 ] < 0.0 && mGridErrors [ 0 ] < mGridErrors [ 1 ] ) ) && isGTEDelta ( mGridErrors [ 0 ] ) ) { mExtremalIndices . add ( 0 ) ; } for ( int x = 1 ; x < mGridErrors . length - 1 ; x ++ ) { if ( ( ( mGridErrors [ x ] > 0.0 && ( mGridErrors [ x - 1 ] <= mGridErrors [ x ] && mGridErrors [ x ] > mGridErrors [ x + 1 ] ) ) || ( mGridErrors [ x ] < 0.0 && ( mGridErrors [ x - 1 ] >= mGridErrors [ x ] && mGridErrors [ x ] < mGridErrors [ x + 1 ] ) ) ) && isGTEDelta ( mGridErrors [ x ] ) ) { mExtremalIndices . add ( x ) ; } } int last = mGridErrors . length - 1 ; if ( ( ( mGridErrors [ last ] > 0.0 && ( mGridErrors [ last ] > mGridErrors [ last - 1 ] ) ) || ( mGridErrors [ last ] < 0.0 && ( mGridErrors [ last ] < mGridErrors [ last - 1 ] ) ) ) && isGTEDelta ( mGridErrors [ last ] ) ) { mExtremalIndices . add ( last ) ; } if ( mExtremalIndices . size ( ) < mSpecification . getExtremaCount ( ) ) { throw new FilterDesignException ( "Couldn't find the minimum extremal frequencies in " + "error set" ) ; } List < Integer > indicesToRemove = new ArrayList < > ( ) ; Iterator < Integer > it = mExtremalIndices . iterator ( ) ; Integer current = it . next ( ) ; Integer next ; boolean positiveAxis = mGridErrors [ current ] > 0.0 ; while ( it . hasNext ( ) ) { next = it . next ( ) ; if ( ! ( positiveAxis ^ ( mGridErrors [ next ] > 0.0 ) ) ) { if ( Math . abs ( mGridErrors [ next ] ) <= Math . abs ( mGridErrors [ current ] ) ) { it . remove ( ) ; next = current ; } else { indicesToRemove . add ( current ) ; } } else { positiveAxis = ! positiveAxis ; } current = next ; } mExtremalIndices . removeAll ( indicesToRemove ) ; while ( mExtremalIndices . size ( ) > mSpecification . getExtremaCount ( ) ) { mExtremalIndices . remove ( mExtremalIndices . size ( ) - 1 ) ; } if ( mExtremalIndices . size ( ) > mSpecification . getExtremaCount ( ) ) { int lastIndex = mExtremalIndices . size ( ) - 1 ; if ( Math . abs ( mGridErrors [ mExtremalIndices . get ( 0 ) ] ) > Math . abs ( mGridErrors [ mExtremalIndices . get ( lastIndex ) ] ) ) { mExtremalIndices . remove ( lastIndex ) ; } else { mExtremalIndices . remove ( 0 ) ; } } if ( mExtremalIndices . size ( ) < mSpecification . getExtremaCount ( ) ) { throw new FilterDesignException ( "Couldn't find the minimum extremal frequencies in " + "error set" ) ; } }
identifies the indexes of the extremal error values using the alternation theorem
