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


Java NullArgumentException类代码示例

本文整理汇总了Java中org.apache.commons.math3.exception.NullArgumentException的典型用法代码示例。如果您正苦于以下问题:Java NullArgumentException类的具体用法?Java NullArgumentException怎么用?Java NullArgumentException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


NullArgumentException类属于org.apache.commons.math3.exception包,在下文中一共展示了NullArgumentException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: ParameterGuesser

import org.apache.commons.math3.exception.NullArgumentException; //导入依赖的package包/类
/**
 * Constructs instance with the specified observed points.
 *
 * @param observations Observed points from which to guess the
 * parameters of the Gaussian.
 * @throws NullArgumentException if {@code observations} is
 * {@code null}.
 * @throws NumberIsTooSmallException if there are less than 3
 * observations.
 */
public ParameterGuesser(WeightedObservedPoint[] observations) {
    if (observations == null) {
        throw new NullArgumentException(LocalizedFormats.INPUT_ARRAY);
    }
    if (observations.length < 3) {
        throw new NumberIsTooSmallException(observations.length, 3, true);
    }

    final WeightedObservedPoint[] sorted = sortObservations(observations);
    final double[] params = basicGuess(sorted);

    norm = params[0];
    mean = params[1];
    sigma = params[2];
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:26,代码来源:GaussianFitter.java

示例2: generate

import org.apache.commons.math3.exception.NullArgumentException; //导入依赖的package包/类
/** {@inheritDoc} */
public ConvexHull2D generate(final Collection<Vector2D> points)
        throws NullArgumentException, ConvergenceException {
    // check for null points
    MathUtils.checkNotNull(points);

    Collection<Vector2D> hullVertices = null;
    if (points.size() < 2) {
        hullVertices = points;
    } else {
        hullVertices = findHullVertices(points);
    }

    try {
        return new ConvexHull2D(hullVertices.toArray(new Vector2D[hullVertices.size()]),
                                tolerance);
    } catch (MathIllegalArgumentException e) {
        // the hull vertices may not form a convex hull if the tolerance value is to large
        throw new ConvergenceException();
    }
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:22,代码来源:AbstractConvexHullGenerator2D.java

示例3: checkArray

import org.apache.commons.math3.exception.NullArgumentException; //导入依赖的package包/类
/**
 * Checks to make sure that the input long[][] array is rectangular,
 * has at least 2 rows and 2 columns, and has all non-negative entries.
 *
 * @param in input 2-way table to check
 * @throws NullArgumentException if the array is null
 * @throws DimensionMismatchException if the array is not valid
 * @throws NotPositiveException if the array contains any negative entries
 */
private void checkArray(final long[][] in)
    throws NullArgumentException, DimensionMismatchException,
    NotPositiveException {

    if (in.length < 2) {
        throw new DimensionMismatchException(in.length, 2);
    }

    if (in[0].length < 2) {
        throw new DimensionMismatchException(in[0].length, 2);
    }

    MathArrays.checkRectangular(in);
    MathArrays.checkNonNegative(in);

}
 
开发者ID:biocompibens,项目名称:SME,代码行数:26,代码来源:ChiSquareTest.java

示例4: checkParameters

import org.apache.commons.math3.exception.NullArgumentException; //导入依赖的package包/类
/**
 * Performs all dimension checks on the parameters of
 * {@link #solve(RealLinearOperator, RealVector, RealVector) solve} and
 * {@link #solveInPlace(RealLinearOperator, RealVector, RealVector) solveInPlace},
 * and throws an exception if one of the checks fails.
 *
 * @param a the linear operator A of the system
 * @param b the right-hand side vector
 * @param x0 the initial guess of the solution
 * @throws NullArgumentException if one of the parameters is {@code null}
 * @throws NonSquareOperatorException if {@code a} is not square
 * @throws DimensionMismatchException if {@code b} or {@code x0} have
 * dimensions inconsistent with {@code a}
 */
protected static void checkParameters(final RealLinearOperator a,
    final RealVector b, final RealVector x0) throws
    NullArgumentException, NonSquareOperatorException,
    DimensionMismatchException {
    MathUtils.checkNotNull(a);
    MathUtils.checkNotNull(b);
    MathUtils.checkNotNull(x0);
    if (a.getRowDimension() != a.getColumnDimension()) {
        throw new NonSquareOperatorException(a.getRowDimension(),
                                                   a.getColumnDimension());
    }
    if (b.getDimension() != a.getRowDimension()) {
        throw new DimensionMismatchException(b.getDimension(),
                                             a.getRowDimension());
    }
    if (x0.getDimension() != a.getColumnDimension()) {
        throw new DimensionMismatchException(x0.getDimension(),
                                             a.getColumnDimension());
    }
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:35,代码来源:IterativeLinearSolver.java

示例5: copySubMatrix

import org.apache.commons.math3.exception.NullArgumentException; //导入依赖的package包/类
/** {@inheritDoc} */
public void copySubMatrix(int[] selectedRows, int[] selectedColumns, T[][] destination)
    throws MatrixDimensionMismatchException, NoDataException,
    NullArgumentException, OutOfRangeException {
    // safety checks
    checkSubMatrixIndex(selectedRows, selectedColumns);
    if ((destination.length < selectedRows.length) ||
        (destination[0].length < selectedColumns.length)) {
        throw new MatrixDimensionMismatchException(destination.length,
                                                   destination[0].length,
                                                   selectedRows.length,
                                                   selectedColumns.length);
    }

    // copy entries
    for (int i = 0; i < selectedRows.length; i++) {
        final T[] destinationI = destination[i];
        for (int j = 0; j < selectedColumns.length; j++) {
            destinationI[j] = getEntry(selectedRows[i], selectedColumns[j]);
        }
    }

}
 
开发者ID:biocompibens,项目名称:SME,代码行数:24,代码来源:AbstractFieldMatrix.java

示例6: multiply

import org.apache.commons.math3.exception.NullArgumentException; //导入依赖的package包/类
/**
 * <p>Multiplies the value of this fraction by another, returning the
 * result in reduced form.</p>
 *
 * @param fraction  the fraction to multiply by, must not be {@code null}
 * @return a {@code Fraction} instance with the resulting values
 * @throws NullArgumentException if the fraction is {@code null}
 * @throws MathArithmeticException if the resulting numerator or denominator exceeds
 *  {@code Integer.MAX_VALUE}
 */
public Fraction multiply(Fraction fraction) {
    if (fraction == null) {
        throw new NullArgumentException(LocalizedFormats.FRACTION);
    }
    if (numerator == 0 || fraction.numerator == 0) {
        return ZERO;
    }
    // knuth 4.5.1
    // make sure we don't overflow unless the result *must* overflow.
    int d1 = ArithmeticUtils.gcd(numerator, fraction.denominator);
    int d2 = ArithmeticUtils.gcd(fraction.numerator, denominator);
    return getReducedFraction
    (ArithmeticUtils.mulAndCheck(numerator/d1, fraction.numerator/d2),
            ArithmeticUtils.mulAndCheck(denominator/d2, fraction.denominator/d1));
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:26,代码来源:Fraction.java

示例7: createColumnFieldMatrix

import org.apache.commons.math3.exception.NullArgumentException; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:27,代码来源:MatrixUtils.java

示例8: checkSubMatrixIndex

import org.apache.commons.math3.exception.NullArgumentException; //导入依赖的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);
    }
}
 
开发者ID:jiaminghan,项目名称:droidplanner-master,代码行数:37,代码来源:MatrixUtils.java

示例9: checkSubMatrixIndex

import org.apache.commons.math3.exception.NullArgumentException; //导入依赖的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)
    throws NoDataException, NullArgumentException, OutOfRangeException {
    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);
    }
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:38,代码来源:MatrixUtils.java

示例10: anovaStats

import org.apache.commons.math3.exception.NullArgumentException; //导入依赖的package包/类
/**
 * This method calls the method that actually does the calculations (except
 * P-value).
 *
 * @param categoryData
 *            <code>Collection</code> of <code>double[]</code> arrays each
 *            containing data for one category
 * @return computed AnovaStats
 * @throws NullArgumentException
 *             if <code>categoryData</code> is <code>null</code>
 * @throws DimensionMismatchException
 *             if the length of the <code>categoryData</code> array is less
 *             than 2 or a contained <code>double[]</code> array does not
 *             contain at least two values
 */
private AnovaStats anovaStats(final Collection<double[]> categoryData)
    throws NullArgumentException, DimensionMismatchException {

    MathUtils.checkNotNull(categoryData);

    final Collection<SummaryStatistics> categoryDataSummaryStatistics =
            new ArrayList<SummaryStatistics>(categoryData.size());

    // convert arrays to SummaryStatistics
    for (final double[] data : categoryData) {
        final SummaryStatistics dataSummaryStatistics = new SummaryStatistics();
        categoryDataSummaryStatistics.add(dataSummaryStatistics);
        for (final double val : data) {
            dataSummaryStatistics.addValue(val);
        }
    }

    return anovaStats(categoryDataSummaryStatistics, false);

}
 
开发者ID:biocompibens,项目名称:SME,代码行数:36,代码来源:OneWayAnova.java

示例11: generateSecretKey

import org.apache.commons.math3.exception.NullArgumentException; //导入依赖的package包/类
@Test
public void generateSecretKey() {
  final ByteString message = ByteString.encodeUtf8("this is a test");
  final ByteString key = SecretBox.generateSecretKey();
  final SecretBox box = new SecretBox(key);
  final ByteString n = box.nonce(message);
  final ByteString c = box.seal(n, message);
  final Optional<ByteString> p = box.open(n, c);
  assertEquals(message, p.orElseThrow(NullArgumentException::new));
}
 
开发者ID:codahale,项目名称:xsalsa20poly1305,代码行数:11,代码来源:SecretBoxTest.java

示例12: generateKeyPair

import org.apache.commons.math3.exception.NullArgumentException; //导入依赖的package包/类
@Test
public void generateKeyPair() {
  final ByteString message = ByteString.encodeUtf8("this is a test");
  final ByteString privateKeyA = SecretBox.generatePrivateKey();
  final ByteString publicKeyA = SecretBox.generatePublicKey(privateKeyA);
  final ByteString privateKeyB = SecretBox.generatePrivateKey();
  final ByteString publicKeyB = SecretBox.generatePublicKey(privateKeyB);
  final SecretBox boxA = new SecretBox(publicKeyB, privateKeyA);
  final SecretBox boxB = new SecretBox(publicKeyA, privateKeyB);
  final ByteString n = boxA.nonce(message);
  final ByteString c = boxA.seal(n, message);
  final Optional<ByteString> p = boxB.open(n, c);
  assertEquals(message, p.orElseThrow(NullArgumentException::new));
}
 
开发者ID:codahale,项目名称:xsalsa20poly1305,代码行数:15,代码来源:SecretBoxTest.java

示例13: ArrayFieldVector

import org.apache.commons.math3.exception.NullArgumentException; //导入依赖的package包/类
/**
 * Construct a vector by appending one vector to another vector.
 *
 * @param v1 First vector (will be put in front of the new vector).
 * @param v2 Second vector (will be put at back of the new vector).
 * @throws NullArgumentException if {@code v1} or {@code v2} is
 * {@code null}.
 * @since 3.2
 */
public ArrayFieldVector(T[] v1, FieldVector<T> v2)
        throws NullArgumentException {
    MathUtils.checkNotNull(v1);
    MathUtils.checkNotNull(v2);
    field = v2.getField();
    final T[] v2Data =
            (v2 instanceof ArrayFieldVector) ? ((ArrayFieldVector<T>) v2).data : v2.toArray();
    data = MathArrays.buildArray(field, v1.length + v2Data.length);
    System.arraycopy(v1, 0, data, 0, v1.length);
    System.arraycopy(v2Data, 0, data, v1.length, v2Data.length);
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:21,代码来源:ArrayFieldVector.java

示例14: load

import org.apache.commons.math3.exception.NullArgumentException; //导入依赖的package包/类
/**
 * Computes the empirical distribution from the provided
 * array of numbers.
 *
 * @param in the input data array
 * @exception NullArgumentException if in is null
 */
public void load(double[] in) throws NullArgumentException {
    DataAdapter da = new ArrayDataAdapter(in);
    try {
        da.computeStats();
        // new adapter for the second pass
        fillBinStats(new ArrayDataAdapter(in));
    } catch (IOException ex) {
        // Can't happen
        throw new MathInternalError();
    }
    loaded = true;

}
 
开发者ID:biocompibens,项目名称:SME,代码行数:21,代码来源:EmpiricalDistribution.java

示例15: mapAddToSelf

import org.apache.commons.math3.exception.NullArgumentException; //导入依赖的package包/类
/** {@inheritDoc} */
public FieldVector<T> mapAddToSelf(T d) throws NullArgumentException {
    for (int i = 0; i < data.length; i++) {
        data[i] = data[i].add(d);
    }
    return this;
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:8,代码来源:ArrayFieldVector.java


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