mir.glas.l1

Level 1

This is a submodule of mir.glas.

The Level 1 GLAS perform vector and vector-vector operations.

Vector-vector operations

rotapply Givens rotation
axpyconstant times a vector plus a vector
dotdot product
dotcdot product, conjugating the first vector

Vector operations

Function NameDescription
nrm2Euclidean norm
sqnrm2square of Euclidean norm
asumsum of absolute values
iamaxindex of max abs value
amaxmax abs value

All functions except iamax work with multidimensional tensors.

GLAS does not provide swap, scal, and copy functions. This functionality is part of ndslice package. Examples can be found below.

Members

Functions

amax
auto amax(Slice!(Iterator, N, kind) x)

Takes the sum of the |Re(.)| + |Im(.)|'s of a vector and returns a single precision result.

asum
auto asum(Slice!(Iterator, N, kind) x)

Takes the sum of the |Re(.)| + |Im(.)|'s of a vector and returns a single precision result.

asum
F asum(Slice!(Iterator, N, kind) x)

Takes the sum of the |Re(.)| + |Im(.)|'s of a vector and returns a single precision result.

axpy
void axpy(in A a, Slice!(Iterator1, N, kind1) x, Slice!(Iterator2, N, kind2) y)

Constant times a vector plus a vector. Uses unrolled loops for strides equal to one.

dot
F dot(Slice!(Iterator1, N, kind1) x, Slice!(Iterator2, N, kind2) y)
auto dot(Slice!(Iterator1, N, kind1) x, Slice!(Iterator2, N, kind2) y)

Forms the dot product of two vectors. Uses unrolled loops for strides equal to one.

dotc
F dotc(Slice!(Iterator1, N, kind1) x, Slice!(Iterator2, N, kind2) y)
auto dotc(Slice!(Iterator1, N, kind1) x, Slice!(Iterator2, N, kind2) y)

Forms the dot product of two complex vectors. Uses unrolled loops for strides equal to one.

iamax
sizediff_t iamax(Slice!(Iterator, 1, kind) x)

Finds the index of the first element having maximum |Re(.)| + |Im(.)|. Return: index of the first element having maximum |Re(.)| + |Im(.)|

nrm2
F nrm2(Slice!(Iterator, N, kind) x)
auto nrm2(Slice!(Iterator, N, kind) x)

Returns the euclidean norm of a vector. Uses unrolled loops for stride equal to one.

rot
void rot(in C c, in S s, Slice!(Iterator1, N, kind1) x, Slice!(Iterator2, N, kind2) y)

Applies a plane rotation, where the c (cos) and s (sin) are scalars. Uses unrolled loops for strides equal to one.

sqnrm2
F sqnrm2(Slice!(Iterator, N, kind) x)
auto sqnrm2(Slice!(Iterator, N, kind) x)

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

Examples

SWAP

1 import std.algorithm.mutation: swap;
2 import mir.ndslice.allocation: slice;
3 import mir.algorithm.iteration: each;
4 import std.typecons: Yes;
5 auto x = slice!double(4);
6 auto y = slice!double(4);
7 x[] = [0, 1, 2, 3];
8 y[] = [4, 5, 6, 7];
9 each!(swap)(x, y);
10 assert(x == [4, 5, 6, 7]);
11 assert(y == [0, 1, 2, 3]);

SCAL

1 import mir.ndslice.allocation: slice;
2 import std.typecons: Yes;
3 auto x = slice!double(4);
4 x[] = [0, 1, 2, 3];
5 x[] *= 2.0;
6 assert(x == [0, 2, 4, 6]);

COPY

1 import mir.ndslice.allocation: slice;
2 auto x = slice!double(4);
3 auto y = slice!double(4);
4 x[] = [0, 1, 2, 3];
5 y[] = x;
6 assert(y == [0, 1, 2, 3]);

Meta

Authors

Ilya Yaroshenko