Logo

Programming-Idioms

History of Idiom 202 > diff from v1 to v2

Edit summary for version 2 by spectrum:
New Fortran implementation by user [spectrum]

Version 1

2019-09-28, 20:37:11

Version 2

2019-09-28, 21:33:13

Idiom #202 Sum of squares

Calculate the sum of squares s of data, an array of floating point values.

Idiom #202 Sum of squares

Calculate the sum of squares s of data, an array of floating point values.

Code
real, allocatable :: data(:)
...
s = sum( data**2 )
Comments bubble
data may be a multidimensional array (e.g. data(:,:)).