115.高斯消去: HPF 程序 |
REAL a(n,n), tmp(n)
!HPF$ DISTRIBUTE a(CYCLIC,CYCLIC)
!HPF$ ALIGN tmp(i) WITH a(*,i)
DO k = 1, n-1
! 选主元
ipivot = MAXLOC( ABS(a(k:n,k)) ) + k - 1
! 交换行
tmp(k:n) = a(ipivot, k:n)
a(ipivot, k:n) = a(k, k:n_
a(k,k:n) = tmp(k:n)
! 更新子阵
FORALL ( i=k+1:n, j=k+1:n ) &
& a(i,j) = a(i,k)/tmp(k)*tmp(j)
END DO
Copyright: NPACT |