硬汉嵌入式论坛

 找回密码
 立即注册
查看: 3464|回复: 2
收起左侧

[DSP] ARM DSP库的Gauss-Jordan法求逆矩阵

[复制链接]

1万

主题

6万

回帖

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
107077
QQ
发表于 2020-3-22 00:12:29 | 显示全部楼层 |阅读模式

这种方法最早被记载于中国的九章算术中。而在欧洲则是牛顿最先发现这种方法。Carl Friedrich Gauss(高斯)于1810年发明了一种在19世纪被广为接受的(特别是对于当时辛勤工作的手算员)的用于symmetric elimination的记法,这种记法被手算员们广泛应用于解决正常方程的最小二乘问题。而此词条的高斯-若尔当消元法的命名中的“若尔当”则来源于1888年德国数学家Wilhelm Jordan发现了这种高斯消元法的变体。有趣的是Clasen在同年出版的作品中也提到了相同的方法。这个事情更多地被认为是两人分别独立地发现了此方法。


QQ截图20200322001222.png



  1.     /*--------------------------------------------------------------------------------------------------------------
  2.      * Matrix Inverse can be solved using elementary row operations.
  3.      *
  4.      *  Gauss-Jordan Method:
  5.      *
  6.      *      1. First combine the identity matrix and the input matrix separated by a bar to form an
  7.      *        augmented matrix as follows:
  8.      *                      _                  _         _         _
  9.      *                     |  a11  a12 | 1   0  |       |  X11 X12  |
  10.      *                     |           |        |   =   |           |
  11.      *                     |_ a21  a22 | 0   1 _|       |_ X21 X21 _|
  12.      *
  13.      *      2. In our implementation, pDst Matrix is used as identity matrix.
  14.      *
  15.      *      3. Begin with the first row. Let i = 1.
  16.      *
  17.      *      4. Check to see if the pivot for column i is the greatest of the column.
  18.      *         The pivot is the element of the main diagonal that is on the current row.
  19.      *         For instance, if working with row i, then the pivot element is aii.
  20.      *         If the pivot is not the most significant of the columns, exchange that row with a row
  21.      *         below it that does contain the most significant value in column i. If the most
  22.      *         significant value of the column is zero, then an inverse to that matrix does not exist.
  23.      *         The most significant value of the column is the absolute maximum.
  24.      *
  25.      *      5. Divide every element of row i by the pivot.
  26.      *
  27.      *      6. For every row below and  row i, replace that row with the sum of that row and
  28.      *         a multiple of row i so that each new element in column i below row i is zero.
  29.      *
  30.      *      7. Move to the next row and column and repeat steps 2 through 5 until you have zeros
  31.      *         for every element below and above the main diagonal.
  32.      *
  33.      *      8. Now an identical matrix is formed to the left of the bar(input matrix, pSrc).
  34.      *         Therefore, the matrix to the right of the bar is our solution(pDst matrix, pDst).
  35.      *----------------------------------------------------------------------------------------------------------------*/
复制代码


回复

使用道具 举报

1万

主题

6万

回帖

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
107077
QQ
 楼主| 发表于 2020-3-22 11:25:56 | 显示全部楼层
ARM DSP库实现的代码有局限性,有些无法正常求解。
回复

使用道具 举报

4

主题

42

回帖

54

积分

初级会员

积分
54
发表于 2020-4-27 22:55:52 | 显示全部楼层
今天遇到一个矩阵求逆的问题,给大家提醒一下:
ARM DSP库里面的求逆函数arm_mat_inverse_f32(&mat_a, &mat_b)的时候,会改变前一个矩阵值。函数调用完后,mat_a就变成单位阵了。这点给大家提醒一下,如果后续有需要用到mat_a的时候,需要重新赋值。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|Archiver|手机版|硬汉嵌入式论坛

GMT+8, 2024-5-16 17:06 , Processed in 0.156699 second(s), 28 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表