01 /*
02 * $Id: PolynomialEvaluation.java,v 1.6 2008/02/15 14:54:18 koga Exp $
03 *
04 * Copyright (C) 2004 Koga Laboratory. All rights reserved.
05 *
06 */
07 package matxbook.chap17;
08
09 import org.mklab.nfc.scalar.DoubleComplexNumber;
10 import org.mklab.nfc.scalar.DoubleNumber;
11 import org.mklab.nfc.scalar.Polynomial;
12
13
14 /**
15 * @author koga
16 * @version $Revision: 1.6 $, 2004/04/19
17 */
18 public class PolynomialEvaluation {
19
20 /**
21 * メインメソッド
22 *
23 * @param args コマンドライン引数
24 */
25 @SuppressWarnings("nls")
26 public static void main(String[] args) {
27 Polynomial s = new Polynomial("s");
28 Polynomial p = s.power(2).multiply(3).add(s.multiply(4)).add(5);
29 double a = ((DoubleNumber)p.evaluate(2)).doubleValue();
30 System.out.println("a = " + a);
31 DoubleComplexNumber b = (DoubleComplexNumber)p.evaluate(new DoubleComplexNumber(1, 2));
32 b.print("b");
33 }
34 }
|