Commit f456b83c authored by EdwinMindcraft's avatar EdwinMindcraft
Browse files

main + Makefile

parent 09cf7b9d
.idea/**
cmake-build-debug/**
\ No newline at end of file
cmake-build-debug/**
*.o
*.exe
*.mod
*.zip
\ No newline at end of file
FC = gfortran
OPT = -g
main: main.f gauss_seidel.o
$(FC) $(OPT) main.f gauss_seidel.o -o main
gauss_seidel.o: gauss_seidel.f
$(FC) $(OPT) gauss_seidel.f -c
\ No newline at end of file
2
0.000001
3 1 2 4
3 3
1 1
\ No newline at end of file
program main
use gauss_seidel
implicit none
integer i
real :: A(2,2), b(2), x(2)
A = reshape((/1, 0, 1, 2/), shape(A))
b = (/13, 11/)
x = (/1, 2/)
integer i, n
real, allocatable :: A(:,:), b(:), x(:)
real :: prec
read (*,*) n
read (*,*) prec
allocate(A(n,n))
allocate(b(n))
allocate(x(n))
read (*,*) A
read (*,*) b
read (*,*) x
do i=1,3000000
call solve_system(A, b, x)
if (norm2(matmul(A, x) - b) < 0.0001) then
if (norm2(matmul(A, x) - b) < prec) then
exit
endif
enddo
write(*,*) x, matmul(A, x)
end
write(*,*) x
write(*,*) matmul(A, x)
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment