本文整理汇总了Java中org.apache.commons.math.MathRuntimeException.createIOException方法的典型用法代码示例。如果您正苦于以下问题:Java MathRuntimeException.createIOException方法的具体用法?Java MathRuntimeException.createIOException怎么用?Java MathRuntimeException.createIOException使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.math.MathRuntimeException
的用法示例。
在下文中一共展示了MathRuntimeException.createIOException方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeExternal
import org.apache.commons.math.MathRuntimeException; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
public void writeExternal(final ObjectOutput out)
throws IOException {
try {
// save the local attributes
finalizeStep();
} catch (DerivativeException e) {
throw MathRuntimeException.createIOException(e);
}
final int dimension = (currentState == null) ? -1 : currentState.length;
out.writeInt(dimension);
for (int i = 0; i < dimension; ++i) {
out.writeDouble(yDotKLast[0][i]);
out.writeDouble(yDotKLast[1][i]);
out.writeDouble(yDotKLast[2][i]);
}
// save the state of the base class
super.writeExternal(out);
}
示例2: writeBaseExternal
import org.apache.commons.math.MathRuntimeException; //导入方法依赖的package包/类
/** Save the base state of the instance.
* This method performs step finalization if it has not been done
* before.
* @param out stream where to save the state
* @exception IOException in case of write error
*/
protected void writeBaseExternal(final ObjectOutput out)
throws IOException {
if (currentState == null) {
out.writeInt(-1);
} else {
out.writeInt(currentState.length);
}
out.writeDouble(previousTime);
out.writeDouble(currentTime);
out.writeDouble(h);
out.writeBoolean(forward);
if (currentState != null) {
for (int i = 0; i < currentState.length; ++i) {
out.writeDouble(currentState[i]);
}
}
out.writeDouble(interpolatedTime);
// we do not store the interpolated state,
// it will be recomputed as needed after reading
// finalize the step (and don't bother saving the now true flag)
try {
finalizeStep();
} catch (DerivativeException e) {
throw MathRuntimeException.createIOException(e);
}
}
示例3: load
import org.apache.commons.math.MathRuntimeException; //导入方法依赖的package包/类
/**
* Computes the empirical distribution from the input file.
*
* @param file the input file
* @throws IOException if an IO error occurs
*/
public void load(File file) throws IOException {
BufferedReader in = new BufferedReader(new FileReader(file));
try {
DataAdapter da = new StreamDataAdapter(in);
try {
da.computeStats();
} catch (IOException ioe) {
// don't wrap exceptions which are already IOException
throw ioe;
} catch (RuntimeException rte) {
// don't wrap RuntimeExceptions
throw rte;
} catch (Exception e) {
throw MathRuntimeException.createIOException(e);
}
in = new BufferedReader(new FileReader(file));
fillBinStats(in);
loaded = true;
} finally {
try {
in.close();
} catch (IOException ex) {
// ignore
}
}
}
示例4: load
import org.apache.commons.math.MathRuntimeException; //导入方法依赖的package包/类
/**
* Computes the empirical distribution using data read from a URL.
* @param url url of the input file
*
* @throws IOException if an IO error occurs
*/
public void load(URL url) throws IOException {
BufferedReader in =
new BufferedReader(new InputStreamReader(url.openStream()));
try {
DataAdapter da = new StreamDataAdapter(in);
try {
da.computeStats();
} catch (IOException ioe) {
// don't wrap exceptions which are already IOException
throw ioe;
} catch (RuntimeException rte) {
// don't wrap RuntimeExceptions
throw rte;
} catch (Exception e) {
throw MathRuntimeException.createIOException(e);
}
if (sampleStats.getN() == 0) {
throw MathRuntimeException.createEOFException("URL {0} contains no data",
url);
}
in = new BufferedReader(new InputStreamReader(url.openStream()));
fillBinStats(in);
loaded = true;
} finally {
try {
in.close();
} catch (IOException ex) {
// ignore
}
}
}
示例5: fillBinStats
import org.apache.commons.math.MathRuntimeException; //导入方法依赖的package包/类
/**
* Fills binStats array (second pass through data file).
*
* @param in object providing access to the data
* @throws IOException if an IO error occurs
*/
private void fillBinStats(Object in) throws IOException {
// Load array of bin upper bounds -- evenly spaced from min - max
double min = sampleStats.getMin();
double max = sampleStats.getMax();
double delta = (max - min)/(Double.valueOf(binCount)).doubleValue();
double[] binUpperBounds = new double[binCount];
binUpperBounds[0] = min + delta;
for (int i = 1; i< binCount - 1; i++) {
binUpperBounds[i] = binUpperBounds[i-1] + delta;
}
binUpperBounds[binCount -1] = max;
// Initialize binStats ArrayList
if (!binStats.isEmpty()) {
binStats.clear();
}
for (int i = 0; i < binCount; i++) {
SummaryStatistics stats = new SummaryStatistics();
binStats.add(i,stats);
}
// Filling data in binStats Array
DataAdapterFactory aFactory = new DataAdapterFactory();
DataAdapter da = aFactory.getAdapter(in);
try {
da.computeBinStats(min, delta);
} catch (IOException ioe) {
// don't wrap exceptions which are already IOException
throw ioe;
} catch (RuntimeException rte) {
// don't wrap RuntimeExceptions
throw rte;
} catch (Exception e) {
throw MathRuntimeException.createIOException(e);
}
// Assign upperBounds based on bin counts
upperBounds = new double[binCount];
upperBounds[0] =
((double) binStats.get(0).getN()) / (double) sampleStats.getN();
for (int i = 1; i < binCount-1; i++) {
upperBounds[i] = upperBounds[i-1] +
((double) binStats.get(i).getN()) / (double) sampleStats.getN();
}
upperBounds[binCount-1] = 1.0d;
}