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
A _amax(A a, B b)
Undocumented in source. Be warned that the author may not have intended to support it.
_asum
A _asum(A a, B b)
Undocumented in source. Be warned that the author may not have intended to support it.
_fmuladd
A _fmuladd(A a, B b, C c)
Undocumented in source. Be warned that the author may not have intended to support it.
_fmuladdc
A _fmuladdc(A a, B b, C c)
Undocumented in source. Be warned that the author may not have intended to support it.
_nrm2
A _nrm2(A a, B b)
Undocumented in source. Be warned that the author may not have intended to support it.
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(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(C c, 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.

Templates

_axpy
template _axpy(alias a)
Undocumented in source.
_rot
template _rot(alias c, alias s)
Undocumented in source.

Examples

SWAP

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

SCAL

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

COPY

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

Meta

Authors

Ilya Yaroshenko