Tabnine Logo
NoDataException.<init>
Code IndexAdd Tabnine to your IDE (free)

How to use
org.apache.commons.math3.exception.NoDataException
constructor

Best Java code snippets using org.apache.commons.math3.exception.NoDataException.<init> (Showing top 20 results out of 315)

origin: org.apache.commons/commons-math3

/** Check interpolation can be performed.
 * @exception NoDataException if interpolation cannot be performed
 * because sample is empty
 */
private void checkInterpolation() throws NoDataException {
  if (abscissae.isEmpty()) {
    throw new NoDataException(LocalizedFormats.EMPTY_INTERPOLATION_SAMPLE);
  }
}
origin: org.apache.commons/commons-math3

/**
 * Get the elements type from an array.
 *
 * @param <T> Type of the field elements.
 * @param d Data array.
 * @return the field to which the array elements belong.
 * @throws NoDataException if array is empty.
 */
protected static <T extends FieldElement<T>> Field<T> extractField(final T[] d)
  throws NoDataException {
  if (d.length == 0) {
    throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_ROW);
  }
  return d[0].getField();
}
origin: org.apache.commons/commons-math3

/**
 * Ensures that the provided arrays fulfills the assumptions.
 *
 * @param x first sample
 * @param y second sample
 * @throws NullArgumentException if {@code x} or {@code y} are {@code null}.
 * @throws NoDataException if {@code x} or {@code y} are zero-length.
 */
private void ensureDataConformance(final double[] x, final double[] y)
  throws NullArgumentException, NoDataException {
  if (x == null ||
    y == null) {
    throw new NullArgumentException();
  }
  if (x.length == 0 ||
    y.length == 0) {
    throw new NoDataException();
  }
}
origin: org.apache.commons/commons-math3

/**
 * Get the elements type from an array.
 *
 * @param <T> Type of the field elements.
 * @param d Data array.
 * @return the field to which the array elements belong.
 * @throws NullArgumentException if the array is {@code null}.
 * @throws NoDataException if the array is empty.
 */
protected static <T extends FieldElement<T>> Field<T> extractField(final T[][] d)
  throws NoDataException, NullArgumentException {
  if (d == null) {
    throw new NullArgumentException();
  }
  if (d.length == 0) {
    throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_ROW);
  }
  if (d[0].length == 0) {
    throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_COLUMN);
  }
  return d[0][0].getField();
}
origin: org.apache.commons/commons-math3

/**
 * Uses Horner's Method to evaluate the polynomial with the given coefficients at
 * the argument.
 *
 * @param coefficients Coefficients of the polynomial to evaluate.
 * @param argument Input value.
 * @return the value of the polynomial.
 * @throws NoDataException if {@code coefficients} is empty.
 * @throws NullArgumentException if {@code coefficients} is {@code null}.
 */
protected static double evaluate(double[] coefficients, double argument)
  throws NullArgumentException, NoDataException {
  MathUtils.checkNotNull(coefficients);
  int n = coefficients.length;
  if (n == 0) {
    throw new NoDataException(LocalizedFormats.EMPTY_POLYNOMIALS_COEFFICIENTS_ARRAY);
  }
  double result = coefficients[n - 1];
  for (int j = n - 2; j >= 0; j--) {
    result = argument * result + coefficients[j];
  }
  return result;
}
origin: org.apache.commons/commons-math3

/**
 * Returns the coefficients of the derivative of the polynomial with the given coefficients.
 *
 * @param coefficients Coefficients of the polynomial to differentiate.
 * @return the coefficients of the derivative or {@code null} if coefficients has length 1.
 * @throws NoDataException if {@code coefficients} is empty.
 * @throws NullArgumentException if {@code coefficients} is {@code null}.
 */
protected static double[] differentiate(double[] coefficients)
  throws NullArgumentException, NoDataException {
  MathUtils.checkNotNull(coefficients);
  int n = coefficients.length;
  if (n == 0) {
    throw new NoDataException(LocalizedFormats.EMPTY_POLYNOMIALS_COEFFICIENTS_ARRAY);
  }
  if (n == 1) {
    return new double[]{0};
  }
  double[] result = new double[n - 1];
  for (int i = n - 1; i > 0; i--) {
    result[i - 1] = i * coefficients[i];
  }
  return result;
}
origin: org.apache.commons/commons-math3

/**
 * Returns the sum of the (signed) differences between corresponding elements of the
 * input arrays -- i.e., sum(sample1[i] - sample2[i]).
 *
 * @param sample1  the first array
 * @param sample2  the second array
 * @return sum of paired differences
 * @throws DimensionMismatchException if the arrays do not have the same
 * (positive) length.
 * @throws NoDataException if the sample arrays are empty.
 */
public static double sumDifference(final double[] sample1, final double[] sample2)
throws DimensionMismatchException, NoDataException {
  int n = sample1.length;
  if (n != sample2.length) {
    throw new DimensionMismatchException(n, sample2.length);
  }
  if (n <= 0) {
    throw new NoDataException(LocalizedFormats.INSUFFICIENT_DIMENSION);
  }
  double result = 0;
  for (int i = 0; i < n; i++) {
    result += sample1[i] - sample2[i];
  }
  return result;
}
origin: org.apache.commons/commons-math3

/**
 * Construct a polynomial with the given coefficients.  The first element
 * of the coefficients array is the constant term.  Higher degree
 * coefficients follow in sequence.  The degree of the resulting polynomial
 * is the index of the last non-null element of the array, or 0 if all elements
 * are null.
 * <p>
 * The constructor makes a copy of the input array and assigns the copy to
 * the coefficients property.</p>
 *
 * @param c Polynomial coefficients.
 * @throws NullArgumentException if {@code c} is {@code null}.
 * @throws NoDataException if {@code c} is empty.
 */
public PolynomialFunction(double c[])
  throws NullArgumentException, NoDataException {
  super();
  MathUtils.checkNotNull(c);
  int n = c.length;
  if (n == 0) {
    throw new NoDataException(LocalizedFormats.EMPTY_POLYNOMIALS_COEFFICIENTS_ARRAY);
  }
  while ((n > 1) && (c[n - 1] == 0)) {
    --n;
  }
  this.coefficients = new double[n];
  System.arraycopy(c, 0, this.coefficients, 0, n);
}
origin: org.apache.commons/commons-math3

/**
 * Loads new y sample data, overriding any previous data.
 *
 * @param y the array representing the y sample
 * @throws NullArgumentException if y is null
 * @throws NoDataException if y is empty
 */
protected void newYSampleData(double[] y) {
  if (y == null) {
    throw new NullArgumentException();
  }
  if (y.length == 0) {
    throw new NoDataException();
  }
  this.yVector = new ArrayRealVector(y);
}
origin: org.apache.commons/commons-math3

/**
 * Calculates |z[i]| for all i
 *
 * @param z sample
 * @return |z|
 * @throws NullArgumentException if {@code z} is {@code null}
 * @throws NoDataException if {@code z} is zero-length.
 */
private double[] calculateAbsoluteDifferences(final double[] z)
  throws NullArgumentException, NoDataException {
  if (z == null) {
    throw new NullArgumentException();
  }
  if (z.length == 0) {
    throw new NoDataException();
  }
  final double[] zAbs = new double[z.length];
  for (int i = 0; i < z.length; ++i) {
    zAbs[i] = FastMath.abs(z[i]);
  }
  return zAbs;
}
origin: org.apache.commons/commons-math3

/**
 * Ensures that the provided arrays fulfills the assumptions.
 *
 * @param x first sample
 * @param y second sample
 * @throws NullArgumentException if {@code x} or {@code y} are {@code null}.
 * @throws NoDataException if {@code x} or {@code y} are zero-length.
 * @throws DimensionMismatchException if {@code x} and {@code y} do not
 * have the same length.
 */
private void ensureDataConformance(final double[] x, final double[] y)
  throws NullArgumentException, NoDataException, DimensionMismatchException {
  if (x == null ||
    y == null) {
      throw new NullArgumentException();
  }
  if (x.length == 0 ||
    y.length == 0) {
    throw new NoDataException();
  }
  if (y.length != x.length) {
    throw new DimensionMismatchException(y.length, x.length);
  }
}
origin: org.apache.commons/commons-math3

/**
 * Check if submatrix ranges indices are valid.
 * Rows and columns are indicated counting from 0 to n-1.
 *
 * @param selectedRows Array of row indices.
 * @param selectedColumns Array of column indices.
 * @throws NullArgumentException if the arrays are {@code null}.
 * @throws NoDataException if the arrays have zero length.
 * @throws OutOfRangeException if row or column selections are not valid.
 */
protected void checkSubMatrixIndex(final int[] selectedRows, final int[] selectedColumns)
  throws NoDataException, NullArgumentException, OutOfRangeException {
  if (selectedRows == null ||
    selectedColumns == null) {
    throw new NullArgumentException();
  }
  if (selectedRows.length == 0 ||
    selectedColumns.length == 0) {
    throw new NoDataException();
  }
  for (final int row : selectedRows) {
    checkRowIndex(row);
  }
  for (final int column : selectedColumns) {
    checkColumnIndex(column);
  }
}
origin: org.apache.commons/commons-math3

/**
 * Computes the quantization error.
 * The quantization error is the average distance between a feature vector
 * and its "best matching unit" (closest neuron).
 *
 * @param data Feature vectors.
 * @param neurons List of neurons to scan.
 * @param distance Distance function.
 * @return the error.
 * @throws NoDataException if {@code data} is empty.
 */
public static double computeQuantizationError(Iterable<double[]> data,
                       Iterable<Neuron> neurons,
                       DistanceMeasure distance) {
  double d = 0;
  int count = 0;
  for (double[] f : data) {
    ++count;
    d += distance.compute(f, findBest(f, neurons, distance).getFeatures());
  }
  if (count == 0) {
    throw new NoDataException();
  }
  return d / count;
}
origin: org.apache.commons/commons-math3

/** Interpolate value at a specified abscissa.
 * @param x interpolation abscissa
 * @return interpolated value
 * @exception NoDataException if sample is empty
 * @throws NullArgumentException if x is null
 */
public T[] value(T x) throws NoDataException, NullArgumentException {
  // safety check
  MathUtils.checkNotNull(x);
  if (abscissae.isEmpty()) {
    throw new NoDataException(LocalizedFormats.EMPTY_INTERPOLATION_SAMPLE);
  }
  final T[] value = MathArrays.buildArray(x.getField(), topDiagonal.get(0).length);
  T valueCoeff = x.getField().getOne();
  for (int i = 0; i < topDiagonal.size(); ++i) {
    T[] dividedDifference = topDiagonal.get(i);
    for (int k = 0; k < value.length; ++k) {
      value[k] = value[k].add(dividedDifference[k].multiply(valueCoeff));
    }
    final T deltaX = x.subtract(abscissae.get(i));
    valueCoeff = valueCoeff.multiply(deltaX);
  }
  return value;
}
origin: org.apache.commons/commons-math3

/** {@inheritDoc} */
public void setSubMatrix(final double[][] subMatrix, final int row, final int column)
  throws NoDataException, OutOfRangeException,
  DimensionMismatchException, NullArgumentException {
  MathUtils.checkNotNull(subMatrix);
  final int nRows = subMatrix.length;
  if (nRows == 0) {
    throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_ROW);
  }
  final int nCols = subMatrix[0].length;
  if (nCols == 0) {
    throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_COLUMN);
  }
  for (int r = 1; r < nRows; ++r) {
    if (subMatrix[r].length != nCols) {
      throw new DimensionMismatchException(nCols, subMatrix[r].length);
    }
  }
  MatrixUtils.checkRowIndex(this, row);
  MatrixUtils.checkColumnIndex(this, column);
  MatrixUtils.checkRowIndex(this, nRows + row - 1);
  MatrixUtils.checkColumnIndex(this, nCols + column - 1);
  for (int i = 0; i < nRows; ++i) {
    for (int j = 0; j < nCols; ++j) {
      setEntry(row + i, column + j, subMatrix[i][j]);
    }
  }
}
origin: org.apache.commons/commons-math3

throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_ROW);
throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_COLUMN);
origin: org.apache.commons/commons-math3

/**
 * Creates a column {@link FieldMatrix} using the data from the input
 * array.
 *
 * @param <T> the type of the field elements
 * @param columnData  the input column data
 * @return a columnData x 1 FieldMatrix
 * @throws NoDataException if {@code data} is empty.
 * @throws NullArgumentException if {@code columnData} is {@code null}.
 */
public static <T extends FieldElement<T>> FieldMatrix<T>
  createColumnFieldMatrix(final T[] columnData)
  throws NoDataException, NullArgumentException {
  if (columnData == null) {
    throw new NullArgumentException();
  }
  final int nRows = columnData.length;
  if (nRows == 0) {
    throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_ROW);
  }
  final FieldMatrix<T> m = createFieldMatrix(columnData[0].getField(), nRows, 1);
  for (int i = 0; i < nRows; ++i) {
    m.setEntry(i, 0, columnData[i]);
  }
  return m;
}
origin: org.apache.commons/commons-math3

/**
 * Create a row {@link FieldMatrix} using the data from the input
 * array.
 *
 * @param <T> the type of the field elements
 * @param rowData the input row data
 * @return a 1 x rowData.length FieldMatrix
 * @throws NoDataException if {@code rowData} is empty.
 * @throws NullArgumentException if {@code rowData} is {@code null}.
 */
public static <T extends FieldElement<T>> FieldMatrix<T>
  createRowFieldMatrix(final T[] rowData)
  throws NoDataException, NullArgumentException {
  if (rowData == null) {
    throw new NullArgumentException();
  }
  final int nCols = rowData.length;
  if (nCols == 0) {
    throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_COLUMN);
  }
  final FieldMatrix<T> m = createFieldMatrix(rowData[0].getField(), 1, nCols);
  for (int i = 0; i < nCols; ++i) {
    m.setEntry(0, i, rowData[i]);
  }
  return m;
}
origin: org.apache.commons/commons-math3

  /**
   * {@inheritDoc}
   */
  public PiecewiseBicubicSplineInterpolatingFunction interpolate( final double[] xval,
                                  final double[] yval,
                                  final double[][] fval)
    throws DimensionMismatchException,
        NullArgumentException,
        NoDataException,
        NonMonotonicSequenceException {
    if ( xval == null ||
       yval == null ||
       fval == null ||
       fval[0] == null ) {
      throw new NullArgumentException();
    }

    if ( xval.length == 0 ||
       yval.length == 0 ||
       fval.length == 0 ) {
      throw new NoDataException();
    }

    MathArrays.checkOrder(xval);
    MathArrays.checkOrder(yval);

    return new PiecewiseBicubicSplineInterpolatingFunction( xval, yval, fval );
  }
}
origin: org.apache.commons/commons-math3

/** {@inheritDoc}
 * @since 3.1
 * @throws NoDataException if {@code coefficients} is empty.
 * @throws NullArgumentException if {@code coefficients} is {@code null}.
 */
public DerivativeStructure value(final DerivativeStructure t)
  throws NullArgumentException, NoDataException {
  MathUtils.checkNotNull(coefficients);
  int n = coefficients.length;
  if (n == 0) {
    throw new NoDataException(LocalizedFormats.EMPTY_POLYNOMIALS_COEFFICIENTS_ARRAY);
  }
  DerivativeStructure result =
      new DerivativeStructure(t.getFreeParameters(), t.getOrder(), coefficients[n - 1]);
  for (int j = n - 2; j >= 0; j--) {
    result = result.multiply(t).add(coefficients[j]);
  }
  return result;
}
org.apache.commons.math3.exceptionNoDataException<init>

Javadoc

Construct the exception.

Popular methods of NoDataException

    Popular in Java

    • Making http requests using okhttp
    • requestLocationUpdates (LocationManager)
    • setScale (BigDecimal)
    • getApplicationContext (Context)
    • MalformedURLException (java.net)
      This exception is thrown when a program attempts to create an URL from an incorrect specification.
    • Enumeration (java.util)
      A legacy iteration interface.New code should use Iterator instead. Iterator replaces the enumeration
    • TimeUnit (java.util.concurrent)
      A TimeUnit represents time durations at a given unit of granularity and provides utility methods to
    • JCheckBox (javax.swing)
    • Reflections (org.reflections)
      Reflections one-stop-shop objectReflections scans your classpath, indexes the metadata, allows you t
    • Location (org.springframework.beans.factory.parsing)
      Class that models an arbitrary location in a Resource.Typically used to track the location of proble
    • Top plugins for WebStorm
    Tabnine Logo
    • Products

      Search for Java codeSearch for JavaScript code
    • IDE Plugins

      IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
    • Company

      About UsContact UsCareers
    • Resources

      FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
    Get Tabnine for your IDE now