Exemplo n.º 1
0
    public NGDItem(
        long term1count,
        long term2count,
        String term1,
        String term2,
        List<String[]> term1Array,
        List<String[]> term2Array,
        long combocount,
        boolean useAlias,
        long totalDocCount) {
      this.term1count = term1count;
      this.term2count = term2count;
      this.term1 = term1;
      this.term2 = term2;
      this.combocount = combocount;
      this.term1Array = term1Array;
      this.term2Array = term2Array;
      this.useAlias = useAlias;
      this.totalDocCount = totalDocCount;

      if (this.combocount == 0) {
        this.ngd = -1;
      } else {
        double term1_log = Math.log10(this.term1count);
        double term2_log = Math.log10(this.term2count);
        double combo_log = Math.log10(this.combocount);

        this.ngd =
            (Math.max(term1_log, term2_log) - combo_log)
                / (Math.log10(this.totalDocCount) - Math.min(term1_log, term2_log));
      }
    }
Exemplo n.º 2
0
 public static String readableFileSize(long size) {
   if (size <= 0) return "0";
   final String[] units = new String[] {"B", "KB", "MB", "GB", "TB"};
   int digitGroups = (int) (Math.log10(size) / Math.log10(1024));
   return new DecimalFormat("#,##0.#").format(size / Math.pow(1024, digitGroups))
       + " "
       + units[digitGroups];
 }
Exemplo n.º 3
0
 public boolean isPowerOfTwo(int n) {
   double res = Math.log10(n) / Math.log10(2);
   if (res == (int) res) {
     return true;
   } else {
     return false;
   }
 }
Exemplo n.º 4
0
  public static void computeAlleleFrequencyPriors(
      final int N, final double[] priors, final double theta) {

    double sum = 0.0;

    // for each i
    for (int i = 1; i <= N; i++) {
      final double value = theta / (double) i;
      priors[i] = Math.log10(value);
      sum += value;
    }

    // null frequency for AF=0 is (1 - sum(all other frequencies))
    priors[0] = Math.log10(1.0 - sum);
  }
Exemplo n.º 5
0
 private long normalizeMax(long l) {
   int exp = (int) Math.log10((double) l);
   long multiple = (long) Math.pow(10.0, exp);
   int i = (int) (l / multiple);
   l = (i + 1) * multiple;
   return l;
 }
    public void computeMetricScaleExtremes(
        int UTMZone, String hemisphere, GridElement ge, double size) {
      if (UTMZone != this.zone) return;
      if (size < 1 || size > this.maxResolution) return;

      UTMExtremes levelExtremes = this.extremes[(int) Math.log10(size) - 1];

      if (ge.type.equals(GridElement.TYPE_LINE_EASTING)
          || ge.type.equals(GridElement.TYPE_LINE_EAST)
          || ge.type.equals(GridElement.TYPE_LINE_WEST)) {
        levelExtremes.minX = ge.value < levelExtremes.minX ? ge.value : levelExtremes.minX;
        levelExtremes.maxX = ge.value > levelExtremes.maxX ? ge.value : levelExtremes.maxX;
      } else if (ge.type.equals(GridElement.TYPE_LINE_NORTHING)
          || ge.type.equals(GridElement.TYPE_LINE_SOUTH)
          || ge.type.equals(GridElement.TYPE_LINE_NORTH)) {
        if (hemisphere.equals(levelExtremes.minYHemisphere))
          levelExtremes.minY = ge.value < levelExtremes.minY ? ge.value : levelExtremes.minY;
        else if (hemisphere.equals(AVKey.SOUTH)) {
          levelExtremes.minY = ge.value;
          levelExtremes.minYHemisphere = hemisphere;
        }
        if (hemisphere.equals(levelExtremes.maxYHemisphere))
          levelExtremes.maxY = ge.value > levelExtremes.maxY ? ge.value : levelExtremes.maxY;
        else if (hemisphere.equals(AVKey.NORTH)) {
          levelExtremes.maxY = ge.value;
          levelExtremes.maxYHemisphere = hemisphere;
        }
      }
    }
    @Override
    public void reduce(Text key, Iterable<HMapStIW> values, Context context)
        throws IOException, InterruptedException {
      Iterator<HMapStIW> iter = values.iterator();
      HMapStIW map = new HMapStIW();

      while (iter.hasNext()) {
        map.plus(iter.next());
      }

      HMapStFW writeMap = new HMapStFW();

      double pmi = 0.0;
      for (MapKI.Entry<String> entry : map.entrySet()) {
        String k = entry.getKey();

        if (map.get(k) >= 10) {
          if (wordCounts.containsKey(key.toString()) && wordCounts.containsKey(k)) {
            int px = wordCounts.get(key.toString());
            int py = wordCounts.get(k);
            pmi = Math.log10(((double) (map.get(k)) / (px * py)) * wordCounts.get("numLines*"));
            writeMap.put(k, (float) pmi);
          }
        }
      }
      if (writeMap.size() > 0) {
        context.write(key, writeMap);
      }
    }
  /**
   * P(somatic | D) = P(somatic) * P(D | somatic) = P(somatic) * P(D | normals are ref) * P(D |
   * tumors are non-ref)
   *
   * <p>P(! somatic | D) = P(! somatic) * P(D | ! somatic) = P(! somatic) * * ( P(D | normals are
   * non-ref) * P(D | tumors are non-ref) [germline] + P(D | normals are ref) * P(D | tumors are
   * ref)) [no-variant at all]
   *
   * @param vc
   * @return
   */
  private double calcLog10pSomatic(final VariantContext vc) {
    // walk over tumors
    double log10pNonRefInTumors = log10pNonRefInSamples(vc, tumorSample);
    double log10pRefInTumors = log10pRefInSamples(vc, tumorSample);

    // walk over normals
    double log10pNonRefInNormals = log10pNonRefInSamples(vc, normalSample);
    double log10pRefInNormals = log10pRefInSamples(vc, normalSample);

    // priors
    double log10pSomaticPrior = QualityUtils.qualToErrorProbLog10(somaticPriorQ);
    double log10pNotSomaticPrior = Math.log10(1 - QualityUtils.qualToErrorProb(somaticPriorQ));

    double log10pNotSomaticGermline = log10pNonRefInNormals + log10pNonRefInTumors;
    double log10pNotSomaticNoVariant = log10pRefInNormals + log10pRefInTumors;

    double log10pNotSomatic =
        log10pNotSomaticPrior
            + MathUtils.log10sumLog10(
                new double[] {log10pNotSomaticGermline, log10pNotSomaticNoVariant});
    double log10pSomatic = log10pSomaticPrior + log10pNonRefInTumors + log10pRefInNormals;
    double lod = log10pSomatic - log10pNotSomatic;

    return Double.isInfinite(lod) ? -10000 : lod;
  }
 public void clear() {
   int numLevels = (int) Math.log10(this.maxResolution);
   this.extremes = new UTMExtremes[numLevels];
   for (int i = 0; i < numLevels; i++) {
     this.extremes[i] = new UTMExtremes();
     this.extremes[i].clear();
   }
 }
Exemplo n.º 10
0
  // 從DF算出IDF = log(N/(1+DF))
  public static HashMap<String, Double> IDF(HashMap<String, Integer> DF) {

    HashMap<String, Double> idf = new HashMap<String, Double>();
    for (String term : DF.keySet()) {
      idf.put(term, Math.log10((double) (1095 / (double) (1 + DF.get(term)))));
    }
    return idf;
  }
Exemplo n.º 11
0
      /**
       * The <code>deliverByte</code> method delivers bytes to receiver
       *
       * @param oneBitBeforeNow
       */
      private void deliverByte(long oneBitBeforeNow) {
        List<Transmission> it = getIntersection(oneBitBeforeNow - BYTE_SIZE);
        if (it != null) { // there is a transmission
          boolean one = false;
          double rssi = 0.0;
          double SNR = 0;
          assert it.size() > 0;
          for (Transmission t : it) {
            if (one) { // more than one transmission
              double I =
                  medium.arbitrator.computeReceivedPower(
                      t, Receiver.this, (int) clock.cyclesToMillis(clock.getCount()));
              // add interference to received power in linear scale
              rssi = 10 * Math.log10(Math.pow(10, rssi / 10) + Math.pow(10, I / 10));
              SNR = SNR - I;
            } else { // only one transmission - no interference -
              one = true;
              Pr =
                  medium.arbitrator.computeReceivedPower(
                      t, Receiver.this, (int) clock.cyclesToMillis(clock.getCount()));
              Pn = medium.arbitrator.getNoise((int) clock.cyclesToMillis(clock.getCount()));
              rssi = Pr;
              SNR = Pr - Pn;
            }
          }
          double snr = Math.pow(10D, (SNR / 10D));
          // ebno = snr / spectral efficiency = snr / log(1 + snr)
          double ebno = snr / Math.log(1 + snr);
          // BER vs Ebno in AWGN channel
          double x = Math.sqrt(2 * ebno);
          double x2 = Math.pow(x, 2);
          double BER = Math.exp(-x2 / 2) / (1.64D * x + Math.sqrt(0.76D * (x2) + 4D));
          setBER(BER);
          setRSSI(rssi);
          // merge transmissions into a single byte and send it to receiver
          // we return val in order to get rssi and corr value
          char val =
              medium.arbitrator.mergeTransmissions(
                  Receiver.this,
                  it,
                  oneBitBeforeNow - BYTE_SIZE,
                  (int) clock.cyclesToMillis(clock.getCount()));
          // store high byte for corrupted bytes
          int newval = (int) (val & 0xff00);
          newval |= (int) (0xff & nextByte(true, (byte) val));
          val = (char) newval;
          if (probeList != null) probeList.fireAfterReceive(Receiver.this, val);
          clock.insertEvent(this, cyclesPerByte);

        } else { // no transmissions intersect
          // all transmissions are over.
          locked = false;
          nextByte(false, (byte) 0);
          if (probeList != null) probeList.fireAfterReceiveEnd(Receiver.this);
          clock.insertEvent(this, leadCycles);
        }
      }
Exemplo n.º 12
0
  private double log10PLFromSamples(
      final VariantContext vc, final String sample, boolean calcRefP) {

    Genotype g = vc.getGenotype(sample);
    double log10pSample = -1000;
    if (!g.isNoCall()) {
      final double[] gLikelihoods = MathUtils.normalizeFromLog10(g.getLikelihoods().getAsVector());
      log10pSample = Math.log10(calcRefP ? gLikelihoods[0] : 1 - gLikelihoods[0]);
      log10pSample = Double.isInfinite(log10pSample) ? -10000 : log10pSample;
    }
    return log10pSample;
  }
  private boolean needToSplit(DrawContext dc, Sector sector) {
    Vec4[] corners = sector.computeCornerPoints(dc.getGlobe(), dc.getVerticalExaggeration());
    Vec4 centerPoint = sector.computeCenterPoint(dc.getGlobe(), dc.getVerticalExaggeration());

    View view = dc.getView();
    double d1 = view.getEyePoint().distanceTo3(corners[0]);
    double d2 = view.getEyePoint().distanceTo3(corners[1]);
    double d3 = view.getEyePoint().distanceTo3(corners[2]);
    double d4 = view.getEyePoint().distanceTo3(corners[3]);
    double d5 = view.getEyePoint().distanceTo3(centerPoint);

    double minDistance = d1;
    if (d2 < minDistance) minDistance = d2;
    if (d3 < minDistance) minDistance = d3;
    if (d4 < minDistance) minDistance = d4;
    if (d5 < minDistance) minDistance = d5;

    double cellSize =
        (Math.PI * sector.getDeltaLatRadians() * dc.getGlobe().getRadius()) / 20; // TODO

    return !(Math.log10(cellSize) <= (Math.log10(minDistance) - this.splitScale));
  }
  public double getScore(String text) {
    double score = 0.00f;

    for (int i = 0; i < text.length(); i += 4) {

      if (i + 4 > text.length()) break;

      String next = text.substring(i, i + 4);

      if (map.get(next) != null) {
        double frequency = (double) map.get(next);
        score += Math.log10(frequency);
      }
    }
    return score;
  }
  public float getScore(String text) {
    float score = 0.00f;
    for (int i = 0; i < text.length(); i++) {

      if (i + 4 >= text.length()) break;

      String next = text.substring(i, i + 4);

      if (map.get(next) != null) {
        float frequency = (float) map.get(next);
        float total = (float) map.size();

        score += Math.log10(frequency);
      }
    }
    return score;
  }
Exemplo n.º 16
0
 /**
  * The <code>isChannelClear</code> method determines wether the channel is clear or not
  *
  * @return true if channel is clear and false otherwise
  */
 public final boolean isChannelClear(int RSSI_reg, int MDMCTRL0_reg) {
   if (activated && locked) {
     // this is the only shortcut: receiver is on and locked to a transmission
     return false;
   } else {
     // the receiver could be off or it is not locked to a transmission
     // the latter could happen also if the receiver was just turned on and the TX has been
     // started before!
     long time = clock.getCount();
     long bit = getBitNum(time) - BIT_DELAY; // there is a one bit delay
     waitForNeighbors(time - cyclesPerByte);
     List<Transmission> it = getIntersection(bit - BYTE_SIZE);
     if (it != null) { // if there is a transmission
       // There are 3 modes (ED, 802.15.4 compliant detection, both)
       int cca_mode = (MDMCTRL0_reg & 0x00c0) >>> 6;
       // cca modes 1 and 3 compare threshold with rssi to determine CCA
       if (cca_mode == 1 || cca_mode == 3) {
         boolean one = false;
         double rssi = 0.0;
         assert it.size() > 0;
         for (Transmission t : it) {
           if (one) { // more than one transmission
             double I =
                 medium.arbitrator.computeReceivedPower(
                     t, Receiver.this, (int) clock.cyclesToMillis(clock.getCount()));
             // add interference to received power in linear scale
             rssi = 10 * Math.log10(Math.pow(10, rssi / 10) + Math.pow(10, I / 10));
           } else { // only one transmission - no interference -
             one = true;
             Pr =
                 medium.arbitrator.computeReceivedPower(
                     t, Receiver.this, (int) clock.cyclesToMillis(clock.getCount()));
             Pn = medium.arbitrator.getNoise((int) clock.cyclesToMillis(clock.getCount()));
             rssi = Pr;
           }
         }
         int cca_hyst = (MDMCTRL0_reg & 0x0700) >>> 8;
         int cca_thr = (RSSI_reg & 0xff00) >>> 8;
         if (cca_thr > 127) cca_thr -= 256;
         int rssi_val = (int) rssi + 45;
         return rssi_val < cca_thr - cca_hyst;
       } else return false; // other modes false since we have transmissions
     } else return true; // no transmissions: CCA true in all cases
   }
 }
Exemplo n.º 17
0
  public void start() {

    Connection connection = null; // manages connection
    Connection connection2 = null;
    Statement statement = null; // query statement
    Statement statement2 = null;
    wm = new double[20][Data.windows_size];
    String QueryKinasesName = "%" + Data.kinease + "%";
    // data.code = data.codenames[3];
    String QueryCodeName = Data.code;
    int windows_size = Data.windows_size;

    // int windows_size = 9;

    int shift = windows_size / 2;

    try {
      Class.forName(JDBC_DRIVER); // load database driver class
      for (windows_size = Data.windows_size; windows_size <= Data.windows_size; windows_size += 2) {
        shift = windows_size / 2;
        // establish connection to database
        connection = DriverManager.getConnection(DATABASE_URL, "", "");
        connection2 = DriverManager.getConnection(DATABASE_URL, "", "");
        // create Statement for querying database
        statement = connection.createStatement();
        statement2 = connection2.createStatement();
        String ACC = null;
        String SEQUENCE = null;
        String KINASES = null;
        String LIKE = "LIKE";
        // int POSITION = 0;
        // int index = 0;
        String temp = null;
        // int numtemp = 0;
        // int LENGTH = (int) 0;
        // int count = 0;
        double[] totalAAcount = new double[windows_size];

        double weightmatrix[][] = new double[windows_size][128]; // windowssize;aa;

        String statementquery1 =
            "SELECT Mid(sequence,(position-"
                + shift
                + "),"
                + windows_size
                + ") AS TARGET, index,code,length,position,sequence FROM Dataset_041106 WHERE ((position-"
                + shift
                + ")>1) AND ((position +"
                + shift
                + ")<length) AND kinases "
                + LIKE
                + " '"
                + QueryKinasesName
                + "' AND (code LIKE '"
                + QueryCodeName
                + "')";
        System.out.println("#" + statementquery1);
        /// fout.println("#"+statementquery1);
        ResultSet resultSet1 = statement.executeQuery(statementquery1);
        int seqsize = 0;
        while ((resultSet1.next())) {
          String posseq = resultSet1.getString("TARGET");
          seqsize = posseq.length();
          if (posseq.charAt(0) != 'X' && posseq.charAt(seqsize - 1) != 'X') { // �h����t

            for (int i = 0; i < seqsize; i++) {

              weightmatrix[i][posseq.charAt(i)]++;
            }
            // possequence.addElement(posseq);
          }
        } // end while
        char[] aaMap = {
          'A', 'R', 'N', 'D', 'C', 'Q', 'E', 'G', 'H', 'I', 'L', 'K', 'M', 'F', 'P', 'S', 'T', 'W',
          'Y', 'V', 'X'
        };
        double[] expmatrix = {
          0.0701313443873091,
          0.0582393695201718,
          0.0359362961736045,
          0.0520743144385134,
          0.0172010453343506,
          0.0498574962335004,
          0.0796465136978452,
          0.0624720283551962,
          0.0241405228512130,
          0.0416989778376737,
          0.0934441156861220,
          0.0632334844952389,
          0.0213293464067050,
          0.0324554733241482,
          0.0651181982370858,
          0.0881672518230193,
          0.0524630941595624,
          0.0101093184162382,
          0.0244701177088640,
          0.0578116909136386
        };
        // double[] aaMapfreq = new double[windows_size];
        double freq = 0;
        for (int j = 0; j < weightmatrix.length; j++) {
          for (int i = 0; i < aaMap.length - 1; i++) {
            totalAAcount[j] += weightmatrix[j][aaMap[i]];
          }
        }

        for (int i = 0; i < aaMap.length - 1; i++) {
          // profilefout.print(aaMap[i]);
          for (int j = 0; j < windows_size; j++) {

            freq = ((weightmatrix[j][aaMap[i]]) / (totalAAcount[j])) + 1;

            wm[i][j] = Math.log10((freq / expmatrix[i])) / Math.log10(2.0);

            //  profilefout.print(","+aaMapfreq[i]);

          }
          // profilefout.println();
        }

        // fout.close();
        // profilefout.close();

        resultSet1.close();
        connection.close();
      }

    } // end try
    catch (ClassNotFoundException classNotFound) {
      classNotFound.printStackTrace();
      System.exit(1);
    } catch (NullPointerException nullpointerException) {
      nullpointerException.printStackTrace();
      System.exit(1);

    } catch (SQLException ex) {
      /** @todo Handle this exception */
      /*        } catch (IOException ex) {
       */
      /** @todo Handle this exception */
    } catch (NoClassDefFoundError ex) {

    } finally { // ensure statement and connection are closed properly
      try {
        statement.close();
        statement2.close();

        connection.close();

        connection2.close();
      } catch (Exception exception) { // end try
        exception.printStackTrace();
        System.exit(1);
      } // end catch
    } // end finally
  } // end main
Exemplo n.º 18
0
  public void start2() {

    wm = new double[20][Data.windows_size];
    String QueryKinasesName = "%" + Data.kinease + "%";
    // data.code = data.codenames[3];
    String QueryCodeName = Data.code;
    int windows_size = Data.windows_size;

    // int windows_size = 9;

    int shift = windows_size / 2;

    try {

      {
        shift = windows_size / 2;
        // establish connection to database

        String ACC = null;
        String SEQUENCE = null;
        String KINASES = null;
        String LIKE = "LIKE";
        // int POSITION = 0;
        // int index = 0;
        String temp = null;
        // int numtemp = 0;
        // int LENGTH = (int) 0;
        // int count = 0;
        double[] totalAAcount = new double[windows_size];

        double weightmatrix[][] = new double[windows_size][128]; // windowssize;aa;

        /// fout.println("#"+statementquery1);

        int seqsize = 0;

        for (int i = 0; i < pwmseq.size(); i++) {
          String posseq = pwmseq.elementAt(i).toString();
          seqsize = posseq.length();
          {
            for (int j = 0; j < seqsize; j++) {

              weightmatrix[j][posseq.charAt(j)]++;
            }
            // possequence.addElement(posseq);
          }
        } // end while
        char[] aaMap = {
          'A', 'R', 'N', 'D', 'C', 'Q', 'E', 'G', 'H', 'I', 'L', 'K', 'M', 'F', 'P', 'S', 'T', 'W',
          'Y', 'V', 'X'
        };
        double[] expmatrix = {
          0.0701313443873091,
          0.0582393695201718,
          0.0359362961736045,
          0.0520743144385134,
          0.0172010453343506,
          0.0498574962335004,
          0.0796465136978452,
          0.0624720283551962,
          0.0241405228512130,
          0.0416989778376737,
          0.0934441156861220,
          0.0632334844952389,
          0.0213293464067050,
          0.0324554733241482,
          0.0651181982370858,
          0.0881672518230193,
          0.0524630941595624,
          0.0101093184162382,
          0.0244701177088640,
          0.0578116909136386
        };
        // double[] aaMapfreq = new double[windows_size];
        double freq = 0;
        for (int j = 0; j < weightmatrix.length; j++) {
          for (int i = 0; i < aaMap.length - 1; i++) {
            totalAAcount[j] += weightmatrix[j][aaMap[i]];
          }
        }

        for (int i = 0; i < aaMap.length - 1; i++) {
          // profilefout.print(aaMap[i]);
          for (int j = 0; j < windows_size; j++) {

            freq = ((weightmatrix[j][aaMap[i]] + 0.05) / (totalAAcount[j] + 1));

            wm[i][j] = Math.log10((freq / expmatrix[i])) / Math.log10(2.0);

            //  profilefout.print(","+aaMapfreq[i]);

          }
          // profilefout.println();
        }

        // fout.close();
        // profilefout.close();

      }

    } // end try
    catch (NullPointerException nullpointerException) {
      nullpointerException.printStackTrace();
      System.exit(1);

    } catch (NoClassDefFoundError ex) {

    } finally { // ensure statement and connection are closed properly
      try {

      } catch (Exception exception) { // end try
        exception.printStackTrace();
        System.exit(1);
      } // end catch
    } // end finally
  } // end main
Exemplo n.º 19
0
 // To add/remove functions change evaluateOperator() and registration
 public double evaluateFunction(String fncnam, ArgParser fncargs) throws ArithmeticException {
   switch (Character.toLowerCase(fncnam.charAt(0))) {
     case 'a':
       {
         if (fncnam.equalsIgnoreCase("abs")) {
           return Math.abs(fncargs.next());
         }
         if (fncnam.equalsIgnoreCase("acos")) {
           return Math.acos(fncargs.next());
         }
         if (fncnam.equalsIgnoreCase("asin")) {
           return Math.asin(fncargs.next());
         }
         if (fncnam.equalsIgnoreCase("atan")) {
           return Math.atan(fncargs.next());
         }
       }
       break;
     case 'c':
       {
         if (fncnam.equalsIgnoreCase("cbrt")) {
           return Math.cbrt(fncargs.next());
         }
         if (fncnam.equalsIgnoreCase("ceil")) {
           return Math.ceil(fncargs.next());
         }
         if (fncnam.equalsIgnoreCase("cos")) {
           return Math.cos(fncargs.next());
         }
         if (fncnam.equalsIgnoreCase("cosh")) {
           return Math.cosh(fncargs.next());
         }
       }
       break;
     case 'e':
       {
         if (fncnam.equalsIgnoreCase("exp")) {
           return Math.exp(fncargs.next());
         }
         if (fncnam.equalsIgnoreCase("expm1")) {
           return Math.expm1(fncargs.next());
         }
       }
       break;
     case 'f':
       {
         if (fncnam.equalsIgnoreCase("floor")) {
           return Math.floor(fncargs.next());
         }
       }
       break;
     case 'g':
       {
         //              if(fncnam.equalsIgnoreCase("getExponent"   )) { return
         // Math.getExponent(fncargs.next());                } needs Java 6
       }
       break;
     case 'l':
       {
         if (fncnam.equalsIgnoreCase("log")) {
           return Math.log(fncargs.next());
         }
         if (fncnam.equalsIgnoreCase("log10")) {
           return Math.log10(fncargs.next());
         }
         if (fncnam.equalsIgnoreCase("log1p")) {
           return Math.log1p(fncargs.next());
         }
       }
       break;
     case 'm':
       {
         if (fncnam.equalsIgnoreCase("max")) {
           return Math.max(fncargs.next(), fncargs.next());
         }
         if (fncnam.equalsIgnoreCase("min")) {
           return Math.min(fncargs.next(), fncargs.next());
         }
       }
       break;
     case 'n':
       {
         //              if(fncnam.equalsIgnoreCase("nextUp"        )) { return Math.nextUp
         // (fncargs.next());                } needs Java 6
       }
       break;
     case 'r':
       {
         if (fncnam.equalsIgnoreCase("random")) {
           return Math.random();
         } // impure
         if (fncnam.equalsIgnoreCase("round")) {
           return Math.round(fncargs.next());
         }
         if (fncnam.equalsIgnoreCase("roundHE")) {
           return Math.rint(fncargs.next());
         } // round half-even
       }
       break;
     case 's':
       {
         if (fncnam.equalsIgnoreCase("signum")) {
           return Math.signum(fncargs.next());
         }
         if (fncnam.equalsIgnoreCase("sin")) {
           return Math.sin(fncargs.next());
         }
         if (fncnam.equalsIgnoreCase("sinh")) {
           return Math.sinh(fncargs.next());
         }
         if (fncnam.equalsIgnoreCase("sqrt")) {
           return Math.sqrt(fncargs.next());
         }
       }
       break;
     case 't':
       {
         if (fncnam.equalsIgnoreCase("tan")) {
           return Math.tan(fncargs.next());
         }
         if (fncnam.equalsIgnoreCase("tanh")) {
           return Math.tanh(fncargs.next());
         }
         if (fncnam.equalsIgnoreCase("toDegrees")) {
           return Math.toDegrees(fncargs.next());
         }
         if (fncnam.equalsIgnoreCase("toRadians")) {
           return Math.toRadians(fncargs.next());
         }
       }
       break;
     case 'u':
       {
         if (fncnam.equalsIgnoreCase("ulp")) {
           return Math.ulp(fncargs.next());
         }
       }
       break;
       // no default
   }
   throw new UnsupportedOperationException(
       "MathEval internal function setup is incorrect - internal function \""
           + fncnam
           + "\" not handled");
 }