01 /*
02 * $Id: ListCompareElements4.java,v 1.8 2006/08/18 06:46:33 koga Exp $
03 *
04 * Copyright (C) 2004 Koga Laboratory. All rights reserved.
05 *
06 */
07 package matxbook.chap18;
08
09 import org.mklab.nfc.matrix.BooleanMatrix;
10 import org.mklab.nfc.matx.MatxList;
11
12
13 /**
14 * 複数の条件を満たすリストの成分を求めるサンプルです。
15 * @author koga
16 * @version $Revision: 1.8 $, 2004/04/21
17 */
18 public class ListCompareElements4 {
19
20 /**
21 * メインメソッド
22 *
23 * @param args コマンドライン引数
24 */
25 @SuppressWarnings("nls")
26 public static void main(String[] args) {
27 double[] aa = new double[] {1, 2.1, 3, 4.2, 5, 7.3, 9.4, 10.5};
28 MatxList a = new MatxList(aa.length);
29 for (int i = 0; i < aa.length; i++) {
30 a.set(i + 1, aa[i]);
31 }
32 BooleanMatrix bm1 = a.compareElementWise(3, ".>=");
33 BooleanMatrix bm2 = a.compareElementWise(9, ".<=");
34 BooleanMatrix bm3 = bm1.andElementWise(bm2);
35 MatxList b = a.getSubList(bm3.find());
36 b.print("a(3 .<= a && a .<= 9)");
37 }
38 }
|