5#include <src/math-helpers.hh>
9#include <sycl/sycl.hpp>
28 const T*
ptr =
nullptr;
48template <
typename Ops,
typename T>
51 for (
int t = 0; t < nrot; ++t) {
52 Ops::rot_pair(x[t], y[t], c[t], s[t]);
56template <
typename Ops,
typename T>
58 for (
int t = 0; t < nrot; ++t) {
61 typename Ops::Real ct =
typename Ops::Real(0);
64 Ops::lartg(f, g, ct, st, rt);
73 if constexpr (internal::is_complex<T>::value) {
74 return T(x.real(),
typename T::value_type(0));
80template <typename T, bool IsComplex = internal::is_complex<T>::value>
88 static inline void lartg(
const T& f_in,
const T& g_in,
Real& c, T& s, T& r) {
89 auto [ct, st, rt] = internal::lartg(f_in, g_in);
96 const Real s =
static_cast<Real>(s_in);
97 const Real xt =
static_cast<Real>(x);
98 const Real yt =
static_cast<Real>(y);
99 x = T(c * xt + s * yt);
100 y = T(c * yt - s * xt);
104 for (
int t = 0; t < nrot; ++t) {
122 const Real xi =
static_cast<Real>(x);
123 const Real yi =
static_cast<Real>(y);
124 const Real zi =
static_cast<Real>(z);
125 const Real si =
static_cast<Real>(si_in);
127 const Real t1 = si * zi;
128 const Real t2 = ci * zi;
129 const Real t3 = t2 - si * xi;
130 const Real t4 = t2 + si * yi;
131 const Real t5 = ci * xi + t1;
132 const Real t6 = ci * yi - t1;
134 x = T(ci * t5 + si * t4);
135 y = T(ci * t6 - si * t3);
136 z = T(ci * t4 - si * t5);
145 for (
int t = 0; t < nrot; ++t) {
158 auto diag = AB(int32_t(0),
Slice{});
159 auto sub = AB(int32_t(1),
Slice{});
160 for (
int j = 0; j < n; ++j) {
161 D[j] =
static_cast<Real>(diag[j]);
163 E[j] =
static_cast<Real>(sub[j]);
175 static inline void lartg(
const T& f,
const T& g,
Real& c, T& s, T& r) {
176 auto [ct, st, rt] = internal::lartg(f, g);
185 x = T(c) * xt + s * yt;
190 for (
int t = 0; t < nrot; ++t) {
209 const Real xi =
static_cast<Real>(x.real());
210 const Real yi =
static_cast<Real>(y.real());
213 const Real zir =
static_cast<Real>(zi.real());
214 const Real zii =
static_cast<Real>(zi.imag());
216 const Real sir =
static_cast<Real>(si.real());
217 const Real sii =
static_cast<Real>(si.imag());
219 const Real t1r = sir * zir - sii * zii;
220 const Real t1i = sir * zii + sii * zir;
222 const T t2 = T(ci * zir, ci * zii);
226 const Real t5 = ci * xi + t1r;
227 const Real t6 = ci * yi - t1r;
229 const Real xnew = ci * t5 + (sir *
static_cast<Real>(t4.real()) + sii *
static_cast<Real>(t4.imag()));
230 const Real ynew = ci * t6 - (sir *
static_cast<Real>(t3.real()) - sii *
static_cast<Real>(t3.imag()));
233 x = T(xnew,
Real(0));
234 y = T(ynew,
Real(0));
244 for (
int t = 0; t < nrot; ++t) {
251 for (
int t = 0; t < nrot; ++t) {
258 for (
int j = 0; j < n; ++j) {
259 const int idx = 0 + j * ldab;
269 auto diag = AB(int32_t(0),
Slice{});
270 auto sub = AB(int32_t(1),
Slice{});
273 for (
int j = 0; j < n; ++j) {
278 for (
int j = 0; j < n - 1; ++j) {
280 const Real a = internal::abs(t);
286 sub[j] = T(a,
Real(0));
293 for (
int j = 0; j < n; ++j) {
294 D[j] =
static_cast<Real>(real_part(diag[j]));
311#define BTRD_LOWER_INPLACE_SUBGROUP_DISPATCH_EXTERN(fp, real_fp) \
312extern template Event btrd_lower_inplace_subgroup_dispatch<BATCHLAS_UNPAREN fp>(Queue&, \
313 KernelMatrixView<BATCHLAS_UNPAREN fp, MatrixFormat::Dense>, \
316 VectorView<BATCHLAS_UNPAREN real_fp>, \
317 VectorView<BATCHLAS_UNPAREN fp>, \
318 VectorView<BATCHLAS_UNPAREN real_fp>, \
319 VectorView<BATCHLAS_UNPAREN real_fp>, \
320 VectorView<BATCHLAS_UNPAREN fp>);
324#undef BTRD_LOWER_INPLACE_SUBGROUP_DISPATCH_EXTERN
Non-owning view of a batch of strided vectors: the vector argument type of the entry points.
The batched containers: Matrix (owning), MatrixView (non-owning), KernelMatrixView (device-side),...
constexpr T conj(const T &value)
StridedView< T > make_strided(T *ptr, int inc)
void lartv_impl(int nrot, StridedView< T > x, StridedView< T > y, ConstStridedView< typename Ops::Real > c, ConstStridedView< T > s)
Event btrd_lower_inplace_subgroup_dispatch(Queue &q, KernelMatrixView< T, MatrixFormat::Dense > ab, int n, int kd, VectorView< typename base_type< T >::type > c, VectorView< T > work, VectorView< typename base_type< T >::type > d, VectorView< typename base_type< T >::type > e, VectorView< T > tau)
void largv_impl(int nrot, StridedView< T > x, StridedView< T > w, StridedView< typename Ops::Real > c)
ConstStridedView< T > make_const_strided(T *ptr, int inc)
Completion handle of enqueued work, returned by every entry point.
Trivially copyable view of a MatrixView for use inside a SYCL kernel.
Where BatchLAS work runs: a device, a backend, an ordered SYCL queue and a workspace arena.
A half-open index range [start, end) along one dimension.
const T & operator[](int i) const
T & operator[](int i) const
static void largv(int nrot, StridedView< T > x, StridedView< T > w, StridedView< Real > c)
static void ensure_band_diag_real(T *, int, int)
static void finalize_tridiag(const KernelMatrixView< T, MatrixFormat::Dense > &AB, int n, VectorView< Real > D, VectorView< Real > E, VectorView< T > TAU)
static void lartv(int nrot, StridedView< T > x, StridedView< T > y, ConstStridedView< Real > c, ConstStridedView< T > s)
static void lartg(const T &f_in, const T &g_in, Real &c, T &s, T &r)
static void rot_pair(T &x, T &y, Real c, const T &s_in)
static void prepare_work_for_right(int, T *, int)
typename base_type< T >::type Real
static void rot(int nrot, StridedView< T > x, StridedView< T > y, Real c, const T &s_in)
static void lar2v_pair(T &x, T &y, T &z, Real ci, const T &si_in)
static void lar2v(int nrot, StridedView< T > x, StridedView< T > y, StridedView< T > z, ConstStridedView< Real > c, ConstStridedView< T > s)
typename base_type< T >::type Real
static void lartv(int nrot, StridedView< T > x, StridedView< T > y, ConstStridedView< Real > c, ConstStridedView< T > s)
static void lartg(const T &f, const T &g, Real &c, T &s, T &r)
static void lar2v_pair(T &x, T &y, T &z, Real ci, const T &si)
static void prepare_work_for_right(int nrot, T *s, int stride)
static void rot_pair(T &x, T &y, Real c, const T &s)
static void lar2v(int nrot, StridedView< T > x, StridedView< T > y, StridedView< T > z, ConstStridedView< Real > c, ConstStridedView< T > s)
static void ensure_band_diag_real(T *AB, int ldab, int n)
static void rot(int nrot, StridedView< T > x, StridedView< T > y, Real c, const T &s)
static void finalize_tridiag(KernelMatrixView< T, MatrixFormat::Dense > AB, int n, VectorView< Real > D, VectorView< Real > E, VectorView< T > TAU)
static void largv(int nrot, StridedView< T > x, StridedView< T > w, StridedView< Real > c)
#define BTRD_LOWER_INPLACE_SUBGROUP_DISPATCH_EXTERN(fp, real_fp)
#define BATCHLAS_FOR_EACH_SYTRD_SB2ST_CTA_DISPATCH_TYPE(INVOKE)