Prod
Trả về tích các phần tử của ma trận/vector, cũng có thể thực hiện cho trục được chỉ định.
cpp
double vector::Prod(
const double initial=1 // hệ số nhân ban đầu
);
double matrix::Prod(
const double initial=1 // hệ số nhân ban đầu
);
vector matrix::Prod(
const int axis, // trục
const double initial=1 // hệ số nhân ban đầu
);
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
Tham số
axis
[in] Trục. 0 — trục ngang, 1 — trục dọc.
initial=1
[in] Hệ số nhân ban đầu.
Ví dụ
cpp
matrix matrix_a={{10,3,2},{1,8,12},{6,5,4},{7,11,9}};
Print("matrix_a\n",matrix_a);
vector cols_prod=matrix_a.Prod(0);
vector rows_prod=matrix_a.Prod(1);
double matrix_prod=matrix_a.Prod();
Print("cols_prod=",cols_prod);
cols_prod=matrix_a.Prod(0,0.1);
Print("cols_prod=",cols_prod);
Print("rows_prod=",rows_prod);
Print("prod value ",matrix_prod);
/*
matrix_a
[[10,3,2]
[1,8,12]
[6,5,4]
[7,11,9]]
cols_prod=[420,1320,864]
cols_prod=[42,132,86.40000000000001]
rows_prod=[60,96,120,693]
prod value 479001600.0
*/
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24