GetSubで行列の一部を抜き出し
{
gROOT->Reset();
TMatrixD m, n;
m.ResizeTo(3,3,-1);
n.ResizeTo(3,3,-1);
m[0][0] = 1.0; m[0][1] = 2.0; m[0][2] = 3.0;
m[1][0] = 4.0; m[1][1] = 8.0; m[1][2] = 6.0;
m[2][0] = 7.0; m[2][1] = 8.0; m[2][2] = 9.0;
n.Print();//3*3のまま
n += m.GetSub(0,1,0,1,"S");//"S"は省略可
n.Print();//2*2に縮小される
m.Print();
}
実行結果
3x3 matrix is as follows
| 0 | 1 | 2 |
------------------------------------------------------------------
0 | 0 0 0
1 | 0 0 0
2 | 0 0 0
2x2 matrix is as follows
| 0 | 1 |
------------------------------------------------------------------
0 | 1 2
1 | 4 8
3x3 matrix is as follows
| 0 | 1 | 2 |
------------------------------------------------------------------
0 | 1 2 3
1 | 4 8 6
2 | 7 8 9
gROOT->Reset();
TMatrixD m, n;
m.ResizeTo(3,3,-1);
n.ResizeTo(3,3,-1);
m[0][0] = 1.0; m[0][1] = 2.0; m[0][2] = 3.0;
m[1][0] = 4.0; m[1][1] = 8.0; m[1][2] = 6.0;
m[2][0] = 7.0; m[2][1] = 8.0; m[2][2] = 9.0;
n.Print();//3*3のまま
n += m.GetSub(0,1,0,1,"S");//"S"は省略可
n.Print();//2*2に縮小される
m.Print();
}
実行結果
3x3 matrix is as follows
| 0 | 1 | 2 |
------------------------------------------------------------------
0 | 0 0 0
1 | 0 0 0
2 | 0 0 0
2x2 matrix is as follows
| 0 | 1 |
------------------------------------------------------------------
0 | 1 2
1 | 4 8
3x3 matrix is as follows
| 0 | 1 | 2 |
------------------------------------------------------------------
0 | 1 2 3
1 | 4 8 6
2 | 7 8 9
0 Comments:
コメントを投稿
<< Home