本文整理汇总了Java中org.apache.commons.math3.exception.NoDataException类的典型用法代码示例。如果您正苦于以下问题:Java NoDataException类的具体用法?Java NoDataException怎么用?Java NoDataException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NoDataException类属于org.apache.commons.math3.exception包,在下文中一共展示了NoDataException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: BilinearInterpolatingFunction
import org.apache.commons.math3.exception.NoDataException; //导入依赖的package包/类
public BilinearInterpolatingFunction(double[] xval, double[] yval, double[][] fval)
throws DimensionMismatchException, NoDataException, NonMonotonicSequenceException {
if (xval.length == 0 || yval.length == 0 || fval.length == 0) {
throw new NoDataException();
}
if (xval.length != fval.length) {
throw new DimensionMismatchException(xval.length, fval.length);
}
if (yval.length != fval[0].length) {
throw new DimensionMismatchException(yval.length, fval[0].length);
}
MathArrays.checkOrder(xval);
MathArrays.checkOrder(yval);
this.xval = xval;
this.yval = yval;
this.fval = fval;
}
示例2: interpolate
import org.apache.commons.math3.exception.NoDataException; //导入依赖的package包/类
@Override
public BilinearInterpolatingFunction interpolate(double[] xval, double[] yval, double[][] fval)
throws NoDataException, DimensionMismatchException, NonMonotonicSequenceException {
if (xval.length == 0 || yval.length == 0 || fval.length == 0) {
throw new NoDataException();
}
if (xval.length != fval.length) {
throw new DimensionMismatchException(xval.length, fval.length);
}
if (yval.length != fval[0].length) {
throw new DimensionMismatchException(yval.length, fval[0].length);
}
MathArrays.checkOrder(xval);
MathArrays.checkOrder(yval);
return new BilinearInterpolatingFunction(xval, yval, fval);
}
示例3: computeQuantizationError
import org.apache.commons.math3.exception.NoDataException; //导入依赖的package包/类
/**
* 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;
}
示例4: computeTopographicError
import org.apache.commons.math3.exception.NoDataException; //导入依赖的package包/类
/**
* Computes the topographic error.
* The topographic error is the proportion of data for which first and
* second best matching units are not adjacent in the map.
*
* @param data Feature vectors.
* @param net Network.
* @param distance Distance function.
* @return the error.
* @throws NoDataException if {@code data} is empty.
*/
public static double computeTopographicError(Iterable<double[]> data,
Network net,
DistanceMeasure distance) {
int notAdjacentCount = 0;
int count = 0;
for (double[] f : data) {
++count;
final Pair<Neuron, Neuron> p = findBestAndSecondBest(f, net, distance);
if (!net.getNeighbours(p.getFirst()).contains(p.getSecond())) {
// Increment count if first and second best matching units
// are not neighbours.
++notAdjacentCount;
}
}
if (count == 0) {
throw new NoDataException();
}
return ((double) notAdjacentCount) / count;
}
示例5: ensureDataConformance
import org.apache.commons.math3.exception.NoDataException; //导入依赖的package包/类
/**
* 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);
}
}
示例6: calculateAbsoluteDifferences
import org.apache.commons.math3.exception.NoDataException; //导入依赖的package包/类
/**
* 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;
}
示例7: checkSubMatrixIndex
import org.apache.commons.math3.exception.NoDataException; //导入依赖的package包/类
/**
* Check if submatrix ranges indices are valid.
* Rows and columns are indicated counting from 0 to n-1.
*
* @param m Matrix.
* @param selectedRows Array of row indices.
* @param selectedColumns Array of column indices.
* @throws NullArgumentException if {@code selectedRows} or
* {@code selectedColumns} are {@code null}.
* @throws NoDataException if the row or column selections are empty (zero
* length).
* @throws OutOfRangeException if row or column selections are not valid.
*/
public static void checkSubMatrixIndex(final AnyMatrix m,
final int[] selectedRows,
final int[] selectedColumns) {
if (selectedRows == null) {
throw new NullArgumentException();
}
if (selectedColumns == null) {
throw new NullArgumentException();
}
if (selectedRows.length == 0) {
throw new NoDataException(LocalizedFormats.EMPTY_SELECTED_ROW_INDEX_ARRAY);
}
if (selectedColumns.length == 0) {
throw new NoDataException(LocalizedFormats.EMPTY_SELECTED_COLUMN_INDEX_ARRAY);
}
for (final int row : selectedRows) {
checkRowIndex(m, row);
}
for (final int column : selectedColumns) {
checkColumnIndex(m, column);
}
}
示例8: sumDifference
import org.apache.commons.math3.exception.NoDataException; //导入依赖的package包/类
/**
* 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;
}
示例9: checkSubMatrixIndex
import org.apache.commons.math3.exception.NoDataException; //导入依赖的package包/类
/**
* 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) {
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);
}
}
示例10: StepFunction
import org.apache.commons.math3.exception.NoDataException; //导入依赖的package包/类
/**
* Builds a step function from a list of arguments and the corresponding
* values. Specifically, returns the function h(x) defined by <pre><code>
* h(x) = y[0] for all x < x[1]
* y[1] for x[1] ≤ x < x[2]
* ...
* y[y.length - 1] for x ≥ x[x.length - 1]
* </code></pre>
* The value of {@code x[0]} is ignored, but it must be strictly less than
* {@code x[1]}.
*
* @param x Domain values where the function changes value.
* @param y Values of the function.
* @throws NonMonotonicSequenceException
* if the {@code x} array is not sorted in strictly increasing order.
* @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.
*/
public StepFunction(double[] x,
double[] y)
throws NullArgumentException, NoDataException,
DimensionMismatchException, NonMonotonicSequenceException {
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);
}
MathArrays.checkOrder(x);
abscissa = MathArrays.copyOf(x);
ordinate = MathArrays.copyOf(y);
}
示例11: value
import org.apache.commons.math3.exception.NoDataException; //导入依赖的package包/类
/** {@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;
}
示例12: differentiate
import org.apache.commons.math3.exception.NoDataException; //导入依赖的package包/类
/**
* 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;
}
示例13: interpolate
import org.apache.commons.math3.exception.NoDataException; //导入依赖的package包/类
/**
* {@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 );
}
示例14: ComplexFormat
import org.apache.commons.math3.exception.NoDataException; //导入依赖的package包/类
/**
* Create an instance with a custom imaginary character, a custom number
* format for the real part, and a custom number format for the imaginary
* part.
*
* @param imaginaryCharacter The custom imaginary character.
* @param realFormat the custom format for the real part.
* @param imaginaryFormat the custom format for the imaginary part.
* @throws NullArgumentException if {@code imaginaryCharacter} is
* {@code null}.
* @throws NoDataException if {@code imaginaryCharacter} is an
* empty string.
* @throws NullArgumentException if {@code imaginaryFormat} is {@code null}.
* @throws NullArgumentException if {@code realFormat} is {@code null}.
*/
public ComplexFormat(String imaginaryCharacter,
NumberFormat realFormat,
NumberFormat imaginaryFormat)
throws NullArgumentException, NoDataException {
if (imaginaryCharacter == null) {
throw new NullArgumentException();
}
if (imaginaryCharacter.length() == 0) {
throw new NoDataException();
}
if (imaginaryFormat == null) {
throw new NullArgumentException(LocalizedFormats.IMAGINARY_FORMAT);
}
if (realFormat == null) {
throw new NullArgumentException(LocalizedFormats.REAL_FORMAT);
}
this.imaginaryCharacter = imaginaryCharacter;
this.imaginaryFormat = imaginaryFormat;
this.realFormat = realFormat;
}
示例15: Array2DRowFieldMatrix
import org.apache.commons.math3.exception.NoDataException; //导入依赖的package包/类
/**
* Create a new {@code FieldMatrix<T>} using the input array as the underlying
* data array.
* <p>If an array is built specially in order to be embedded in a
* {@code FieldMatrix<T>} and not used directly, the {@code copyArray} may be
* set to {@code false}. This will prevent the copying and improve
* performance as no new array will be built and no data will be copied.</p>
*
* @param field Field to which the elements belong.
* @param d Data for the new matrix.
* @param copyArray Whether to copy or reference the input array.
* @throws DimensionMismatchException if {@code d} is not rectangular.
* @throws NoDataException if there are not at least one row and one column.
* @throws NullArgumentException if {@code d} is {@code null}.
* @see #Array2DRowFieldMatrix(FieldElement[][])
*/
public Array2DRowFieldMatrix(final Field<T> field, final T[][] d, final boolean copyArray)
throws DimensionMismatchException, NoDataException, NullArgumentException {
super(field);
if (copyArray) {
copyIn(d);
} else {
MathUtils.checkNotNull(d);
final int nRows = d.length;
if (nRows == 0) {
throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_ROW);
}
final int nCols = d[0].length;
if (nCols == 0) {
throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_COLUMN);
}
for (int r = 1; r < nRows; r++) {
if (d[r].length != nCols) {
throw new DimensionMismatchException(nCols, d[r].length);
}
}
data = d;
}
}