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


Java BigDecimal.pow方法代码示例

本文整理汇总了Java中java.math.BigDecimal.pow方法的典型用法代码示例。如果您正苦于以下问题:Java BigDecimal.pow方法的具体用法?Java BigDecimal.pow怎么用?Java BigDecimal.pow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.math.BigDecimal的用法示例。


在下文中一共展示了BigDecimal.pow方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sumCorrelationsOfBucket

import java.math.BigDecimal; //导入方法依赖的package包/类
static BigDecimal sumCorrelationsOfBucket(RiskClass riskClass, List<WeightedSensitivity> weightedSensitivities) {
  BigDecimal sum = BigDecimal.ZERO;

  for (WeightedSensitivity weightedSensitivityK : weightedSensitivities) {
    for (WeightedSensitivity weightedSensitivityI : weightedSensitivities) {
      if (weightedSensitivityI != weightedSensitivityK) {
        BigDecimal correlation = RiskCorrelation.getSensitivityCorrelation(riskClass, weightedSensitivityI.getSensitivity(), weightedSensitivityK.getSensitivity());
        BigDecimal squaredCorrelation = correlation.pow(2);
        BigDecimal value = squaredCorrelation.multiply(weightedSensitivityI.getWeightedValue()).multiply(weightedSensitivityK.getWeightedValue());
        sum = sum.add(value);
      }
    }
  }

  return sum;
}
 
开发者ID:AcadiaSoft,项目名称:simm-lib,代码行数:17,代码来源:CurvatureMarginBucketUtils.java

示例2: calculate

import java.math.BigDecimal; //导入方法依赖的package包/类
private static BigDecimal calculate(String input) {

        int i = 1;
        while (i < input.length() && !order.containsKey(input.charAt(i)))
            i++;

        String var = input.substring(0, i);
        BigDecimal value = variables.getOrDefault(var, new BigDecimal(var));

        char ope = i < input.length() ? input.charAt(0) : 0;
        if (ope == 0) return value;

        int currOrder = order.getOrDefault(ope, -1);

        BigDecimal result = null;
        if (currOrder > 0)
            result = calculate(input.substring(i + 1));

        switch (currOrder) {
            case '+':
                return value.add(result);
            case '-':
                return value.subtract(result);
            case '*':
                return value.multiply(result);
            case '/':
                return value.divide(result, BigDecimal.ROUND_HALF_UP);
            case '^':
                // If pow of int BigDecimal can handle it
                if (result.precision() == 0) return value.pow(result.intValue());
                // Otherwise we gotta revert to power of doubles
                return BigDecimal.valueOf(Math.pow(value.doubleValue(), result.doubleValue()));
        }

        return null;
    }
 
开发者ID:Baizey,项目名称:Helpers,代码行数:37,代码来源:Evaluator.java

示例3: sumCorrelationsAcrossBuckets

import java.math.BigDecimal; //导入方法依赖的package包/类
static BigDecimal sumCorrelationsAcrossBuckets(RiskClass riskClass, List<BucketWeightedAggregation> aggregateByBucket) {
  BigDecimal sum = ZERO;

  if (CollectionUtils.isNotEmpty(aggregateByBucket)) {
    for (BucketWeightedAggregation bucketAggregateB : aggregateByBucket) {
      for (BucketWeightedAggregation bucketAggregateC : aggregateByBucket) {
        if (!StringUtils.equals(bucketAggregateB.getBucket(), bucketAggregateC.getBucket())) {
          BigDecimal correlation = RiskCorrelation.getBucketCorrelation(riskClass, bucketAggregateB.getBucket(), bucketAggregateC.getBucket());
          BigDecimal squaredCorrelation = correlation.pow(2);

          BigDecimal bucketBSum = WeightedSensitivityUtils.sumWeightSensitivities(bucketAggregateB.getWeightedSensitivities());
          BigDecimal bucketBAggregate = bucketAggregateB.getAggregate();
          BigDecimal sb = bucketBSum.min(bucketBAggregate).max(bucketBAggregate.negate());

          BigDecimal bucketCSum = WeightedSensitivityUtils.sumWeightSensitivities(bucketAggregateC.getWeightedSensitivities());
          BigDecimal bucketCAggregate = bucketAggregateC.getAggregate();
          BigDecimal sc = bucketCSum.min(bucketCAggregate).max(bucketCAggregate.negate());

          BigDecimal product = squaredCorrelation.multiply(sb).multiply(sc);
          sum = sum.add(product);
        }
      }
    }
  }
  return sum;
}
 
开发者ID:AcadiaSoft,项目名称:simm-lib,代码行数:27,代码来源:CurvatureMarginAcrossBucketUtils.java

示例4: eval

import java.math.BigDecimal; //导入方法依赖的package包/类
private BigDecimal eval(Interpreter interpreter, HashMap<String, BigDecimal> arguments, HashSet<String> reserved) throws SyntaxException, ArithmeticException, StackOverflowError {
    if (value == null) {
        BigDecimal l = left.eval(interpreter, arguments);
        BigDecimal r = right.eval(interpreter, arguments);
        switch (operator) {
            case '-': return l.subtract(r);
            case '+': return l.add(r);
            case '*': return l.multiply(r);
            case '%': return l.remainder(r);
            case '/': return l.divide(r, interpreter.getInternalRounding(), RoundingMode.HALF_UP);
            case '^': return l.pow(r.intValue());
        }
    }
    if (reserved.contains(value))
        throw new SyntaxException("Variable '" + value + "' is reserved");
    if(arguments.containsKey(value))
        return arguments.get(value);

    HashMap<String, BigDecimal> variables = interpreter.getVariables();
    if(variables.containsKey(value))
        return variables.get(value);
    if (value.contains("(")) {
        HashMap<String, Function> functions = interpreter.getFunctions();
        String name = value.split("\\(")[0];
        if(!functions.containsKey(name)) throw new SyntaxException("Function '" + name + "' not defined");
        String args = value.substring(name.length() + 1, value.length() - 1);
        return functions.get(name).eval(interpreter, arguments, args);
    }
    if(value.matches("[0-9]+(\\.[0-9]*)?"))
        return new BigDecimal(value);
    throw new SyntaxException("Variable '" + value + "' not defined");
}
 
开发者ID:Baizey,项目名称:Helpers,代码行数:33,代码来源:ParserNode.java

示例5: sqrtNewtonRaphson

import java.math.BigDecimal; //导入方法依赖的package包/类
/**
 * Private utility method used to compute the square root of a BigDecimal.
 * See http://www.codeproject.com/Tips/257031/Implementing-SqrtRoot-in-BigDecimal
 * 
 * @author Luciano Culacciatti 
 */
private static BigDecimal sqrtNewtonRaphson(BigDecimal c, BigDecimal xn, BigDecimal precision){
    BigDecimal fx = xn.pow(2).add(c.negate());
    BigDecimal fpx = xn.multiply(new BigDecimal(2));
    BigDecimal xn1 = fx.divide(fpx, 2 * SQRT_DIG.intValue(), RoundingMode.HALF_DOWN);
    xn1 = xn.add(xn1.negate());
    BigDecimal currentSquare = xn1.pow(2);
    BigDecimal currentPrecision = currentSquare.subtract(c);
    currentPrecision = currentPrecision.abs();
    if(currentPrecision.compareTo(precision) <= -1){
        return xn1;
    }
    return sqrtNewtonRaphson(c, xn1, precision);
}
 
开发者ID:Panzer1119,项目名称:JAddOn,代码行数:20,代码来源:JBigNumber.java

示例6: localPow

import java.math.BigDecimal; //导入方法依赖的package包/类
public BigDecimal localPow(BigDecimal b, BigInteger pw, MathContext mc){
   
    BigInteger Threshold = new BigInteger("100000000");
    BigInteger Counter = Threshold;
    BigInteger Divider = BigInteger.ONE;
    if(pw.compareTo(Threshold)<=0)
         return b.pow(pw.intValueExact(), mc);
    
     
    while(Counter.compareTo(pw)<=0){
        Divider=Divider.add(BigInteger.ONE);
         Counter =Counter.add(Threshold);
    }
     Divider = Divider.subtract(BigInteger.ONE);
     Counter = Counter.subtract(Threshold);
     
     BigInteger Remainder = pw.subtract(Counter);
      
     return b.pow(Remainder.intValueExact(),jc.MC).multiply(localPow(b.pow(100000000,jc.MC),Divider,jc.MC),jc.MC);
     
     
}
 
开发者ID:mathhobbit,项目名称:EditCalculateAndChart,代码行数:23,代码来源:CalCpowl.java

示例7: square

import java.math.BigDecimal; //导入方法依赖的package包/类
public static BigDecimal square(BigDecimal b1) {
  return b1.pow(2);
}
 
开发者ID:AcadiaSoft,项目名称:simm-lib,代码行数:4,代码来源:BigDecimalUtils.java


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