rot

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

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

Parameters

c C

cos scalar

s S

sin scalar

x Slice!(Iterator1, N, kind1)

first n-dimensional tensor

y Slice!(Iterator2, N, kind2)

second n-dimensional tensor BLAS: SROT, DROT, CROT, ZROT, CSROT, ZDROTF

Examples

import mir.ndslice.allocation: slice;
auto x = slice!double(4);
auto y = slice!double(4);
auto a = slice!double(4);
auto b = slice!double(4);
double cos = 3.0 / 5;
double sin = 4.0 / 5;
x[] = [0, 1, 2, 3];
y[] = [4, 5, 6, 7];
foreach (i; 0 .. 4)
{
    a[i] = cos * x[i] + sin * y[i];
    b[i] = cos * y[i] - sin * x[i];
}
rot(cos, sin, x, y);
assert(x == a);
assert(y == b);

Meta