sqnrm2

Forms the square of the euclidean norm. Uses unrolled loops for stride equal to one.

  1. F sqnrm2(Slice!(Iterator, N, kind) x)
    @fastmath
    F
    sqnrm2
    (
    F
    SliceKind kind
    size_t N
    Iterator
    )
    (
    Slice!(Iterator, N, kind) x
    )
  2. auto sqnrm2(Slice!(Iterator, N, kind) x)

Parameters

F

type for summation (optional template parameter)

x Slice!(Iterator, N, kind)

n-dimensional tensor

Return Value

Type: F

conj(xᐪ) × x

Examples

import mir.ndslice.allocation: slice;
auto x = slice!double(4);
x[] = [0, 1, 2, 3];
assert(sqnrm2(x) == 1.0 + 4 + 9);
import mir.ndslice.allocation: slice;

auto x = slice!cdouble(2);
x[] = [0 + 1i, 2 + 3i];

assert(sqnrm2(x) == 1.0 + 4 + 9);

Meta