Example usage for java.lang Float NEGATIVE_INFINITY

List of usage examples for java.lang Float NEGATIVE_INFINITY

Introduction

In this page you can find the example usage for java.lang Float NEGATIVE_INFINITY.

Prototype

float NEGATIVE_INFINITY

To view the source code for java.lang Float NEGATIVE_INFINITY.

Click Source Link

Document

A constant holding the negative infinity of type float .

Usage

From source file:gdsc.smlm.fitting.Gaussian2DFitter.java

/**
 * Sets the constraints for the fitted parameters. This functions set the lower bounds of the background and
 * signal to zero.//from www.jav  a 2s. c  o  m
 * 
 * @param maxx
 *            The x range of the data
 * @param maxy
 *            The y range of the data
 * @param npeaks
 *            The number of peaks
 * @param params
 *            The estimated parameters
 * @param y
 *            The data
 * @param ySize
 *            The size of the data
 * @param paramsPerPeak
 *            The number of parameters per peak
 */
private void setConstraints(final int maxx, final int maxy, final int npeaks, final double[] params,
        final double[] y, final int ySize, final int paramsPerPeak) {
    // Create appropriate bounds for the parameters
    double[] lower = new double[params.length];
    double[] upper = new double[lower.length];
    Arrays.fill(lower, Float.NEGATIVE_INFINITY);
    Arrays.fill(upper, Float.POSITIVE_INFINITY);
    lower[Gaussian2DFunction.BACKGROUND] = 0;
    for (int i = 0, j = 0; i < npeaks; i++, j += paramsPerPeak) {
        lower[j + Gaussian2DFunction.SIGNAL] = 0;
    }
    solver.setConstraints(lower, upper);
}

From source file:au.org.ala.delta.intkey.directives.invocation.UseDirectiveInvocation.java

private Attribute promptForCharacterValue(au.org.ala.delta.model.Character ch,
        au.org.ala.delta.model.Character dependentChar, Set<Integer> applicableStates,
        DirectivePopulator populator, Specimen specimen, IntkeyContext context) {
    SimpleAttributeData impl = new SimpleAttributeData(false, false);

    if (ch instanceof MultiStateCharacter) {
        Set<Integer> stateValues;
        if (dependentChar != null) {
            // We are setting a value for a controlling character. Ensure
            // that the states that make the dependent character applicable
            // are pre-selected.
            stateValues = populator.promptForMultiStateValue((MultiStateCharacter) ch, applicableStates,
                    dependentChar);//  w  w w .  jav  a  2 s.  c  om
        } else {
            // Get the current value of the character as set in the
            // specimen. If no
            // value is set for the character, an attribute with
            // unknown = true is returned.
            MultiStateAttribute currentAttribute = (MultiStateAttribute) specimen.getAttributeForCharacter(ch);
            stateValues = populator.promptForMultiStateValue((MultiStateCharacter) ch,
                    currentAttribute.isUnknown() ? null : currentAttribute.getPresentStates(), null);
        }
        if (stateValues != null && stateValues.isEmpty() && dependentChar == null) {
            // User hit OK but did not select any states. Delete any value
            // set
            // for the character.
            if (specimen.hasValueFor(ch)) {
                deleteCharacter(ch, context);
            }
            return null;
        } else if (stateValues != null && stateValues.size() > 0) {
            impl.setPresentStateOrIntegerValues(stateValues);
        } else {
            return null;
        }
    } else if (ch instanceof IntegerCharacter) {
        // Get the current value of the character as set in the specimen. If
        // no
        // value is set for the character, an attribute with
        // unknown = true is returned.
        IntegerAttribute currentAttribute = (IntegerAttribute) specimen.getAttributeForCharacter(ch);

        Set<Integer> intValue = populator.promptForIntegerValue((IntegerCharacter) ch,
                currentAttribute.isUnknown() ? null : currentAttribute.getPresentValues());

        if (intValue != null && intValue.isEmpty()) {
            // User hit OK but did not input any values. Delete any value
            // set
            // for the character
            if (specimen.hasValueFor(ch)) {
                deleteCharacter(ch, context);
            }
            return null;
        } else if (intValue != null && intValue.size() > 0) {
            impl.setPresentStateOrIntegerValues(intValue);
        } else {
            return null;
        }
    } else if (ch instanceof RealCharacter) {
        // Get the current value of the character as set in the specimen. If
        // no
        // value is set for the character, an attribute with
        // unknown = true is returned.
        RealAttribute currentAttribute = (RealAttribute) specimen.getAttributeForCharacter(ch);

        FloatRange floatRange = populator.promptForRealValue((RealCharacter) ch,
                currentAttribute.isUnknown() ? null : currentAttribute.getPresentRange());

        if (floatRange != null) {
            // Float range with minimum and maximum value as negative
            // infinity indicates that the user hit OK without inputting
            // values.
            if (floatRange.getMaximumFloat() == Float.NEGATIVE_INFINITY
                    && floatRange.getMinimumFloat() == Float.NEGATIVE_INFINITY) {
                // User hit OK but did not input any values. Delete any
                // value set
                // for the character
                if (specimen.hasValueFor(ch)) {
                    deleteCharacter(ch, context);
                }
                return null;
            }
            impl.setRealRange(floatRange);
        } else {
            return null;
        }
    } else if (ch instanceof TextCharacter) {
        // Get the current value of the character as set in the specimen. If
        // no
        // value is set for the character, an attribute with
        // unknown = true is returned.
        TextAttribute currentAttribute = (TextAttribute) specimen.getAttributeForCharacter(ch);

        List<String> stringList = populator.promptForTextValue((TextCharacter) ch,
                currentAttribute.isUnknown() ? null
                        : Arrays.asList(currentAttribute.getValueAsString().split("/")));

        if (stringList != null && stringList.isEmpty()) {
            // User hit OK but did not input any values. Delete any
            // value set
            // for the character
            if (specimen.hasValueFor(ch)) {
                deleteCharacter(ch, context);
            }
            return null;
        } else if (stringList != null && stringList.size() > 0) {
            impl.setValueFromString(StringUtils.join(stringList, '/'));
        } else {
            return null;
        }
    } else {
        throw new IllegalArgumentException("Unrecognized character type");
    }

    Attribute attr = AttributeFactory.newAttribute(ch, impl);
    attr.setSpecimenAttribute(true);

    return attr;
}

From source file:org.jboss.bqt.client.xml.XMLQueryVisitationStrategy.java

/**
 * Consume an XML message and update the specified Float instance.
 * <br>/*from   ww w.  ja v  a 2s  . c o m*/
 * @param object the instance that is to be updated with the XML message data.
 * @param cellElement the XML element that contains the data
 * @return the updated instance.
 * @exception JDOMException if there is an error consuming the message.
 */
private Object consumeMsg(Float object, Element cellElement) throws JDOMException {

    // -----------------------
    // Process the element ...
    // -----------------------
    String strElement = cellElement.getTextTrim();
    Float result;

    if (strElement.equals("NaN")) { //$NON-NLS-1$
        result = new Float(Float.NaN);
    } else if (strElement.equals("-Infinity")) { //$NON-NLS-1$
        result = new Float(Float.NEGATIVE_INFINITY);
    } else if (strElement.equals("Infinity")) { //$NON-NLS-1$
        result = new Float(Float.POSITIVE_INFINITY);
    } else {
        try {
            result = Float.valueOf(strElement);
        } catch (NumberFormatException e) {
            throw new JDOMException("Unable to parse the value for " + cellElement.getName() + //$NON-NLS-1$
                    " element: " + strElement, e); //$NON-NLS-1$
        }
    }
    return result;
}

From source file:net.sf.maltcms.chromaui.charts.FastHeatMapPlot.java

/**
 * Calculates the X data range.// w w w. java 2s.c o  m
 *
 * @param data the data (<code>null</code> permitted).
 *
 * @return The range.
 */
private Range calculateXDataRange(float[][] data) {

    Range result = null;

    if (data != null) {
        float lowest = Float.POSITIVE_INFINITY;
        float highest = Float.NEGATIVE_INFINITY;
        for (int i = 0; i < data[0].length; i++) {
            float v = data[0][i];
            if (v < lowest) {
                lowest = v;
            }
            if (v > highest) {
                highest = v;
            }
        }
        if (lowest <= highest) {
            result = new Range(lowest, highest);
        }
    }

    return result;

}

From source file:net.sf.maltcms.chromaui.charts.FastHeatMapPlot.java

/**
 * Calculates the Y data range./*  w ww .j a  va2 s.  c  o m*/
 *
 * @param data the data (<code>null</code> permitted).
 *
 * @return The range.
 */
private Range calculateYDataRange(float[][] data) {

    Range result = null;
    if (data != null) {
        float lowest = Float.POSITIVE_INFINITY;
        float highest = Float.NEGATIVE_INFINITY;
        for (int i = 0; i < data[0].length; i++) {
            float v = data[1][i];
            if (v < lowest) {
                lowest = v;
            }
            if (v > highest) {
                highest = v;
            }
        }
        if (lowest <= highest) {
            result = new Range(lowest, highest);
        }
    }
    return result;

}

From source file:jp.furplag.util.commons.NumberUtilsTest.java

/**
 * {@link jp.furplag.util.commons.NumberUtils#isInfinite(java.lang.Object)}.
 *//*from w w w.jav a2  s.  c om*/
@Test
public void testIsInfiniteObject() {
    assertEquals("null", false, isInfinite(null));
    assertEquals("empty", false, isInfinite(""));
    assertEquals("invalidString", false, isInfinite("not a number"));
    assertEquals("notParsable", false, isInfinite(new int[] { 1, 2, 3 }));
    assertEquals("notParsable", false,
            isInfinite(new float[] { Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY }));
    assertEquals("NaN", false, isInfinite(Double.NaN));
    assertEquals("Infinity: Float", true, isInfinite(Float.POSITIVE_INFINITY));
    assertEquals("Infinity: Double", true, isInfinite(Double.POSITIVE_INFINITY));
    assertEquals("Infinity: String", true, isInfinite("Infinity"));
    assertEquals("-Infinity: Float", true, isInfinite(Float.NEGATIVE_INFINITY));
    assertEquals("-Infinity: Double", true, isInfinite(Double.NEGATIVE_INFINITY));
    assertEquals("-Infinity: String", true, isInfinite("-Infinity"));
    assertEquals("Infinity: BIgDecimal", false, isInfinite(INFINITY_DOUBLE));

    assertEquals(true, isInfinite(INFINITY_DOUBLE.doubleValue()));
}

From source file:jp.furplag.util.commons.NumberUtilsTest.java

/**
 * {@link jp.furplag.util.commons.NumberUtils#isInfinite(java.lang.Object, int)}.
 *///from w  ww.j  av a2  s  . c o  m
@Test
public void testIsInfiniteObjectInt() {
    assertEquals("null", false, isInfinite(null, -1));
    assertEquals("null", false, isInfinite(null, 0));
    assertEquals("null", false, isInfinite(null, 1));
    assertEquals("empty", false, isInfinite("", -1));
    assertEquals("empty", false, isInfinite("", 0));
    assertEquals("empty", false, isInfinite("", 1));
    assertEquals("invalidString", false, isInfinite("not a number", -1));
    assertEquals("invalidString", false, isInfinite("not a number", 0));
    assertEquals("invalidString", false, isInfinite("not a number", 1));
    assertEquals("notParsable", false, isInfinite(new int[] { 1, 2, 3 }, -1));
    assertEquals("notParsable", false, isInfinite(new int[] { 1, 2, 3 }, 0));
    assertEquals("notParsable", false, isInfinite(new int[] { 1, 2, 3 }, 1));
    assertEquals("notParsable", false,
            isInfinite(new float[] { Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY }, -1));
    assertEquals("notParsable", false,
            isInfinite(new float[] { Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY }, 0));
    assertEquals("notParsable", false,
            isInfinite(new float[] { Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY }, 1));
    assertEquals("NaN", false, isInfinite(Double.NaN, -1));
    assertEquals("NaN", false, isInfinite(Double.NaN, 0));
    assertEquals("NaN", false, isInfinite(Double.NaN, 1));

    assertEquals("Infinity: Float", false, isInfinite(Float.POSITIVE_INFINITY, -1));
    assertEquals("Infinity: Float", true, isInfinite(Float.POSITIVE_INFINITY, 0));
    assertEquals("Infinity: Float", true, isInfinite(Float.POSITIVE_INFINITY, 1));
    assertEquals("Infinity: Double", false, isInfinite(Double.POSITIVE_INFINITY, -1));
    assertEquals("Infinity: Double", true, isInfinite(Double.POSITIVE_INFINITY, 0));
    assertEquals("Infinity: Double", true, isInfinite(Double.POSITIVE_INFINITY, 1));
    assertEquals("Infinity: String", false, isInfinite("Infinity", -1));
    assertEquals("Infinity: String", true, isInfinite("Infinity", 0));
    assertEquals("Infinity: String", true, isInfinite("Infinity", 1));

    assertEquals("-Infinity: Float", true, isInfinite(Float.NEGATIVE_INFINITY, -1));
    assertEquals("-Infinity: Float", true, isInfinite(Float.NEGATIVE_INFINITY, 0));
    assertEquals("-Infinity: Float", false, isInfinite(Float.NEGATIVE_INFINITY, 1));
    assertEquals("-Infinity: Double", true, isInfinite(Double.NEGATIVE_INFINITY, -1));
    assertEquals("-Infinity: Double", true, isInfinite(Double.NEGATIVE_INFINITY, 0));
    assertEquals("-Infinity: Double", false, isInfinite(Double.NEGATIVE_INFINITY, 1));
    assertEquals("-Infinity: String", true, isInfinite("-Infinity", -1));
    assertEquals("-Infinity: String", true, isInfinite("-Infinity", 0));
    assertEquals("-Infinity: String", false, isInfinite("-Infinity", 1));
}

From source file:gdsc.core.ij.AlignImagesFFT.java

private int[] getPeak(FloatProcessor subCorrMat, int minX, int minY, int w, int h) {
    int width = subCorrMat.getWidth();
    float max = Float.NEGATIVE_INFINITY;
    int maxi = 0;
    float[] data = (float[]) subCorrMat.getPixels();
    for (int y = minY; y < minY + h; y++)
        for (int x = 0, i = y * width + minX; x < w; x++, i++) {
            if (max < data[i]) {
                max = data[i];/*  w  w  w .  j  ava 2 s .  com*/
                maxi = i;
            }
        }
    return new int[] { maxi % width, maxi / width };
}

From source file:edu.harvard.iq.dataverse.dataaccess.TabularSubsetGenerator.java

public Object[] subsetObjectVector(File tabfile, int column, int varcount, int casecount, int columntype,
        boolean compatmode) throws IOException {

    Object[] retVector = null;/*from w ww  .  ja  va2s .c o m*/

    boolean isString = false;
    boolean isDouble = false;
    boolean isLong = false;
    boolean isFloat = false;

    //Locale loc = new Locale("en", "US");

    if (columntype == COLUMN_TYPE_STRING) {
        isString = true;
        retVector = new String[casecount];
    } else if (columntype == COLUMN_TYPE_DOUBLE) {
        isDouble = true;
        retVector = new Double[casecount];
    } else if (columntype == COLUMN_TYPE_LONG) {
        isLong = true;
        retVector = new Long[casecount];
    } else if (columntype == COLUMN_TYPE_FLOAT) {
        isFloat = true;
        retVector = new Float[casecount];
    } else {
        throw new IOException("Unsupported column type: " + columntype);
    }

    File rotatedImageFile = getRotatedImage(tabfile, varcount, casecount);
    long[] columnEndOffsets = extractColumnOffsets(rotatedImageFile, varcount, casecount);
    long columnOffset = 0;
    long columnLength = 0;

    if (column > 0) {
        columnOffset = columnEndOffsets[column - 1];
        columnLength = columnEndOffsets[column] - columnEndOffsets[column - 1];
    } else {
        columnOffset = varcount * 8;
        columnLength = columnEndOffsets[0] - varcount * 8;
    }

    FileChannel fc = (FileChannel.open(Paths.get(rotatedImageFile.getAbsolutePath()), StandardOpenOption.READ));
    fc.position(columnOffset);
    int MAX_COLUMN_BUFFER = 8192;

    ByteBuffer in = ByteBuffer.allocate(MAX_COLUMN_BUFFER);

    if (columnLength < MAX_COLUMN_BUFFER) {
        in.limit((int) (columnLength));
    }

    long bytesRead = 0;
    long bytesReadTotal = 0;
    int caseindex = 0;
    int byteoffset = 0;
    byte[] leftover = null;

    while (bytesReadTotal < columnLength) {
        bytesRead = fc.read(in);
        byte[] columnBytes = in.array();
        int bytecount = 0;

        while (bytecount < bytesRead) {
            if (columnBytes[bytecount] == '\n') {
                /*
                String token = new String(columnBytes, byteoffset, bytecount-byteoffset, "UTF8");
                        
                if (leftover != null) {
                String leftoverString = new String (leftover, "UTF8");
                token = leftoverString + token;
                leftover = null;
                }
                */
                /* 
                 * Note that the way I was doing it at first - above - 
                 * was not quite the correct way - because I was creating UTF8
                 * strings from the leftover bytes, and the bytes in the 
                 * current buffer *separately*; which means, if a multi-byte
                 * UTF8 character got split in the middle between one buffer
                 * and the next, both chunks of it would become junk 
                 * characters, on each side!
                 * The correct way of doing it, of course, is to create a
                 * merged byte buffer, and then turn it into a UTF8 string. 
                 *      -- L.A. 4.0
                 */
                String token = null;

                if (leftover == null) {
                    token = new String(columnBytes, byteoffset, bytecount - byteoffset, "UTF8");
                } else {
                    byte[] merged = new byte[leftover.length + bytecount - byteoffset];

                    System.arraycopy(leftover, 0, merged, 0, leftover.length);
                    System.arraycopy(columnBytes, byteoffset, merged, leftover.length, bytecount - byteoffset);
                    token = new String(merged, "UTF8");
                    leftover = null;
                    merged = null;
                }

                if (isString) {
                    if ("".equals(token)) {
                        // An empty string is a string missing value!
                        // An empty string in quotes is an empty string!
                        retVector[caseindex] = null;
                    } else {
                        // Strip the outer quotes:
                        token = token.replaceFirst("^\\\"", "");
                        token = token.replaceFirst("\\\"$", "");

                        // We need to restore the special characters that 
                        // are stored in tab files escaped - quotes, new lines 
                        // and tabs. Before we do that however, we need to 
                        // take care of any escaped backslashes stored in 
                        // the tab file. I.e., "foo\t" should be transformed 
                        // to "foo<TAB>"; but "foo\\t" should be transformed 
                        // to "foo\t". This way new lines and tabs that were
                        // already escaped in the original data are not 
                        // going to be transformed to unescaped tab and 
                        // new line characters!

                        String[] splitTokens = token.split(Matcher.quoteReplacement("\\\\"), -2);

                        // (note that it's important to use the 2-argument version 
                        // of String.split(), and set the limit argument to a
                        // negative value; otherwise any trailing backslashes 
                        // are lost.)

                        for (int i = 0; i < splitTokens.length; i++) {
                            splitTokens[i] = splitTokens[i].replaceAll(Matcher.quoteReplacement("\\\""), "\"");
                            splitTokens[i] = splitTokens[i].replaceAll(Matcher.quoteReplacement("\\t"), "\t");
                            splitTokens[i] = splitTokens[i].replaceAll(Matcher.quoteReplacement("\\n"), "\n");
                            splitTokens[i] = splitTokens[i].replaceAll(Matcher.quoteReplacement("\\r"), "\r");
                        }
                        // TODO: 
                        // Make (some of?) the above optional; for ex., we 
                        // do need to restore the newlines when calculating UNFs;
                        // But if we are subsetting these vectors in order to 
                        // create a new tab-delimited file, they will 
                        // actually break things! -- L.A. Jul. 28 2014

                        token = StringUtils.join(splitTokens, '\\');

                        // "compatibility mode" - a hack, to be able to produce
                        // unfs identical to those produced by the "early" 
                        // unf5 jar; will be removed in production 4.0. 
                        // -- L.A. (TODO: ...)
                        if (compatmode && !"".equals(token)) {
                            if (token.length() > 128) {
                                if ("".equals(token.trim())) {
                                    // don't ask... 
                                    token = token.substring(0, 129);
                                } else {
                                    token = token.substring(0, 128);
                                    //token = String.format(loc, "%.128s", token);
                                    token = token.trim();
                                    //dbgLog.info("formatted and trimmed: "+token);
                                }
                            } else {
                                if ("".equals(token.trim())) {
                                    // again, don't ask; 
                                    // - this replicates some bugginness 
                                    // that happens inside unf5;
                                    token = "null";
                                } else {
                                    token = token.trim();
                                }
                            }
                        }

                        retVector[caseindex] = token;
                    }
                } else if (isDouble) {
                    try {
                        // TODO: verify that NaN and +-Inf are 
                        // handled correctly here! -- L.A.
                        // Verified: new Double("nan") works correctly, 
                        // resulting in Double.NaN;
                        // Double("[+-]Inf") doesn't work however; 
                        // (the constructor appears to be expecting it
                        // to be spelled as "Infinity", "-Infinity", etc. 
                        if ("inf".equalsIgnoreCase(token) || "+inf".equalsIgnoreCase(token)) {
                            retVector[caseindex] = java.lang.Double.POSITIVE_INFINITY;
                        } else if ("-inf".equalsIgnoreCase(token)) {
                            retVector[caseindex] = java.lang.Double.NEGATIVE_INFINITY;
                        } else if (token == null || token.equals("")) {
                            // missing value:
                            retVector[caseindex] = null;
                        } else {
                            retVector[caseindex] = new Double(token);
                        }
                    } catch (NumberFormatException ex) {
                        dbgLog.warning("NumberFormatException thrown for " + token + " as Double");

                        retVector[caseindex] = null; // missing value
                        // TODO: ?
                    }
                } else if (isLong) {
                    try {
                        retVector[caseindex] = new Long(token);
                    } catch (NumberFormatException ex) {
                        retVector[caseindex] = null; // assume missing value
                    }
                } else if (isFloat) {
                    try {
                        if ("inf".equalsIgnoreCase(token) || "+inf".equalsIgnoreCase(token)) {
                            retVector[caseindex] = java.lang.Float.POSITIVE_INFINITY;
                        } else if ("-inf".equalsIgnoreCase(token)) {
                            retVector[caseindex] = java.lang.Float.NEGATIVE_INFINITY;
                        } else if (token == null || token.equals("")) {
                            // missing value:
                            retVector[caseindex] = null;
                        } else {
                            retVector[caseindex] = new Float(token);
                        }
                    } catch (NumberFormatException ex) {
                        dbgLog.warning("NumberFormatException thrown for " + token + " as Float");
                        retVector[caseindex] = null; // assume missing value (TODO: ?)
                    }
                }
                caseindex++;

                if (bytecount == bytesRead - 1) {
                    byteoffset = 0;
                } else {
                    byteoffset = bytecount + 1;
                }
            } else {
                if (bytecount == bytesRead - 1) {
                    // We've reached the end of the buffer; 
                    // This means we'll save whatever unused bytes left in 
                    // it - i.e., the bytes between the last new line 
                    // encountered and the end - in the leftover buffer. 

                    // *EXCEPT*, there may be a case of a very long String
                    // that is actually longer than MAX_COLUMN_BUFFER, in 
                    // which case it is possible that we've read through
                    // an entire buffer of bytes without finding any 
                    // new lines... in this case we may need to add this
                    // entire byte buffer to an already existing leftover 
                    // buffer!
                    if (leftover == null) {
                        leftover = new byte[(int) bytesRead - byteoffset];
                        System.arraycopy(columnBytes, byteoffset, leftover, 0, (int) bytesRead - byteoffset);
                    } else {
                        if (byteoffset != 0) {
                            throw new IOException(
                                    "Reached the end of the byte buffer, with some leftover left from the last read; yet the offset is not zero!");
                        }
                        byte[] merged = new byte[leftover.length + (int) bytesRead];

                        System.arraycopy(leftover, 0, merged, 0, leftover.length);
                        System.arraycopy(columnBytes, byteoffset, merged, leftover.length, (int) bytesRead);
                        //leftover = null;
                        leftover = merged;
                        merged = null;
                    }
                    byteoffset = 0;

                }
            }
            bytecount++;
        }

        bytesReadTotal += bytesRead;
        in.clear();
        if (columnLength - bytesReadTotal < MAX_COLUMN_BUFFER) {
            in.limit((int) (columnLength - bytesReadTotal));
        }
    }

    fc.close();

    if (caseindex != casecount) {
        throw new IOException("Faile to read " + casecount + " tokens for column " + column);
        //System.out.println("read "+caseindex+" tokens instead of expected "+casecount+".");
    }

    return retVector;
}

From source file:jp.furplag.util.commons.NumberUtilsTest.java

/**
 * {@link jp.furplag.util.commons.NumberUtils#isInfiniteOrNaN(java.lang.Object)}.
 *//* w ww  .  jav  a 2 s  . c  o  m*/
// @Test
public void testIsInfiniteOrNaN() {
    assertEquals("null", false, isInfiniteOrNaN(null));
    assertEquals("empty", false, isInfiniteOrNaN(""));
    assertEquals("invalidString", false, isInfiniteOrNaN("not a number"));
    assertEquals("notParsable", false, isInfiniteOrNaN(new int[] { 1, 2, 3 }));
    assertEquals("notParsable", false,
            isInfiniteOrNaN(new float[] { Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY }));
    assertEquals("Infinity: Float", true, isInfiniteOrNaN(Float.POSITIVE_INFINITY));
    assertEquals("Infinity: Double", true, isInfiniteOrNaN(Double.POSITIVE_INFINITY));
    assertEquals("Infinity: String", true, isInfiniteOrNaN("Infinity"));
    assertEquals("-Infinity: Float", true, isInfiniteOrNaN(Float.NEGATIVE_INFINITY));
    assertEquals("-Infinity: Double", true, isInfiniteOrNaN(Double.NEGATIVE_INFINITY));
    assertEquals("-Infinity: String", true, isInfiniteOrNaN("-Infinity"));
    assertEquals("NaN: Double", true, isInfiniteOrNaN(Double.NaN));
    assertEquals("NaN: Float", true, isInfiniteOrNaN(Double.NaN));
    assertEquals("NaN: String", true, isInfiniteOrNaN("NaN"));

    assertEquals("NaN: Double", true, isInfiniteOrNaN(Double.POSITIVE_INFINITY / Double.POSITIVE_INFINITY));
    assertEquals("NaN: Float", true,
            isInfiniteOrNaN(divide(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, float.class)));
}