Documentos de Académico
Documentos de Profesional
Documentos de Cultura
IMPLICIT NONE
INTEGER, PARAMETER :: dbl = SELECTED_REAL_KIND(p = 15)
REAL(KIND=dbl),ALLOCATABLE,dimension(:,:):: a, invA,y
REAL(KIND=dbl),ALLOCATABLE,dimension(:)::b, x,z,u
REAL(KIND=dbl):: l,P,t,v,h
CHARACTER NOMBRE*30
Integer:: sal, errorflag, i, j, n, FLAG,np,m,mp,k,nn
!Definicin de ndices
nn=n
WRITE(*,51,advance = 'no')
51 FORMAT(3X,'Ingrese 1 o 2 segun lo desee => ')
READ (*,*) flag
P=0
do i=1,n
P = log(x(i)) + P
end do
A(1,2)=P
A(2,1)=P
P=0
do i=1,n
P = log(x(i))**2 + P
end do
A(2,2) = P
P=0
do i=1,n
P = log(y(i,1)) + P
end do
b(1) = P
P=0
do i=1,n
P = log(x(i))*log(y(i,1)) + P
end do
b(2) = P
! Presentacin de la matriz A
write(sal,*) ' '
write(sal,300)
300 format(3x,'La matriz A generada es: ')
DO i = 1,2
write (sal,8) (A(i,j), j = 1,2)
8 format (8(3X, F10.4))
END DO
WRITE(sal,*)' '
! Presentacin del vector b
n = 2
m = n
np = n
mp = n
h=(t-v)/25
!vector z
Do i=1,26
z(i)=v+(h*(i-1))
end do
pause
end program MinPotencia
!
*************************************************************************
******
SUBROUTINE gaussj(a,n,np,b,m,mp)
INTEGER m,mp,n,np,NMAX
!REAL a(np,np),b(np,mp)
double precision a(np,np), b(np,mp), x(n)
PARAMETER (NMAX=50)
!Linear equation solution by Gauss-Jordan elimination, equation (2.1.1)
above. a(1:n,1:n)
!is an input matrix stored in an array of physical dimensions np by np.
b(1:n,1:m) is an input
!matrix containing the m right-hand side vectors, stored in an array of
physical dimensions
!np by mp. On output, a(1:n,1:n) is replaced by its matrix inverse, and
b(1:n,1:m) is
!replaced by the corresponding set of solution vectors.
!Parameter: NMAX is the largest anticipated value of n.
INTEGER i,icol,irow,j,k,l,ll,indxc(NMAX),indxr(NMAX),&
ipiv(NMAX) !The integer arrays ipiv, indxr, and indxc are
used
REAL big,dum,pivinv !for bookkeeping on the pivoting.
do j=1,n
ipiv(j)=0
end do
do l=1,m
dum=b(irow,l)
b(irow,l)=b(icol,l)
b(icol,l)=dum
end do
end if
indxr(i)=irow !We are now ready to divide the pivot row by the pivot
indxc(i)=icol !element, located at irow and icol.
if (a(icol,icol).eq.0.) pause 'singular matrix in gaussj'
pivinv=1./a(icol,icol)
a(icol,icol)=1.
do l=1,n
a(icol,l)=a(icol,l)*pivinv
end do
do l=1,m
b(icol,l)=b(icol,l)*pivinv
end do
do l=1,m
b(ll,l)=b(ll,l)-b(icol,l)*dum
end do
end if
end do
end do !This is the end of the main loop over columns of the
reduction.
do l=n,1,-1 !It only remains to unscramble the solution in view
!of the column interchanges. We do this by interchanging
!pairs of columns in the reverse order
!that the permutation was built up.
if(indxr(l).ne.indxc(l))then
do k=1,n
dum=a(k,indxr(l))
a(k,indxr(l))=a(k,indxc(l))
a(k,indxc(l))=dum
end do
end if
end do
return !And we are done.
END