01 /*
02 * $Id: MmFormatWrite.java,v 1.6 2008/02/02 05:53:02 koga Exp $
03 *
04 * Copyright (C) 2004 Koga Laboratory. All rights reserved.
05 *
06 */
07 package matxbook.chap14;
08
09 import java.io.FileWriter;
10 import java.io.IOException;
11 import java.io.Writer;
12
13 import org.mklab.nfc.matrix.DoubleMatrix;
14 import org.mklab.nfc.matx.MatxInteger;
15 import org.mklab.nfc.matx.MatxList;
16 import org.mklab.nfc.matx.MatxString;
17 import org.mklab.nfc.scalar.DoubleComplexNumber;
18
19
20 /**
21 * MaTXのmmファイルとしてデータを出力するサンプルです。
22 * @author koga
23 * @version $Revision: 1.6 $, 2004/04/29
24 */
25 public class MmFormatWrite {
26
27 /**
28 * メインメソッド
29 *
30 * @param args コマンドライン引数
31 * @throws IOException ファイルに出力できない場合
32 */
33 @SuppressWarnings("nls")
34 public static void main(String[] args) throws IOException {
35 int a = 1;
36 String b = "hello";
37 DoubleMatrix c = new DoubleMatrix(new double[][] { {1, 2}, {3, 4}});
38 MatxList d = new MatxList(new Object[] {Integer.valueOf(1), new Double(1.2), new DoubleComplexNumber(3, 4)});
39
40 Writer output = new FileWriter("data.mm");
41 MatxInteger.writeMmFormat(a, output, "a");
42 MatxString.writeMmFormat(b, output, "b");
43 c.writeMmFormat(output, "c", true);
44 d.writeMmFormat(output, "d", true);
45 output.close();
46 }
47 }
|