Anonymous user
Averages/Arithmetic mean: Difference between revisions
m
→{{header|Fortran}}
Line 129:
=={{header|Fortran}}==
In ISO Fortran 90 or later, use the SUM intrinsic, the SIZE intrinsic and the MAX intrinsic (to avoid divide by zero):
! MAX of SIZE and 1 prevents divide by zero if SIZE == 0 (zero-length array)
! expression becomes "0 / MAX( 0, 1 ) -> 0 / 1 -> 0", rather than "0 / 0 -> NaN"
! dividing by the length of the row, which is the number of columns (SIZE of dimension 2)
! dividing by the length of the column, which is the number of rows (SIZE of dimension 1)
|