Advertisement

Algorithm: Gauss-Jordan elimination of Matrices

阅读量:

近期正在复习线性代数,发现利用高斯消元法来构造阶梯形矩阵具有较高的实用性。因此,自行编写了一段代码,具体实现方式如下:

采用Python语言:

复制代码
 # by sesiria 2019

    
 # algorithm for Gaussian Elimination for square matrix.
    
 import numpy as np
    
  
    
 class MatrixIsSingular(Exception): pass
    
  
    
 # assume the input is a square matrix with the dimension m x n
    
 # return the echelon-form matrix of the input
    
 # otherwise throw a 'MatrixIsSingular' exception.
    
 def GaussianElimination(A):
    
     B = np.array(A, dtype=np.float_) # Make B as a copy of A, since we're going to alter it's values.
    
     # m = rows
    
     # n

全部评论 (0)

还没有任何评论哟~