wikipaom2017:051:030:000
Differenze
Queste sono le differenze tra la revisione selezionata e la versione attuale della pagina.
| Entrambe le parti precedenti la revisioneRevisione precedente | |||
| wikipaom2017:051:030:000 [2017/03/31 13:55] – [prodotto matrice - matrice , flessibile] ebertocchi | wikipaom2017:051:030:000 [2017/03/31 13:55] (versione attuale) – ebertocchi | ||
|---|---|---|---|
| Linea 1: | Linea 1: | ||
| + | ====== Routine ausiliarie ====== | ||
| + | ===== Matrici e vettori ===== | ||
| + | ==== Calcolo di determinante per matrici 2x2 o 3x3 ==== | ||
| + | < | ||
| + | c234567---------------------------------------------------------------72 | ||
| + | c===================== calcolo di determinante per matrici 2x2 o 3x3 === | ||
| + | c calcolo il determinante di una matrice di ordine 2 o 3 | ||
| + | c a : matrice della quale calcolare il determinante | ||
| + | c n : ordine della matrice | ||
| + | c det : determinante calcolato | ||
| + | c restituisce 'not a number' | ||
| + | c | ||
| + | subroutine detsm(a, | ||
| + | implicit none | ||
| + | integer n | ||
| + | double precision a(n,n),det | ||
| + | | ||
| + | if (n.eq.1) then | ||
| + | | ||
| + | else if (n.eq.2) then | ||
| + | | ||
| + | else if (n.eq.3) then | ||
| + | det= a(1, | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | else | ||
| + | | ||
| + | | ||
| + | | ||
| + | end if | ||
| + | | ||
| + | return | ||
| + | end subroutine | ||
| + | </ | ||
| + | ==== Calcolo dell' | ||
| + | |||
| + | < | ||
| + | c234567---------------------------------------------------------------72 | ||
| + | c============================== calcolo l' | ||
| + | c calcolo la matrice inversa di una matrice di ordine 2 o 3 | ||
| + | c a : matrice della quale calcolare il determinante | ||
| + | c n : ordine della matrice | ||
| + | c inva : matrice inversa calcolata | ||
| + | c restituisce una matrice 'not a number' | ||
| + | c | ||
| + | subroutine invsm(a, | ||
| + | implicit none | ||
| + | integer n | ||
| + | double precision a(n, | ||
| + | | ||
| + | c | ||
| + | call detsm(a, | ||
| + | | ||
| + | if (n.eq.1) then | ||
| + | | ||
| + | else if (n.eq.2) then | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | c | ||
| + | c TODO: inversa matrice 3x3! | ||
| + | c | ||
| + | else | ||
| + | | ||
| + | | ||
| + | | ||
| + | end if | ||
| + | | ||
| + | return | ||
| + | end subroutine | ||
| + | </ | ||
| + | |||
| + | ==== Assemblaggio matrice su matrice ==== | ||
| + | |||
| + | < | ||
| + | c234567---------------------------------------------------------------72 | ||
| + | c======================== mappa, scala e assembla matrice su matrice === | ||
| + | c | ||
| + | c INPUT: | ||
| + | c . sca : fattore scalare, double precision | ||
| + | c . a : matrice ma x na, double precision | ||
| + | c . b : matrice mb x nb, double precisione | ||
| + | c . imap : vettore di mappatura delle righe di a su b | ||
| + | c . jmap : vettore di mappatura delle colonne di a su b | ||
| + | c | ||
| + | c OUTPUT : | ||
| + | c | ||
| + | c b : modificata nei termini imap, | ||
| + | c con b( imap, jmap) = b(imap, | ||
| + | c e b(!imap, | ||
| + | c | ||
| + | c i termini di imap fuori range 1 <= imap(i) <= mb verranno trascurati | ||
| + | c i termini di jmap fuori range 1 <= jmap(j) <= nb verranno trascurati | ||
| + | c | ||
| + | subroutine assmbl(sca, | ||
| + | implicit none | ||
| + | integer ma, | ||
| + | double precision a(ma,na), b(mb, | ||
| + | |||
| + | do i=1,ma | ||
| + | if (imap(i) .ge. 1 .and. imap(i) .le. mb) then | ||
| + | do j=1,na | ||
| + | if (jmap(j) .ge. 1 .and. imap(i) .le. nb) then | ||
| + | b(imap(i), | ||
| + | end if | ||
| + | enddo | ||
| + | end if | ||
| + | enddo | ||
| + | |||
| + | return | ||
| + | end | ||
| + | </ | ||
| + | |||
| + | ==== prodotto matrice - matrice , flessibile ==== | ||
| + | |||
| + | < | ||
| + | c234567---------------------------------------------------------------72 | ||
| + | c=========================== prodotto matrice - matrice , flessibile === | ||
| + | c può essere usato con vettori | ||
| + | c | ||
| + | c ab = a . b | ||
| + | c | ||
| + | c a : matrice m x l double precision | ||
| + | c b : matrice l x n double precision | ||
| + | c ab: matrice m x n double precision | ||
| + | c | ||
| + | subroutine dot(m, | ||
| + | implicit none | ||
| + | integer m,n,l,i,j,k | ||
| + | double precision a(m, | ||
| + | | ||
| + | c | ||
| + | do i=1,m | ||
| + | do j=1,n | ||
| + | c | ||
| + | ab(i, | ||
| + | c | ||
| + | do k=1,l | ||
| + | | ||
| + | enddo | ||
| + | enddo | ||
| + | enddo | ||
| + | return | ||
| + | end | ||
| + | |||
| + | </ | ||
| + | ==== prodotto matrice trasposta - matrice , flessibile ==== | ||
| + | |||
| + | < | ||
| + | c234567---------------------------------------------------------------72 | ||
| + | c================= prodotto matrice trasposta - matrice , flessibile === | ||
| + | c può essere usato con vettori | ||
| + | c | ||
| + | c ab = a^T . b | ||
| + | c | ||
| + | c a : matrice m x l double precision | ||
| + | c b : matrice l x n double precision | ||
| + | c ab: matrice l x n double precision | ||
| + | c | ||
| + | subroutine tdot(m, | ||
| + | implicit none | ||
| + | integer m,n,l,i,j,k | ||
| + | double precision a(m, | ||
| + | | ||
| + | c | ||
| + | do i=1,l | ||
| + | do j=1,n | ||
| + | c | ||
| + | ab(i, | ||
| + | c | ||
| + | do k=1,m | ||
| + | | ||
| + | enddo | ||
| + | enddo | ||
| + | enddo | ||
| + | return | ||
| + | end | ||
| + | </ | ||
| + | ==== azzeramento matrice/ | ||
| + | |||
| + | |||
| + | < | ||
| + | c234567---------------------------------------------------------------72 | ||
| + | c======================================= azzeramento matrice/ | ||
| + | c passare un valore n pari al numero di celle totali allocate, | ||
| + | c ad es. 12 nel caso di una matrice 3x4 | ||
| + | c | ||
| + | subroutine dzero(a,n) | ||
| + | integer n,i | ||
| + | double precision a(n) | ||
| + | | ||
| + | do i=1,n | ||
| + | | ||
| + | enddo | ||
| + | | ||
| + | end subroutine | ||
| + | </ | ||
