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


Java MathInternalError类代码示例

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


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

示例1: addArcLimit

import org.apache.commons.math3.exception.MathInternalError; //导入依赖的package包/类
/** Add an arc limit to a BSP tree under construction.
 * @param tree BSP tree under construction
 * @param alpha arc limit
 * @param isStart if true, the limit is the start of an arc
 */
private void addArcLimit(final BSPTree<Sphere1D> tree, final double alpha, final boolean isStart) {

    final LimitAngle limit = new LimitAngle(new S1Point(alpha), !isStart, getTolerance());
    final BSPTree<Sphere1D> node = tree.getCell(limit.getLocation(), getTolerance());
    if (node.getCut() != null) {
        // this should never happen
        throw new MathInternalError();
    }

    node.insertCut(limit);
    node.setAttribute(null);
    node.getPlus().setAttribute(Boolean.FALSE);
    node.getMinus().setAttribute(Boolean.TRUE);

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

示例2: taylor

import org.apache.commons.math3.exception.MathInternalError; //导入依赖的package包/类
/** Evaluate Taylor expansion of a derivative structure.
 * @param ds array holding the derivative structure
 * @param dsOffset offset of the derivative structure in its array
 * @param delta parameters offsets (&Delta;x, &Delta;y, ...)
 * @return value of the Taylor expansion at x + &Delta;x, y + &Delta;y, ...
 * @throws MathArithmeticException if factorials becomes too large
 */
public double taylor(final double[] ds, final int dsOffset, final double ... delta)
   throws MathArithmeticException {
    double value = 0;
    for (int i = getSize() - 1; i >= 0; --i) {
        final int[] orders = getPartialDerivativeOrders(i);
        double term = ds[dsOffset + i];
        for (int k = 0; k < orders.length; ++k) {
            if (orders[k] > 0) {
                try {
                    term *= FastMath.pow(delta[k], orders[k]) /
                    CombinatoricsUtils.factorial(orders[k]);
                } catch (NotPositiveException e) {
                    // this cannot happen
                    throw new MathInternalError(e);
                }
            }
        }
        value += term;
    }
    return value;
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:29,代码来源:DSCompiler.java

示例3: taylor

import org.apache.commons.math3.exception.MathInternalError; //导入依赖的package包/类
/** Evaluate Taylor expansion of a derivative structure.
 * @param ds array holding the derivative structure
 * @param dsOffset offset of the derivative structure in its array
 * @param delta parameters offsets (&Delta;x, &Delta;y, ...)
 * @return value of the Taylor expansion at x + &Delta;x, y + &Delta;y, ...
 * @throws MathArithmeticException if factorials becomes too large
 */
public double taylor(final double[] ds, final int dsOffset, final double ... delta)
   throws MathArithmeticException {
    double value = 0;
    for (int i = getSize() - 1; i >= 0; --i) {
        final int[] orders = getPartialDerivativeOrders(i);
        double term = ds[dsOffset + i];
        for (int k = 0; k < orders.length; ++k) {
            if (orders[k] > 0) {
                try {
                    term *= FastMath.pow(delta[k], orders[k]) /
                            ArithmeticUtils.factorial(orders[k]);
                } catch (NotPositiveException e) {
                    // this cannot happen
                    throw new MathInternalError(e);
                }
            }
        }
        value += term;
    }
    return value;
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:29,代码来源:DSCompiler.java

示例4: getProblem

import org.apache.commons.math3.exception.MathInternalError; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
protected LeastSquaresProblem getProblem(Collection<WeightedObservedPoint> observations) {
    // Prepare least-squares problem.
    final int len = observations.size();
    final double[] target  = new double[len];
    final double[] weights = new double[len];

    int i = 0;
    for (WeightedObservedPoint obs : observations) {
        target[i]  = obs.getY();
        weights[i] = obs.getWeight();
        ++i;
    }

    final AbstractCurveFitter.TheoreticalValuesFunction model =
            new AbstractCurveFitter.TheoreticalValuesFunction(FUNCTION, observations);

    if (initialGuess == null) {
        throw new MathInternalError();
    }

    // Return a new least squares problem set up to fit a polynomial curve to the
    // observed points.
    return new LeastSquaresBuilder().
            maxEvaluations(Integer.MAX_VALUE).
            maxIterations(maxIter).
            start(initialGuess).
            target(target).
            weight(new DiagonalMatrix(weights)).
            model(model.getModelFunction(), model.getModelFunctionJacobian()).
            build();

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

示例5: visitLeafNode

import org.apache.commons.math3.exception.MathInternalError; //导入依赖的package包/类
/** {@inheritDoc} */
public void visitLeafNode(final BSPTree<Sphere2D> node) {
    if ((Boolean) node.getAttribute()) {

        // transform this inside leaf cell into a simple convex polygon
        final SphericalPolygonsSet convex =
                new SphericalPolygonsSet(node.pruneAroundConvexCell(Boolean.TRUE,
                                                                    Boolean.FALSE,
                                                                    null),
                                         tolerance);

        // extract the start of the single loop boundary of the convex cell
        final List<Vertex> boundary = convex.getBoundaryLoops();
        if (boundary.size() != 1) {
            // this should never happen
            throw new MathInternalError();
        }

        // compute the geometrical properties of the convex cell
        final double area  = convexCellArea(boundary.get(0));
        final Vector3D barycenter = convexCellBarycenter(boundary.get(0));
        convexCellsInsidePoints.add(barycenter);

        // add the cell contribution to the global properties
        summedArea      += area;
        summedBarycenter = new Vector3D(1, summedBarycenter, area, barycenter);

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

示例6: characterize

import org.apache.commons.math3.exception.MathInternalError; //导入依赖的package包/类
/** Filter the parts of an hyperplane belonging to the boundary.
 * <p>The filtering consist in splitting the specified
 * sub-hyperplane into several parts lying in inside and outside
 * cells of the tree. The principle is to call this method twice for
 * each cut sub-hyperplane in the tree, once on the plus node and
 * once on the minus node. The parts that have the same flag
 * (inside/inside or outside/outside) do not belong to the boundary
 * while parts that have different flags (inside/outside or
 * outside/inside) do belong to the boundary.</p>
 * @param node current BSP tree node
 * @param sub sub-hyperplane to characterize
 * @param splitters nodes that did split the current one
 */
private void characterize(final BSPTree<S> node, final SubHyperplane<S> sub,
                          final List<BSPTree<S>> splitters) {
    if (node.getCut() == null) {
        // we have reached a leaf node
        final boolean inside = (Boolean) node.getAttribute();
        if (inside) {
            addInsideTouching(sub, splitters);
        } else {
            addOutsideTouching(sub, splitters);
        }
    } else {
        final Hyperplane<S> hyperplane = node.getCut().getHyperplane();
        final SubHyperplane.SplitSubHyperplane<S> split = sub.split(hyperplane);
        switch (split.getSide()) {
        case PLUS:
            characterize(node.getPlus(),  sub, splitters);
            break;
        case MINUS:
            characterize(node.getMinus(), sub, splitters);
            break;
        case BOTH:
            splitters.add(node);
            characterize(node.getPlus(),  split.getPlus(),  splitters);
            characterize(node.getMinus(), split.getMinus(), splitters);
            splitters.remove(splitters.size() - 1);
            break;
        default:
            // this should not happen
            throw new MathInternalError();
        }
    }
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:46,代码来源:Characterization.java

示例7: fixTies

import org.apache.commons.math3.exception.MathInternalError; //导入依赖的package包/类
/**
 * If there are no ties in the combined dataset formed from x and y, this
 * method is a no-op.  If there are ties, a uniform random deviate in
 * (-minDelta / 2, minDelta / 2) - {0} is added to each value in x and y, where
 * minDelta is the minimum difference between unequal values in the combined
 * sample.  A fixed seed is used to generate the jitter, so repeated activations
 * with the same input arrays result in the same values.
 *
 * NOTE: if there are ties in the data, this method overwrites the data in
 * x and y with the jittered values.
 *
 * @param x first sample
 * @param y second sample
 */
private static void fixTies(double[] x, double[] y) {
   final double[] values = MathArrays.unique(MathArrays.concatenate(x,y));
   if (values.length == x.length + y.length) {
       return;  // There are no ties
   }

   // Find the smallest difference between values, or 1 if all values are the same
   double minDelta = 1;
   double prev = values[0];
   double delta = 1;
   for (int i = 1; i < values.length; i++) {
      delta = prev - values[i];
      if (delta < minDelta) {
          minDelta = delta;
      }
      prev = values[i];
   }
   minDelta /= 2;

   // Add jitter using a fixed seed (so same arguments always give same results),
   // low-initialization-overhead generator
   final RealDistribution dist =
           new UniformRealDistribution(new JDKRandomGenerator(100), -minDelta, minDelta);

   // It is theoretically possible that jitter does not break ties, so repeat
   // until all ties are gone.  Bound the loop and throw MIE if bound is exceeded.
   int ct = 0;
   boolean ties = true;
   do {
       jitter(x, dist);
       jitter(y, dist);
       ties = hasTies(x, y);
       ct++;
   } while (ties && ct < 1000);
   if (ties) {
       throw new MathInternalError(); // Should never happen
   }
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:53,代码来源:KolmogorovSmirnovTest.java

示例8: getExpansionMode

import org.apache.commons.math3.exception.MathInternalError; //导入依赖的package包/类
/**
 * The expansion mode determines whether the internal storage
 * array grows additively or multiplicatively when it is expanded.
 *
 * @return the expansion mode.
 * @deprecated As of 3.1. Return value to be changed to
 * {@link ExpansionMode} in 4.0.
 */
@Deprecated
public int getExpansionMode() {
    synchronized (this) {
        switch (expansionMode) {
            case MULTIPLICATIVE:
                return MULTIPLICATIVE_MODE;
            case ADDITIVE:
                return ADDITIVE_MODE;
            default:
                throw new MathInternalError(); // Should never happen.
        }
    }
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:22,代码来源:ResizableDoubleArray.java

示例9: iterator

import org.apache.commons.math3.exception.MathInternalError; //导入依赖的package包/类
/** {@inheritDoc} */
public Iterator<int[]> iterator() {
    if (k == 0 ||
        k == n) {
        return new SingletonIterator(MathArrays.natural(k));
    }

    switch (iterationOrder) {
    case LEXICOGRAPHIC:
        return new LexicographicIterator(n, k);
    default:
        throw new MathInternalError(); // Should never happen.
    }
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:15,代码来源:Combinations.java

示例10: load

import org.apache.commons.math3.exception.MathInternalError; //导入依赖的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

示例11: characterize

import org.apache.commons.math3.exception.MathInternalError; //导入依赖的package包/类
/** Filter the parts of an hyperplane belonging to the boundary.
 * <p>The filtering consist in splitting the specified
 * sub-hyperplane into several parts lying in inside and outside
 * cells of the tree. The principle is to call this method twice for
 * each cut sub-hyperplane in the tree, once on the plus node and
 * once on the minus node. The parts that have the same flag
 * (inside/inside or outside/outside) do not belong to the boundary
 * while parts that have different flags (inside/outside or
 * outside/inside) do belong to the boundary.</p>
 * @param node current BSP tree node
 * @param sub sub-hyperplane to characterize
 * @param splitters nodes that did split the current one
 */
private void characterize(final BSPTree<S> node, final SubHyperplane<S> sub,
                          final List<BSPTree<S>> splitters) {
    if (node.getCut() == null) {
        // we have reached a leaf node
        final boolean inside = (Boolean) node.getAttribute();
        if (inside) {
            addInsideTouching(sub, splitters);
        } else {
            addOutsideTouching(sub, splitters);
        }
    } else {
        final Hyperplane<S> hyperplane = node.getCut().getHyperplane();
        switch (sub.side(hyperplane)) {
        case PLUS:
            characterize(node.getPlus(),  sub, splitters);
            break;
        case MINUS:
            characterize(node.getMinus(), sub, splitters);
            break;
        case BOTH:
            final SubHyperplane.SplitSubHyperplane<S> split = sub.split(hyperplane);
            splitters.add(node);
            characterize(node.getPlus(),  split.getPlus(),  splitters);
            characterize(node.getMinus(), split.getMinus(), splitters);
            splitters.remove(splitters.size() - 1);
            break;
        default:
            // this should not happen
            throw new MathInternalError();
        }
    }
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:46,代码来源:Characterization.java

示例12: getExpansionMode

import org.apache.commons.math3.exception.MathInternalError; //导入依赖的package包/类
/**
 * The expansion mode determines whether the internal storage
 * array grows additively or multiplicatively when it is expanded.
 *
 * @return the expansion mode.
 * @deprecated As of 3.1. Return value to be changed to
 * {@link ExpansionMode} in 4.0.
 */
@Deprecated
public int getExpansionMode() {
    switch (expansionMode) {
    case MULTIPLICATIVE:
        return MULTIPLICATIVE_MODE;
    case ADDITIVE:
        return ADDITIVE_MODE;
    default:
        throw new MathInternalError(); // Should never happen.
    }
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:20,代码来源:ResizableDoubleArray.java

示例13: testWrongOrder

import org.apache.commons.math3.exception.MathInternalError; //导入依赖的package包/类
@Test(expected=NumberIsTooLargeException.class)
public void testWrongOrder() {
    UnivariateDifferentiableFunction f =
            new FiniteDifferencesDifferentiator(3, 0.01).differentiate(new UnivariateFunction() {
                public double value(double x) {
                    // this exception should not be thrown because wrong order
                    // should be detected before function call
                    throw new MathInternalError();
                }
            });
    f.value(new DerivativeStructure(1, 3, 0, 1.0));
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:13,代码来源:FiniteDifferencesDifferentiatorTest.java

示例14: testWrongOrderVector

import org.apache.commons.math3.exception.MathInternalError; //导入依赖的package包/类
@Test(expected=NumberIsTooLargeException.class)
public void testWrongOrderVector() {
    UnivariateDifferentiableVectorFunction f =
            new FiniteDifferencesDifferentiator(3, 0.01).differentiate(new UnivariateVectorFunction() {
                public double[] value(double x) {
                    // this exception should not be thrown because wrong order
                    // should be detected before function call
                    throw new MathInternalError();
                }
            });
    f.value(new DerivativeStructure(1, 3, 0, 1.0));
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:13,代码来源:FiniteDifferencesDifferentiatorTest.java

示例15: testWrongOrderMatrix

import org.apache.commons.math3.exception.MathInternalError; //导入依赖的package包/类
@Test(expected=NumberIsTooLargeException.class)
public void testWrongOrderMatrix() {
    UnivariateDifferentiableMatrixFunction f =
            new FiniteDifferencesDifferentiator(3, 0.01).differentiate(new UnivariateMatrixFunction() {
                public double[][] value(double x) {
                    // this exception should not be thrown because wrong order
                    // should be detected before function call
                    throw new MathInternalError();
                }
            });
    f.value(new DerivativeStructure(1, 3, 0, 1.0));
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:13,代码来源:FiniteDifferencesDifferentiatorTest.java


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