! EXAMPLE 1
!
real,dimension(1000)::a=(/(i,i=1,1000)/)
real,dimension(1000)::b,c
b=a
c=a+b
print *, c
end


! EXAMPLE 2
!
real,dimension(10,10)::a=(/((i+j,i=1,10),j=1,10)/)
real,dimension(10,10)::b,c
b=a
c=a+b
print *, c
end



! EXAMPLE 3
!
real,dimension(10,10)::a=(/((i+2*j,i=1,10),j=1,10)/)
real,dimension(10,10)::b,c
b=sqrt(a)
c=a+b
print *, c
end

! EXAMPLE 4
!
! Aprogram to compute the largest eigenvalue
! of a real, dense matrix by the power method

integer, parameter::devno=10, n=10, minit = 10, maxit=100
real::lambda_old, lambda_new
real::rel_err, tol = 2.0**(-20)
real,dimension(n)::x_new, x_old=(/(1.0/n,i=1,n)/)
real,dimension(n,n)::a
open(devno, file='a.dat')
read(10,10) ((a(i,j),j=1,n),i=1,n)
10 format(10f4.1)
iterate: do i=1,maxit
   write (*,*) "i = ", i
   x_new=matmul(a, x_old)
   lambda_new = sqrt(dot_product(x_new, x_new))
   write(*,*) "lambda_new = ", lambda_new
   if (i .gt. minit) then
      rel_err = abs((lambda_new - lambda_old)/lambda_old)
      if (rel_err .lt. tol) exit iterate
   endif
   if (i .eq. maxit) write (*,*) "Maximum Iterations reached"
   lambda_old = lambda_new
   x_old = x_new/lambda_new
end do iterate
write(*,*) "lambda = ", lambda_new
end