En fortran pour obtenir l'indice correspondant à la valeur minimum d'un tableau en fortran il existe la fonction minloc(), exemple d'utilisation
program test_minlocimplicit nonereal, dimension(4,2) :: RR(1,1) = 4.0R(2,1) = 6.0R(3,1) = 3.0R(4,1) = 5.0R(1,2) = 7.0R(2,2) = 1.0R(3,2) = 8.0R(4,2) = 2.0write(6,*) minloc(R) ! Min tout le tableauwrite(6,*) minloc(R(:,1)) ! Min entre R(1,1), R(2,1), R(3,1), R(4,1)write(6,*) minloc(R(:,2)) ! Min entre R(1,2), R(2,2), R(3,2), R(4,2)write(6,*) minloc(R(1,:)) ! Min entre R(1,1) et R(1,2)end program test_minloc
donne
2 2321
Recherches associées
| Liens | Site |
|---|---|
| MINLOC — Location of the minimum value within an array | gcc doc |
| Using MINLOC with Fortran: Incompatible ranks 0 and 1 in assignment | stackoverflow |
| More on Arrays | Page perso |
