2024年4月3日发(作者:)

!

subroutine Lsqnonneg(A,b,x,m,n)

!

!代码文件调用方式:

!call Lsqnonneg(A,b,x,m,n)

!求解方程组 Ax=b

!其中系数矩阵 A 为 m×n 的矩阵,

!本算法对于 m> n时(即超定方程组)有效。

!m

!*****************

! 用最小二乘法计算方程组

! 传进来 Amatrix Bvector

use constants

use vars_fangchengzu_shuju

!use qiujie_jieguo

implicit none

integer, intent(in) :: m,n

logical, allocatable :: p(:),r(:)

real, allocatable :: w(:),s(:)

real,intent(in),dimension(m,n) :: A

real,intent(in),dimension(m) :: b

real,intent(inout),dimension(n) :: x

real, allocatable :: AT(:,:),bAx(:)

! transpose of A

! b-Ax

real, allocatable :: norm_lie(:)