#
Fortran Wiki

norm2

## Description

Calculates the Euclidean vector norm ($L_2$ norm) of `array`

along dimension `dim`

.

## Standard

Fortran 2008 and later

## Class

Transformational function

## Syntax

`result = norm2(array[, dim])`

## Arguments

`array`

- Shall be an array of type `real`

.
`dim`

- (Optional) shall be a scalar of type `integer`

with a value in the range from 1 to n, where n equals the rank of `array`

.

## Return value

The result is of the same type as `array`

.

If `dim`

is absent, a scalar with the square root of the sum of squares of the elements of `array`

is returned. Otherwise, an array of rank $n-1$, where $n$ equals the rank of `array`

, and a shape similar to that of `array`

with dimension `dim`

dropped is returned.

## Example

```
program test_norm2
real :: x(5) = [ real :: 1, 2, 3, 4, 5 ]
print *, norm2(x)
end program
```

## See also

product, sum, hypot

Revised on April 4, 2016 15:06:16
by

Jason Blevins
(128.146.137.52)
(1119 characters / 0.0 pages)