当前位置: 首页>>代码示例>>Java>>正文


Java MathRuntimeException.createIOException方法代码示例

本文整理汇总了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);

}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:24,代码来源:DormandPrince853StepInterpolator.java

示例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);
  }

}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:39,代码来源:AbstractStepInterpolator.java

示例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
        }
    }
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:33,代码来源:EmpiricalDistributionImpl.java

示例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
       }
    }
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:38,代码来源:EmpiricalDistributionImpl.java

示例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;
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:53,代码来源:EmpiricalDistributionImpl.java


注:本文中的org.apache.commons.math.MathRuntimeException.createIOException方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。