01 /*
02 * $Id: BooleanMatrixFindSample3.java,v 1.8 2008/02/02 03:06:25 koga Exp $
03 *
04 * Copyright (C) 2004 Koga Laboratory. All rights reserved.
05 *
06 */
07 package matxbook.chap06;
08
09 import org.mklab.nfc.matrix.DoubleMatrix;
10 import org.mklab.nfc.matrix.IntMatrix;
11
12
13 /**
14 * 指定された条件を満たす行列成分を変更するサンプルです。
15 * @author koga
16 * @version $Revision: 1.8 $, 2004/04/14
17 */
18 public class BooleanMatrixFindSample3 {
19
20 /**
21 * メインメソッド
22 *
23 * @param args コマンドライン引数
24 */
25 @SuppressWarnings("nls")
26 public static void main(String[] args) {
27 DoubleMatrix a = new DoubleMatrix(new double[] {-1, 1, -2, 2});
28 IntMatrix index = a.compareElementWise(".<", 0).find();
29 DoubleMatrix b = a.getSubVector(index);
30 a.setSubVector(index, b.unaryMinus());
31 a.print("a(a .< 0) = - a(a .< 0)");
32 }
33 }
|