本文整理汇总了Java中org.jscience.mathematics.number.Real类的典型用法代码示例。如果您正苦于以下问题:Java Real类的具体用法?Java Real怎么用?Java Real使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Real类属于org.jscience.mathematics.number包,在下文中一共展示了Real类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: JScience_IsPossibleToSolveForUnknownValueOfX_ReturnsTrue
import org.jscience.mathematics.number.Real; //导入依赖的package包/类
@Test
public void JScience_IsPossibleToSolveForUnknownValueOfX_ReturnsTrue(){
// Defines two local variables (x, y).
Variable<Real> varX = new Variable.Local<Real>("x");
Variable<Real> varY = new Variable.Local<Real>("y");
Variable<Real> varA = new Variable.Local<Real>("a");
// f(x) = ix² + 2x + 1
Polynomial<Real> x = Polynomial.valueOf(Real.ONE, varX);
Polynomial<Real> fx = x.pow(2).times(Real.valueOf(2)).plus(x.times(Real.valueOf(4)).plus(Real.valueOf(0.5)));
System.out.println(fx);
System.out.println(fx.pow(2));
System.out.println(fx.differentiate(varX));
System.out.println(fx.integrate(varY));
System.out.println(fx.compose(fx));
// TO DO: Solve for x.
// See: http://jscience.org/api/overview-summary.html#TUTORIAL
// // Calculates expression.
// varX.set(Complex.valueOf(2, 3));
// System.out.println(fx.evaluate());
}
示例2: convertFromXInY
import org.jscience.mathematics.number.Real; //导入依赖的package包/类
/**
* converts the given value from unit X to unit Y
*
* @param value the value to convert
* @param X the unit of value
* @param Y the unit value should be
* @return the converted value from X to Y
*/
public static Real convertFromXInY(Real value, Unit<? extends Quantity> X, Unit<? extends Quantity> Y) {
javax.measure.converter.UnitConverter converter = X.getConverterTo(Y);
double convert = converter.convert(value.doubleValue());
return Real.valueOf(convert);
}