algorithm - 这个高斯消元伪代码的第一步是否正确?

标签 algorithm math equation-solving

算法的第一步应该如下所示吗?

// find the element with largest absolute value in col p and below row p-1

所以不是所有的 col p 只是它的一部分。

算法:

  for p = 1 to n do
    // find the element with largest absolute value in col p <-first step
    // if max is zero, stop!
    // if max element not in row p, swap rows
    // set pivot element to 1
    multiply row p by 1/A[p][p]
    // clear lower column entries
    for r = p+1 to n do
        subtract row p times A[r,p] from current row,
        so that element in pivot column becomes 0
        // do backwards substitution
  for row = n-1 to 1
      for col = row+1 to n
          // subtract out known quantities
          b[row] = b[row] - A[row][col]*b[col]

编辑:

我们有矩阵 A。算法从第一步开始,p=3。我的问题是:我应该从 {5,3,2,-1}(所有元素 od col p)或 {2,-1}(仅来自 col p 的第 p-1 行下方的元素)中选择最大的元素?

[1 2 5 3]

[0 1 3 4]

[0 0 2 2] = A

[0 0 -1 1]

最佳答案

是的,这一步是正确的。前 p - 1 行中已经有主元变量。根据高斯消元算法,新的主元必须在不同的行。

一个简单的例子:

如果你有一个 2x2 矩阵,第一行已经被处理,矩阵看起来像

[1, 2] 
[0, 1]

您显然需要选择 (2, 2) 元素作为第二列的基准,而不是 (1, 2)。

关于algorithm - 这个高斯消元伪代码的第一步是否正确?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40388100/

相关文章:

c++ - 如何找到改变偏航时风力涡轮机叶片形成的角度?

c++ - 解方程。计数 (x,y)

matlab - 解方程组时出错

python - 求解模方程 (Python)

ruby - 基于权重的服务器页面

algorithm - "in-place"到底是什么意思?

javascript - 如何在 JavaScript 中显示整数?

algorithm - 与另一条线和另一个圆相切的圆

algorithm - 区 block 链和不可变链表有什么区别?

algorithm - 用 3 个灯泡的窗口打开所有灯泡