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

Java BigFraction类代码示例

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

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



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

示例1: exactK

import org.apache.commons.math3.fraction.BigFraction; //导入依赖的package包/类
/**
 * Calculates the exact value of {@code P(D_n < d)} using method described
 * in [1] and {@link org.apache.commons.math3.fraction.BigFraction} (see
 * above).
 *
 * @param d statistic
 * @return the two-sided probability of {@code P(D_n < d)}
 * @throws MathArithmeticException if algorithm fails to convert {@code h}
 * to a {@link org.apache.commons.math3.fraction.BigFraction} in expressing
 * {@code d} as {@code (k - h) / m} for integer {@code k, m} and
 * {@code 0 <= h < 1}.
 */
private double exactK(double d) throws MathArithmeticException {

    final int k = (int) FastMath.ceil(n * d);

    final FieldMatrix<BigFraction> H = this.createH(d);
    final FieldMatrix<BigFraction> Hpower = H.power(n);

    BigFraction pFrac = Hpower.getEntry(k - 1, k - 1);

    for (int i = 1; i <= n; ++i) {
        pFrac = pFrac.multiply(i).divide(n);
    }

    /*
     * BigFraction.doubleValue converts numerator to double and the
     * denominator to double and divides afterwards. That gives NaN quite
     * easy. This does not (scale is the number of digits):
     */
    return pFrac.bigDecimalValue(20, BigDecimal.ROUND_HALF_UP).doubleValue();
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:33,代码来源:KolmogorovSmirnovDistribution.java


示例2: buildP

import org.apache.commons.math3.fraction.BigFraction; //导入依赖的package包/类
/** Build the P matrix.
 * <p>The P matrix general terms are shifted (j+1) (-i)<sup>j</sup> terms
 * with i being the row number starting from 1 and j being the column
 * number starting from 1:
 * <pre>
 *        [  -2   3   -4    5  ... ]
 *        [  -4  12  -32   80  ... ]
 *   P =  [  -6  27 -108  405  ... ]
 *        [  -8  48 -256 1280  ... ]
 *        [          ...           ]
 * </pre></p>
 * @param rows number of rows of the matrix
 * @return P matrix
 */
private FieldMatrix<BigFraction> buildP(final int rows) {

    final BigFraction[][] pData = new BigFraction[rows][rows];

    for (int i = 1; i <= pData.length; ++i) {
        // build the P matrix elements from Taylor series formulas
        final BigFraction[] pI = pData[i - 1];
        final int factor = -i;
        int aj = factor;
        for (int j = 1; j <= pI.length; ++j) {
            pI[j - 1] = new BigFraction(aj * (j + 1));
            aj *= factor;
        }
    }

    return new Array2DRowFieldMatrix<BigFraction>(pData, false);

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


示例3: exactK

import org.apache.commons.math3.fraction.BigFraction; //导入依赖的package包/类
/**
 * Calculates the exact value of {@code P(D_n < d)} using the method described in [1] (reference
 * in class javadoc above) and {@link org.apache.commons.math3.fraction.BigFraction} (see
 * above).
 *
 * @param d statistic
 * @param n sample size
 * @return the two-sided probability of \(P(D_n < d)\)
 * @throws MathArithmeticException if algorithm fails to convert {@code h} to a
 *         {@link org.apache.commons.math3.fraction.BigFraction} in expressing {@code d} as \((k
 *         - h) / m\) for integer {@code k, m} and \(0 \le h < 1\).
 */
private double exactK(double d, int n)
    throws MathArithmeticException {

    final int k = (int) Math.ceil(n * d);

    final FieldMatrix<BigFraction> H = this.createExactH(d, n);
    final FieldMatrix<BigFraction> Hpower = H.power(n);

    BigFraction pFrac = Hpower.getEntry(k - 1, k - 1);

    for (int i = 1; i <= n; ++i) {
        pFrac = pFrac.multiply(i).divide(n);
    }

    /*
     * BigFraction.doubleValue converts numerator to double and the denominator to double and
     * divides afterwards. That gives NaN quite easy. This does not (scale is the number of
     * digits):
     */
    return pFrac.bigDecimalValue(20, BigDecimal.ROUND_HALF_UP).doubleValue();
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:34,代码来源:KolmogorovSmirnovTest.java


示例4: getDestStartTime

import org.apache.commons.math3.fraction.BigFraction; //导入依赖的package包/类
private long getDestStartTime() {
    // composition timecode as specified in CPL
    String cplStartTime = getCompositionTimecodeStart();
    BigFraction cplRate = getCompositionTimecodeRate();

    // start time as specified in conversion.xml (destination parameter).
    DestTemplateParameterContext destContext = contextProvider.getDestContext();
    String destStartTime = destContext.getParameterValue(DestContextParameters.START_TIME);
    String destRateStr = destContext.getParameterValue(DestContextParameters.FRAME_RATE);
    BigFraction destRate = StringUtils.isEmpty(destRateStr)
            ? null : ConversionHelper.parseEditRate(destRateStr);

    // values from conversion.xml has higher priority
    String startTime = StringUtils.isEmpty(destStartTime) ? cplStartTime : destStartTime;
    BigFraction rate = destRate == null ? cplRate : destRate;

    // convert to milliseconds
    if (!StringUtils.isEmpty(startTime) && (rate != null)) {
        return ConversionHelper.smpteTimecodeToMilliSeconds(startTime, rate);
    }

    // default fallback 00:00:00:00
    return 0L;
}
 
开发者ID:DSRCorporation,项目名称:imf-conversion,代码行数:25,代码来源:AbstractCplContextBuilderStrategy.java


示例5: getCompositionTimecodeRate

import org.apache.commons.math3.fraction.BigFraction; //导入依赖的package包/类
@Override
public BigFraction getCompositionTimecodeRate() {
    if (cpl2016.getCompositionTimecode() == null) {
        return null;
    }
    BigInteger rate = cpl2016.getCompositionTimecode().getTimecodeRate();
    boolean isDropFrame = cpl2016.getCompositionTimecode().isTimecodeDropFrame();
    if (rate == null || BigInteger.ZERO.equals(rate)) {
        return null;
    }

    // return as-is if non-drop
    if (!isDropFrame) {
        return new BigFraction(rate);
    }

    // return as 30000/1001 for 30 if drop frame
    return new BigFraction(
            rate.multiply(BigInteger.valueOf(1000)),
            BigInteger.valueOf(1001));
}
 
开发者ID:DSRCorporation,项目名称:imf-conversion,代码行数:22,代码来源:Cpl2016ContextBuilderStrategy.java


示例6: getCompositionTimecodeRate

import org.apache.commons.math3.fraction.BigFraction; //导入依赖的package包/类
@Override
public BigFraction getCompositionTimecodeRate() {
    if (cpl2013.getCompositionTimecode() == null) {
        return null;
    }
    BigInteger rate = cpl2013.getCompositionTimecode().getTimecodeRate();
    boolean isDropFrame = cpl2013.getCompositionTimecode().isTimecodeDropFrame();
    if (rate == null || BigInteger.ZERO.equals(rate)) {
        return null;
    }

    // return as-is if non-drop
    if (!isDropFrame) {
        return new BigFraction(rate);
    }

    // return as 30000/1001 for 30 if drop frame
    return new BigFraction(
            rate.multiply(BigInteger.valueOf(1000)),
            BigInteger.valueOf(1001));
}
 
开发者ID:DSRCorporation,项目名称:imf-conversion,代码行数:22,代码来源:Cpl2013ContextBuilderStrategy.java


示例7: doBuildDestContext

import org.apache.commons.math3.fraction.BigFraction; //导入依赖的package包/类
@Override
protected void doBuildDestContext() {
    DestTemplateParameterContext destContext = contextProvider.getDestContext();

    // set interlaced to false if not specified
    String interlaced = destContext.getParameterValue(INTERLACED);
    destContext.addParameter(INTERLACED, interlaced == null ? Boolean.FALSE.toString() : interlaced);

    // define is dar provided
    destContext.addParameter(DEST_PARAM_VIDEO_IS_DAR_SPECIFIED, Boolean.toString(destContext.getParameterValue(DAR) != null));

    // set frame rate for interlaced scan
    // for ffmpeg iFrameRate=frameRate*2
    // for prenc iFrameRate=frameRate
    BigFraction iFrameRate = ConversionHelper.parseEditRate(destContext.getParameterValue(FRAME_RATE));
    if (!SystemUtils.IS_OS_MAC_OSX) {
        iFrameRate = iFrameRate.multiply(2);
    }
    destContext.addParameter(DEST_PARAM_VIDEO_IFRAME_RATE, ConversionHelper.toREditRate(iFrameRate));
}
 
开发者ID:DSRCorporation,项目名称:imf-conversion,代码行数:21,代码来源:ITunesFormatBuilder.java


示例8: resolveContext

import org.apache.commons.math3.fraction.BigFraction; //导入依赖的package包/类
@Override
public DestContextTypeMap resolveContext(DestContextsTypeMap destContexts) throws ConversionException {
    ContextInfo seqContextInfo = new ContextInfoBuilder()
            .setSequenceType(SequenceType.VIDEO)
            .setSequenceUuid(getSequenceUUID())
            .build();

    Integer width = getMinResourceParameterValue(seqContextInfo, WIDTH, Integer::parseInt);
    Integer height = getMinResourceParameterValue(seqContextInfo, HEIGHT, Integer::parseInt);

    BigFraction frameRate = getMinResourceParameterValue(seqContextInfo, FRAME_RATE, ConversionHelper::parseEditRate);

    return resolveStrategy
            .setPackageType(packageType)
            .setWidth(width)
            .setHeight(height)
            .setFrameRate(frameRate)
            // assume video scan type is progressive (according to IMF application #2E)
            .setInterlaced(false)
            .resolveContext(destContexts);
}
 
开发者ID:DSRCorporation,项目名称:imf-conversion,代码行数:22,代码来源:InputDestContextResolveStrategy.java


示例9: testCorrectChapter

import org.apache.commons.math3.fraction.BigFraction; //导入依赖的package包/类
@Test
public void testCorrectChapter() throws Exception {
    ChapterAssetProcessor processor = new ChapterAssetProcessor(metadataXmlProvider, TemplateParameterContextCreator.getWorkingDir());

    processor.setInputChapterItem(ChaptersXmlSampleBuilder.buildInputChapter())
            .setAspectRatio(new BigFraction(16).divide(9))
            .setChapterIndex(1)
            .process(AssetUtils.getTestCorrectChapterFile());

    File asset = new File(TemplateParameterContextCreator.getWorkingDir(), "chapter01.jpg");
    assertTrue(asset.exists());
    assertTrue(asset.isFile());

    ChapterAsset chapterAsset = metadataXmlProvider.getRootElement().getChapterAssets().get(0);
    assertNull(chapterAsset.getType());
    assertNull(chapterAsset.getRole());
    assertEquals("chapter01.jpg", chapterAsset.getFileName());
}
 
开发者ID:DSRCorporation,项目名称:imf-conversion,代码行数:19,代码来源:ChapterAssetProcessorTest.java


示例10: buildP

import org.apache.commons.math3.fraction.BigFraction; //导入依赖的package包/类
/** Build the P matrix.
 * <p>The P matrix general terms are shifted j (-i)<sup>j-1</sup> terms:
 * <pre>
 *        [  -2   3   -4    5  ... ]
 *        [  -4  12  -32   80  ... ]
 *   P =  [  -6  27 -108  405  ... ]
 *        [  -8  48 -256 1280  ... ]
 *        [          ...           ]
 * </pre></p>
 * @param nSteps number of steps of the multistep method
 * (excluding the one being computed)
 * @return P matrix
 */
private FieldMatrix<BigFraction> buildP(final int nSteps) {

    final BigFraction[][] pData = new BigFraction[nSteps][nSteps];

    for (int i = 0; i < pData.length; ++i) {
        // build the P matrix elements from Taylor series formulas
        final BigFraction[] pI = pData[i];
        final int factor = -(i + 1);
        int aj = factor;
        for (int j = 0; j < pI.length; ++j) {
            pI[j] = new BigFraction(aj * (j + 2));
            aj *= factor;
        }
    }

    return new Array2DRowFieldMatrix<BigFraction>(pData, false);

}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:32,代码来源:AdamsNordsieckTransformer.java


示例11: testQuadratic

import org.apache.commons.math3.fraction.BigFraction; //导入依赖的package包/类
@Test
public void testQuadratic() {
    FieldHermiteInterpolator<BigFraction> interpolator = new FieldHermiteInterpolator<BigFraction>();
    interpolator.addSamplePoint(new BigFraction(0), new BigFraction[] { new BigFraction(2) });
    interpolator.addSamplePoint(new BigFraction(1), new BigFraction[] { new BigFraction(0) });
    interpolator.addSamplePoint(new BigFraction(2), new BigFraction[] { new BigFraction(0) });
    for (double x = -10; x < 10; x += 1.0) {
        BigFraction y = interpolator.value(new BigFraction(x))[0];
        Assert.assertEquals((x - 1) * (x - 2), y.doubleValue(), 1.0e-15);
        BigFraction[][] derivatives = interpolator.derivatives(new BigFraction(x), 3);
        Assert.assertEquals((x - 1) * (x - 2), derivatives[0][0].doubleValue(), 1.0e-15);
        Assert.assertEquals(2 * x - 3, derivatives[1][0].doubleValue(), 1.0e-15);
        Assert.assertEquals(2, derivatives[2][0].doubleValue(), 1.0e-15);
        Assert.assertEquals(0, derivatives[3][0].doubleValue(), 1.0e-15);
    }
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:17,代码来源:FieldHermiteInterpolatorTest.java


示例12: testWikipedia

import org.apache.commons.math3.fraction.BigFraction; //导入依赖的package包/类
@Test
public void testWikipedia() {
    // this test corresponds to the example from Wikipedia page:
    // http://en.wikipedia.org/wiki/Hermite_interpolation
    FieldHermiteInterpolator<BigFraction> interpolator = new FieldHermiteInterpolator<BigFraction>();
    interpolator.addSamplePoint(new BigFraction(-1),
                                new BigFraction[] { new BigFraction( 2) },
                                new BigFraction[] { new BigFraction(-8) },
                                new BigFraction[] { new BigFraction(56) });
    interpolator.addSamplePoint(new BigFraction( 0),
                                new BigFraction[] { new BigFraction( 1) },
                                new BigFraction[] { new BigFraction( 0) },
                                new BigFraction[] { new BigFraction( 0) });
    interpolator.addSamplePoint(new BigFraction( 1),
                                new BigFraction[] { new BigFraction( 2) },
                                new BigFraction[] { new BigFraction( 8) },
                                new BigFraction[] { new BigFraction(56) });
    for (BigFraction x = new BigFraction(-1); x.doubleValue() <= 1.0; x = x.add(new BigFraction(1, 8))) {
        BigFraction y = interpolator.value(x)[0];
        BigFraction x2 = x.multiply(x);
        BigFraction x4 = x2.multiply(x2);
        BigFraction x8 = x4.multiply(x4);
        Assert.assertEquals(x8.add(new BigFraction(1)), y);
    }
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:26,代码来源:FieldHermiteInterpolatorTest.java


示例13: testCumulativeConstant

import org.apache.commons.math3.fraction.BigFraction; //导入依赖的package包/类
public void testCumulativeConstant() {
	Distribution c2 = new ConstantDistribution(2);
	Distribution d6 = new DieDistribution(6);
	Distribution d = SumDistribution.add(c2, d6);
	
	assertEquals(BigFraction.ONE, d.getCumulativeProbability(0));
	assertEquals(BigFraction.ONE, d.getCumulativeProbability(1));
	assertEquals(BigFraction.ONE, d.getCumulativeProbability(2));
	assertEquals(BigFraction.ONE, d.getCumulativeProbability(3));
	assertEquals(new BigFraction(5,6), d.getCumulativeProbability(4));
	assertEquals(new BigFraction(4,6), d.getCumulativeProbability(5));
	assertEquals(new BigFraction(3,6), d.getCumulativeProbability(6));
	assertEquals(new BigFraction(2,6), d.getCumulativeProbability(7));
	assertEquals(new BigFraction(1,6), d.getCumulativeProbability(8));
	assertEquals(BigFraction.ZERO, d.getCumulativeProbability(9));
	assertEquals(BigFraction.ZERO, d.getCumulativeProbability(10));
}
 
开发者ID:sizezero,项目名称:dice-probabilities,代码行数:18,代码来源:DistributionTest.java


示例14: exactK

import org.apache.commons.math3.fraction.BigFraction; //导入依赖的package包/类
/**
 * Calculates the exact value of {@code P(D_n < d)} using method described
 * in [1] and {@link org.apache.commons.math3.fraction.BigFraction} (see
 * above).
 *
 * @param d statistic
 * @return the two-sided probability of {@code P(D_n < d)}
 * @throws MathArithmeticException if algorithm fails to convert {@code h}
 * to a {@link org.apache.commons.math3.fraction.BigFraction} in expressing
 * {@code d} as {@code (k - h) / m} for integer {@code k, m} and
 * {@code 0 <= h < 1}.
 */
private double exactK(double d) throws MathArithmeticException {

    final int k = (int) Math.ceil(n * d);

    final FieldMatrix<BigFraction> H = this.createH(d);
    final FieldMatrix<BigFraction> Hpower = H.power(n);

    BigFraction pFrac = Hpower.getEntry(k - 1, k - 1);

    for (int i = 1; i <= n; ++i) {
        pFrac = pFrac.multiply(i).divide(n);
    }

    /*
     * BigFraction.doubleValue converts numerator to double and the
     * denominator to double and divides afterwards. That gives NaN quite
     * easy. This does not (scale is the number of digits):
     */
    return pFrac.bigDecimalValue(20, BigDecimal.ROUND_HALF_UP).doubleValue();
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:33,代码来源:KolmogorovSmirnovDistribution.java


示例15: testNegativeConstant

import org.apache.commons.math3.fraction.BigFraction; //导入依赖的package包/类
public void testNegativeConstant() {
	Distribution cn4 = new ConstantDistribution(-4);
	Distribution d6 = new DieDistribution(6);
	Distribution d = SumDistribution.add(cn4, d6);

	assertEquals(BigFraction.ZERO, d.getProbability(-6));
	assertEquals(BigFraction.ZERO, d.getProbability(-5));
	assertEquals(BigFraction.ZERO, d.getProbability(-4));
	assertEquals(new BigFraction(1,6), d.getProbability(-3));
	assertEquals(new BigFraction(1,6), d.getProbability(-2));
	assertEquals(new BigFraction(1,6), d.getProbability(-1));
	assertEquals(new BigFraction(1,6), d.getProbability(0));
	assertEquals(new BigFraction(1,6), d.getProbability(1));
	assertEquals(new BigFraction(1,6), d.getProbability(2));
	assertEquals(BigFraction.ZERO, d.getProbability(3));
	assertEquals(BigFraction.ZERO, d.getProbability(4));
}
 
开发者ID:sizezero,项目名称:dice-probabilities,代码行数:18,代码来源:DistributionTest.java


示例16: testTwoDSix

import org.apache.commons.math3.fraction.BigFraction; //导入依赖的package包/类
public void testTwoDSix() {
	Distribution d6 = new DieDistribution(6);
	Distribution twoDSix = SumDistribution.add(d6,d6);
	assertEquals(BigFraction.ZERO, twoDSix.getProbability(0));
	assertEquals(BigFraction.ZERO, twoDSix.getProbability(1));
	assertEquals(new BigFraction(1,36), twoDSix.getProbability(2));
	assertEquals(new BigFraction(2,36), twoDSix.getProbability(3));
	assertEquals(new BigFraction(3,36), twoDSix.getProbability(4));
	assertEquals(new BigFraction(4,36), twoDSix.getProbability(5));
	assertEquals(new BigFraction(5,36), twoDSix.getProbability(6));
	assertEquals(new BigFraction(6,36), twoDSix.getProbability(7));
	assertEquals(new BigFraction(5,36), twoDSix.getProbability(8));
	assertEquals(new BigFraction(4,36), twoDSix.getProbability(9));
	assertEquals(new BigFraction(3,36), twoDSix.getProbability(10));
	assertEquals(new BigFraction(2,36), twoDSix.getProbability(11));
	assertEquals(new BigFraction(1,36), twoDSix.getProbability(12));
	assertEquals(BigFraction.ZERO, twoDSix.getProbability(13));
	assertEquals(BigFraction.ZERO, twoDSix.getProbability(14));
	
	assertEquals(BigFraction.ONE, twoDSix.getCumulativeProbability(2));
}
 
开发者ID:sizezero,项目名称:dice-probabilities,代码行数:22,代码来源:DistributionTest.java


示例17: getDistribution

import org.apache.commons.math3.fraction.BigFraction; //导入依赖的package包/类
@Override
public Distribution getDistribution(SparseIntArray sidesToCount) {
	Distribution d = super.getDistribution(sidesToCount);

	// we need to adjust the cumulative distribution past it's lower bound
	// all the way to zero since failure always results if a the final
	// success fails rolled.
	// There is no 100% with this distribution.

	return ScaleCumulativeDistribution.scale(d, 0, d.upperBound(),
			new ScaleCumulativeDistribution.Scale() {
				public BigFraction scale(BigFraction pS, int x) {
					// P(S) = 1 - P(F)
					// P(new) = (1/6) * 0 + (5/6) * P(S)
					// P(new) = (5/6) * P(S)
					return success.multiply(pS);
				}
			});

}
 
开发者ID:sizezero,项目名称:dice-probabilities,代码行数:21,代码来源:FailureSpecial.java


示例18: Rational

import org.apache.commons.math3.fraction.BigFraction; //导入依赖的package包/类
public Rational(double d) {
  if (Math.abs(d) < 1e-15) {
    this.numerator = BigInteger.ZERO;
    this.denominator = BigInteger.ONE;

  } else {
    BigFraction fraction = new BigFraction(d);

    this.numerator = fraction.getNumerator();
    this.denominator = fraction.getDenominator();
  }
}
 
开发者ID:daergoth,项目名称:MatrixC,代码行数:13,代码来源:Rational.java


示例19: roundedK

import org.apache.commons.math3.fraction.BigFraction; //导入依赖的package包/类
/**
 * Calculates {@code P(D_n < d)} using method described in [1] and doubles
 * (see above).
 *
 * @param d statistic
 * @return the two-sided probability of {@code P(D_n < d)}
 * @throws MathArithmeticException if algorithm fails to convert {@code h}
 * to a {@link org.apache.commons.math3.fraction.BigFraction} in expressing
 * {@code d} as {@code (k - h) / m} for integer {@code k, m} and
 * {@code 0 <= h < 1}.
 */
private double roundedK(double d) throws MathArithmeticException {

    final int k = (int) FastMath.ceil(n * d);
    final FieldMatrix<BigFraction> HBigFraction = this.createH(d);
    final int m = HBigFraction.getRowDimension();

    /*
     * Here the rounding part comes into play: use
     * RealMatrix instead of FieldMatrix<BigFraction>
     */
    final RealMatrix H = new Array2DRowRealMatrix(m, m);

    for (int i = 0; i < m; ++i) {
        for (int j = 0; j < m; ++j) {
            H.setEntry(i, j, HBigFraction.getEntry(i, j).doubleValue());
        }
    }

    final RealMatrix Hpower = H.power(n);

    double pFrac = Hpower.getEntry(k - 1, k - 1);

    for (int i = 1; i <= n; ++i) {
        pFrac *= (double) i / (double) n;
    }

    return pFrac;
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:40,代码来源:KolmogorovSmirnovDistribution.java


示例20: AdamsNordsieckTransformer

import org.apache.commons.math3.fraction.BigFraction; //导入依赖的package包/类
/** Simple constructor.
 * @param n number of steps of the multistep method
 * (excluding the one being computed)
 */
private AdamsNordsieckTransformer(final int n) {

    final int rows = n - 1;

    // compute exact coefficients
    FieldMatrix<BigFraction> bigP = buildP(rows);
    FieldDecompositionSolver<BigFraction> pSolver =
        new FieldLUDecomposition<BigFraction>(bigP).getSolver();

    BigFraction[] u = new BigFraction[rows];
    Arrays.fill(u, BigFraction.ONE);
    BigFraction[] bigC1 = pSolver.solve(new ArrayFieldVector<BigFraction>(u, false)).toArray();

    // update coefficients are computed by combining transform from
    // Nordsieck to multistep, then shifting rows to represent step advance
    // then applying inverse transform
    BigFraction[][] shiftedP = bigP.getData();
    for (int i = shiftedP.length - 1; i > 0; --i) {
        // shift rows
        shiftedP[i] = shiftedP[i - 1];
    }
    shiftedP[0] = new BigFraction[rows];
    Arrays.fill(shiftedP[0], BigFraction.ZERO);
    FieldMatrix<BigFraction> bigMSupdate =
        pSolver.solve(new Array2DRowFieldMatrix<BigFraction>(shiftedP, false));

    // convert coefficients to double
    update         = MatrixUtils.bigFractionMatrixToRealMatrix(bigMSupdate);
    c1             = new double[rows];
    for (int i = 0; i < rows; ++i) {
        c1[i] = bigC1[i].doubleValue();
    }

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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java ContainerException类代码示例发布时间:2022-05-22
下一篇:
Java ArrayType类代码示例发布时间: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