Java Code Examples for org.apache.commons.math.MathRuntimeException#createIOException()

The following examples show how to use org.apache.commons.math.MathRuntimeException#createIOException() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DormandPrince853StepInterpolator.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/** {@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);

}
 
Example 2
Source File: DormandPrince853StepInterpolator.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/** {@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);

}
 
Example 3
Source File: DormandPrince853StepInterpolator.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/** {@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);

}
 
Example 4
Source File: DormandPrince853StepInterpolator.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/** {@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);

}
 
Example 5
Source File: DormandPrince853StepInterpolator.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/** {@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);

}
 
Example 6
Source File: DormandPrince853StepInterpolator.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/** {@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);

}
 
Example 7
Source File: DormandPrince853StepInterpolator.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/** {@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);

}
 
Example 8
Source File: DormandPrince853StepInterpolator.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/** {@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);

}
 
Example 9
Source File: DormandPrince853StepInterpolator.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/** {@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);

}
 
Example 10
Source File: AbstractStepInterpolator.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** 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);
  }

}
 
Example 11
Source File: AbstractStepInterpolator.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** 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);
  }

}
 
Example 12
Source File: AbstractStepInterpolator.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** 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);
  }

}
 
Example 13
Source File: AbstractStepInterpolator.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** 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);
  }

}
 
Example 14
Source File: AbstractStepInterpolator.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** 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);
  }

}
 
Example 15
Source File: AbstractStepInterpolator.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** 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);
  }

}
 
Example 16
Source File: AbstractStepInterpolator.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** 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);
  }

}
 
Example 17
Source File: AbstractStepInterpolator.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** 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);
  }

}
 
Example 18
Source File: EmpiricalDistributionImpl.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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;
}
 
Example 19
Source File: EmpiricalDistributionImpl.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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;
}
 
Example 20
Source File: EmpiricalDistributionImpl.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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;
}