用初等行变换求矩阵的逆

这篇博客介绍了如何通过初等行变换的方法来求解矩阵的逆,这是高等代数中的一个重要理论知识,涉及线性代数的基础操作。
摘要由CSDN通过智能技术生成

高等代数的理论知识

(A | E) 经过初等行变换(E | A-1)(A-1 代表A的逆)

matrix_inv <- function(A)
{
  A_zhi <- Matrix::rankMatrix(A)[1]
  n_row <- dim(A)[1]
  n_col <- dim(A)[2]
  if((n_col==n_row)&(n_row == A_zhi))
  {
    B <- diag(1,n_col)
    col_index <- 1
    for(row_index in 1:(n_row - 1))
    {
      temp_col <- A[col_index:n_row,col_index]
    
      non_zreo_row <- which(temp_col!=0)[1]
      #一定找出当前行第一个元素不为零
      temp_row <- A[col_index,]
      A[col_index,] <- 
        A[col_index + non_zreo_row - 1,]
      A[col_index + non_zreo_row - 1,] <- temp_row 
      temp_row1 <- B[col_index,]
      B[col_index,] <- 
        B[col_index + non_zreo_row - 1,]
      B[col_index + non_zreo_row - 1,] <- temp_row1
      #其余的元素化零
      for(j in (col_index + 1):n_row)
      {
        temp_number <-
          A[j,col_index]/A[col_index,col_index
  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值