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 * 多項式の評価のサンプルです。
16 * @author koga
17 * @version $Revision: 1.6 $, 2004/04/19
18 */
19 public class PolynomialEvaluation {
20
21 /**
22 * メインメソッド
23 *
24 * @param args コマンドライン引数
25 */
26 @SuppressWarnings("nls")
27 public static void main(String[] args) {
28 Polynomial s = new Polynomial("s");
29 Polynomial p = s.power(2).multiply(3).add(s.multiply(4)).add(5);
30 double a = ((DoubleNumber)p.evaluate(2)).doubleValue();
31 System.out.println("a = " + a);
32 DoubleComplexNumber b = (DoubleComplexNumber)p.evaluate(new DoubleComplexNumber(1, 2));
33 b.print("b");
34 }
35 }
|