Program main
Include 'link_fnl_shared.h' !//必须要写
use lin_sol_gen_int
use rand_gen_int
use error_option_packet
Implicit None
!// This is Example 1 for Lin_sol_gen
Integer,Parameter :: n = 32
Real( kind(1e0) ),Parameter :: one = 1e0
Real( kind(1e0) ) :: err
Real( kind(1e0) ) :: A(n,n), b(n,n), x(n,n), res(n,n), y(n*n)
!// Generate a random matrix
Call rand_gen(y)
A=reshape( y,[n,n] )
!// Genarate random right-hand sides
Call rand_gen(y)
b=reshape( y,[n,n] )
!// Compute the solution matrix of Ax = b
Call lin_sol_gen( A,b,x )
!// Check the result for small residuals
res=b - matmul( A,x )
err=maxval( abs(res) )/sum( abs(A)+abs(b) )
If (err<=sqrt( epsilon(one)) ) then
Print*, 'Example 1 for Lin_sol_gen is correct.'
End If
End Program
untitled.png (11.14 KB, 下载次数: 254)
PhoXo1.png (63.65 KB, 下载次数: 290)
欢迎光临 Fortran Coder (http://bbs.fcode.cn/) | Powered by Discuz! X3.2 |