axpy

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

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

Parameters

a A

scale parameter

x Slice!(Iterator1, N, kind1)

first n-dimensional tensor

y Slice!(Iterator2, N, kind2)

second n-dimensional tensor BLAS: SAXPY, DAXPY, CAXPY, ZAXPY

Examples

SAXPY, DAXPY

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

SAXPY, DAXPY

import mir.ndslice.allocation: slice;

auto a = 3 + 4i;
auto x = slice!cdouble(2);
auto y = slice!cdouble(2);
x[] = [0 + 1i, 2 + 3i];
y[] = [4 + 5i, 6 + 7i];
axpy(a, x, y);
assert(y == [a * (0 + 1i) + (4 + 5i), a * (2 + 3i) + (6 + 7i)]);

Meta