• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java MathInternalError类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: 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 one 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 characterization placeholder where to put the characterized parts
 */
private void characterize(final BSPTree<S> node, final SubHyperplane<S> sub,
                          final SubHyperplane<S>[] characterization) {
    if (node.getCut() == null) {
        // we have reached a leaf node
        final boolean inside = (Boolean) node.getAttribute();
        if (inside) {
            if (characterization[1] == null) {
                characterization[1] = sub;
            } else {
                characterization[1] = characterization[1].reunite(sub);
            }
        } else {
            if (characterization[0] == null) {
                characterization[0] = sub;
            } else {
                characterization[0] = characterization[0].reunite(sub);
            }
        }
    } else {
        final Hyperplane<S> hyperplane = node.getCut().getHyperplane();
        switch (sub.side(hyperplane)) {
        case PLUS:
            characterize(node.getPlus(), sub, characterization);
            break;
        case MINUS:
            characterize(node.getMinus(), sub, characterization);
            break;
        case BOTH:
            final SubHyperplane.SplitSubHyperplane<S> split = sub.split(hyperplane);
            characterize(node.getPlus(),  split.getPlus(),  characterization);
            characterize(node.getMinus(), split.getMinus(), characterization);
            break;
        default:
            // this should not happen
            throw new MathInternalError();
        }
    }
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:52,代码来源:AbstractRegion.java


示例17: resolveTie

import org.apache.commons.math3.exception.MathInternalError; //导入依赖的package包/类
/**
 * Resolve a sequence of ties, using the configured {@link TiesStrategy}.
 * The input <code>ranks</code> array is expected to take the same value
 * for all indices in <code>tiesTrace</code>.  The common value is recoded
 * according to the tiesStrategy. For example, if ranks = <5,8,2,6,2,7,1,2>,
 * tiesTrace = <2,4,7> and tiesStrategy is MINIMUM, ranks will be unchanged.
 * The same array and trace with tiesStrategy AVERAGE will come out
 * <5,8,3,6,3,7,1,3>.
 *
 * @param ranks array of ranks
 * @param tiesTrace list of indices where <code>ranks</code> is constant
 * -- that is, for any i and j in TiesTrace, <code> ranks[i] == ranks[j]
 * </code>
 */
private void resolveTie(double[] ranks, List<Integer> tiesTrace) {

    // constant value of ranks over tiesTrace
    final double c = ranks[tiesTrace.get(0)];

    // length of sequence of tied ranks
    final int length = tiesTrace.size();

    switch (tiesStrategy) {
        case  AVERAGE:  // Replace ranks with average
            fill(ranks, tiesTrace, (2 * c + length - 1) / 2d);
            break;
        case MAXIMUM:   // Replace ranks with maximum values
            fill(ranks, tiesTrace, c + length - 1);
            break;
        case MINIMUM:   // Replace ties with minimum
            fill(ranks, tiesTrace, c);
            break;
        case RANDOM:    // Fill with random integral values in [c, c + length - 1]
            Iterator<Integer> iterator = tiesTrace.iterator();
            long f = FastMath.round(c);
            while (iterator.hasNext()) {
                ranks[iterator.next()] =
                    randomData.nextLong(f, f + length - 1);
            }
            break;
        case SEQUENTIAL:  // Fill sequentially from c to c + length - 1
            // walk and fill
            iterator = tiesTrace.iterator();
            f = FastMath.round(c);
            int i = 0;
            while (iterator.hasNext()) {
                ranks[iterator.next()] = f + i++;
            }
            break;
        default: // this should not happen unless TiesStrategy enum is changed
            throw new MathInternalError();
    }
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:54,代码来源:NaturalRanking.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SnmpStandardObjectServer类代码示例发布时间:2022-05-22
下一篇:
Java DefaultMQPullConsumer类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap