我正致力于高斯消除(我正试图将矩阵转换成行梯队形式),并立即研究一些可能对我有帮助的来源。我在维基百科上找到了一个伪码,它与高斯消去函数有关。
h := 1 /* Initialization of the pivot row */
k := 1 /* Initialization of the pivot column */
while h ≤ m and k ≤ n
/* Find the k-th pivot: */
i_max := argmax (i = h ... m, abs(A[i, k]))
if A[i_max, k] = 0
/* No pivot in this column, pass to next column */
k := k+1
else
swap rows(h, i_max)
/* Do for all rows below pivot: */
for i = h + 1 ... m:
f := A[i, k] / A[h, k]
/* Fill with zeros the lower part of pivot column: */
A[i, k] := 0
/* Do for all remaining elements in current row: */
for j = k + 1 ... n:
A[i, j] := A[i, j] - A[h, j] * f
/* Increase pivot row and column */
h := h + 1
k := k + 1我不确定如何实现伪代码第6行中所述的argmax函数。
发布于 2021-09-28 14:02:29
我将表达式argmax(i = h ... m, abs(A[i, k]))解释为
“查找索引i,它使表达式
abs(A[i,k])在h.m范围内最大化”。
换句话说就是。在我(从H ..。( m)并找到abs(Ai,k)的最大值,其中k是一个常数值(来自包含的循环),返回索引'i'。
// inline implementation of `argmax_abs_a_ik` inside while loop
int i_max = h;
for (int i = h; i <= m; i++) {
if (Math.abs(A[i,k]) > Math.abs(A[i_max,k])) {
i_max = i;
}
}
// i_max contains resulthttps://stackoverflow.com/questions/69361123
复制相似问题