algoritmo indice di condizionamento per matrici

Messaggioda marygrazy » 01/06/2011, 16:51

ciao a tutti!

ho fatto un programma per calcolare l'indice di condizionamento per matrici ma mi da tre errori

1)error FOR3788: program has more than one MAIN unit

2)error FOR2942: symbol N is not permitted in a specification expression

3)error FOR2942: symbol N is not permitted in a specification expression


il programma è:


PROGRAM CONDIZIONAMENTO MATRICE

PARAMETER (N=4)
REAL h(N,N), t(N,N), k(N,N), v(N,N), w(N,N), z(N,N), cond
cond=0


WRITE (*,*) 'Studio indice di condizionamento delle matrici'
WRITE (*,*) 'di Toepliz, Vandermonde e Wilkinson per la'
WRITE (*,*) 'norma 1'

WRITE (*,*)

C CREAZIONE MATRICI

CALL hilbert(h, N)
CALL toepliz(t, N)
CALL toepliz2(z,N)
CALL vandermonde(v, N)
CALL wilkinson (w, N)

C CALCOLO E STAMPA DEL CONDIZIONAMENTO


WRITE (*,*)
WRITE (*,*) 'Indici di condizionamento'
CALL condz(h, N, cond)
WRITE (*,*) 'Hilbert : ', cond
CALL condz(t, N, cond)
WRITE (*,*) 'Toepliz d.d : ', cond
CALL condz(z, N, cond)
WRITE (*,*) 'Toepliz n.d.d: ', cond
CALL condz(v, N, cond)
WRITE (*,*) 'Vandermonde : ', cond
CALL condz(w, N, cond)
WRITE (*,*) 'Wilkinson : ', cond

END

C SUBROUTINE DEL CALCOLO DELLE NORME

SUBROUTINE norma (a, n, n1)

INTEGER n
REAL a(N,N), n1, x
n1=0
x=0
DO j=1, n
DO i=1, n
x = x + abs(a(i,j))
ENDDO
IF(x .gt. n1) THEN
n1 = x
ENDIF
x = 0
ENDDO

end

C SUBROUTINE condz (a, n, cond)
USE MSIMSL

REAL a(N,N), ainv(N,N), cond, n1, n1inv
PARAMETER (lda=4, ldainv=4)
CALL azzera(cond)
n1 = 0
c CALCOLO INVERSA
CALL LINRG (n, a, lda, ainv, ldainv)
c CALCOLO NORMA MATRICE
CALL norma(a, n, n1)
WRITE (*,*) 'Norma 1 : ', n1
c CALCOLO NORMA MATRICE INVERSA
CALL norma(ainv, n, n1inv)
WRITE (*,*) 'Norma 1 inversa: ', n1inv
c CALCOLO CONDIZIONAMENTO
cond = n1 * n1inv
END
SUBROUTINE azzera (x)
REAL x
x=0
END
c MATRICE HILBERT
SUBROUTINE hilbert (h, N)
INTEGER n,i,j
REAL h(N,N)
DO i=1, n
DO j=1, n
h(i,j) = 1./(i+j-1)
ENDDO
ENDDO
WRITE (*,*) 'Matrice di Hilbert:'
DO i=1, n
WRITE (*,*) (h(i,j), j=1, n)
ENDDO
END
c MATRICE TOEPLIZ DIAG. DOMINANTE
SUBROUTINE toepliz (t, N)
integer n,i,j
real vet(-(n-1):(n-1)),t(n,n)
do i=-(n-1), (n-1)
vet(i) = 1
enddo
write(*,*) 'Inserire vettore di 3 elementi per Toepliz d.d.'
read (*,*) (vet(i), i=-1, 1)
do i=1,n
do j=1,n
t(i,j)=vet(j-i)
enddo
enddo
write(*,*)'La matrice di Toepliz:'
DO i=1, n
WRITE (*,*) (t(i,j), j=1, n)
ENDDO
END
C MATRICE TOEPLIZ
SUBROUTINE toepliz2 (t, N)
integer n,i,j
real vet(-(n-1):(n-1)),t(n,N)
do i=-(n-1), (n-1)
vet(i) = 1
enddo
write(*,*) 'Inserire vettore di 3 elementi per Toepliz non d.d.'
read (*,*) (vet(i), i=-1, 1)
do i=1,n
do j=1,n
t(i,j)=vet(j-i)
enddo
enddo
write(*,*)'La matrice di Toepliz:'
DO i=1, n
WRITE (*,*) (t(i,j), j=1, n)
ENDDO
END

C MATRICE VANDERMONDE
SUBROUTINE vandermonde (k, N)
integer n,i,j
real k(n,n),vet(n),a,b,x
write(*,*) 'Inserire estremo a per la matrice Vandermonde'
read (*,*) a
write(*,*) 'Inserire estremo b per la matrice Vandermonde'
read (*,*) b
x = (b-a)/(n-1)
do i=1, n
vet(i) = a + (i-1)*x
enddo
do i=1,n
do j=1,n
k(i,j)=vet(i)**(j-1)
enddo
enddo
write(*,*)'La matrice di Vandermonde:'
DO i=1, n
WRITE (*,*) (k(i,j), j=1, n)
ENDDO
END

C MATRICE WILKINSON
SUBROUTINE wilkinson (w, n)
integer n,i,j
REAL w(n,n)
DO i=1, n
DO j=1, n
IF (i .eq. j) THEN
w(i,j) = 1
ELSE IF (i .gt. j) THEN
w(i,j) = (-1)**(j-i+1)
ELSE IF ((i .lt. j) .and. (j .eq. n)) THEN
w(i,j) = (-1)**i
ELSE
w(i,j) = 0
ENDIF
ENDDO
ENDDO
WRITE (*,*) 'La matrice di Wilkinson:'
DO i=1, n
WRITE (*,*) (w(i,j), j=1, n)
ENDDO
END

mi potreste aiutare a capire che errori commetto?perche non riesco a capire perche mi segna questi errori, a me sembrava giusto..
marygrazy
Junior Member
Junior Member
 
Messaggi: 175
Iscritto il: 28/05/2010, 11:24
Località: milazzo

Torna a Analisi Numerica e Ricerca Operativa

Chi c’è in linea

Visitano il forum: Nessuno e 0 ospiti

cron